Commit 46016cb
ipc4: handler: bound get_large_config reply size to the reply buffer
The IPC4 fuzzer (simple-IPC-fuzz_sh) aborts with an AddressSanitizer
stack-overflow report in the ipc_send_wq thread, inside vfprintf() under
posix_print_trace(). That report is a red herring: the real failure is an
assert, and the recursive assert -> k_panic -> assert loop that follows it
is what eventually exhausts the 8MB pthread stack native_sim gives the
thread. With -jobs>1 the harness passes -close_fd_mask=1, so printk (which
goes to stdout) is discarded and only the secondary ASan report on stderr
survives into the CI log.
The assert is:
ASSERTION FAIL [!dsp_write_err] @ sof/src/include/sof/lib/mailbox.h:52
reached from ipc_send_queued_msg() -> ipc_platform_send_msg() ->
mailbox_dspbox_write(0, msg->tx_data, 918016), i.e. a reply claiming
~900KB of payload for a 4KB mailbox.
ipc4_get_large_config_module_instance() seeds data_offset from
config->extension.r.data_off_size, a 20-bit host-controlled field, and then
passes it to drv->ops.get_large_config() as an in/out parameter. A module
whose .get_configuration produces no data (template_get_config() is the one
the fuzzer found, but any IPC3-oriented stub behaves the same) returns
success without writing *data_offset_size, so the host-supplied value
survives unchanged and is published as msg_reply->tx_size. The payload
itself lives in ipc->comp_data, which is only SOF_IPC_MSG_MAX_SIZE bytes.
Only the VENDOR_CONFIG_PARAM branch bounds data_off_size today, and it does
so for the inbound hostbox read, not for the reply. With asserts compiled
out, memcpy_s() rejects the copy but the return value is discarded and
dcache_writeback_region() is still asked to write back the out-of-range
length, so the caller sends a reply header advertising a size that was
never copied.
Bound the reply size against the space actually left in the reply buffer
before it is published, and fail the command with
IPC4_INVALID_CONFIG_DATA_LEN otherwise. The bound is computed from data
rather than from SOF_IPC_MSG_MAX_SIZE directly because the non-vendor
branch advances data by sizeof(reply) under CONFIG_LIBRARY. The same fix is
applied to ipc4_process_large_config_get(), the CONFIG_SOF_USERSPACE_LL
variant, which has the identical flaw.
Reproduced and verified on native_sim/native/64 with the crash artifact
from the failing CI run (thesofproject/sof PR 11193, job simple-IPC-fuzz_sh
(4)): it aborts before the change and exits 0 after it. A subsequent
420s/8-job fuzz run over a ~10k-input corpus produced no new artifacts, and
an intel_adsp/ace30/ptl cross-build is clean.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 52dd10e commit 46016cb
1 file changed
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1103 | 1103 | | |
1104 | 1104 | | |
1105 | 1105 | | |
| 1106 | + | |
1106 | 1107 | | |
1107 | 1108 | | |
1108 | 1109 | | |
| |||
1167 | 1168 | | |
1168 | 1169 | | |
1169 | 1170 | | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1170 | 1186 | | |
1171 | 1187 | | |
1172 | 1188 | | |
| |||
1199 | 1215 | | |
1200 | 1216 | | |
1201 | 1217 | | |
| 1218 | + | |
1202 | 1219 | | |
1203 | 1220 | | |
1204 | 1221 | | |
| |||
1274 | 1291 | | |
1275 | 1292 | | |
1276 | 1293 | | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1277 | 1309 | | |
1278 | 1310 | | |
1279 | 1311 | | |
| |||
0 commit comments