Commit 4ae5905
committed
ipc4: handler-user: fix TLV walker pointer wraparound
The TLV walker loop in ipc4_set_vendor_config_module_instance() advances
the tlv pointer by sizeof(struct sof_tlv) + ALIGN_UP(tlv->length, 4)
without validating that the result stays within the IPC payload buffer.
Issue was found using static analysis security scanning tools and
confirmed by testing that a malformed or incorrectly crafted TLV with an
oversized length field causes the 32-bit pointer arithmetic to wrap
around, triggering a null pointer dereference and DSP panic.
Fix by:
1. Adding an upper-bound check on data_off_size against
MAILBOX_HOSTBOX_SIZE at function entry.
2. Validating on each loop iteration that the TLV header + value fits
within the remaining buffer bytes before calling set_large_config or
advancing the pointer. The check uses integer subtraction (not pointer
addition) to avoid undefined behavior from pointer overflow hat the
compiler could optimize away, and splits the comparison to prevent
size_t overflow when tlv->length is near UINT32_MAX.
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>1 parent 8d75e2c commit 4ae5905
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1088 | 1088 | | |
1089 | 1089 | | |
1090 | 1090 | | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
1091 | 1094 | | |
1092 | 1095 | | |
1093 | 1096 | | |
| |||
1097 | 1100 | | |
1098 | 1101 | | |
1099 | 1102 | | |
| 1103 | + | |
| 1104 | + | |
1100 | 1105 | | |
1101 | 1106 | | |
1102 | 1107 | | |
1103 | 1108 | | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
1104 | 1118 | | |
1105 | 1119 | | |
1106 | 1120 | | |
1107 | 1121 | | |
1108 | 1122 | | |
1109 | 1123 | | |
1110 | 1124 | | |
1111 | | - | |
| 1125 | + | |
1112 | 1126 | | |
1113 | 1127 | | |
1114 | 1128 | | |
| |||
0 commit comments