Commit 7183cde
committed
ipc4: basefw_set_fw_config: validate TLV size
basefw_set_fw_config() cast the IPC payload directly to struct sof_tlv*
and read tlv->type without checking that the reported payload length
(data_offset) was sufficient. A zero-length or undersized LargeConfigSet
with param_id=IPC4_FW_CONFIG could cause the handler to access memory
beyond the valid payload (CWE-125 / CWE-20).
Three guards are added before any TLV field access:
1. data_offset < sizeof(struct sof_tlv)
Rejects payloads too short to hold the type+length header (8 B).
2. data_offset < sizeof(struct sof_tlv) + tlv->length
Rejects payloads where the declared value length exceeds the
actual buffer, preventing OOB reads of tlv->value[].
3. tlv->length < sizeof(uint32_t) for IPC4_DMI_FORCE_L1_EXIT
Rejects a TLV whose value field is too small to contain the
force flag read by fw_config_set_force_l1_exit().
The TLV pointer cast is moved to after the header-size check so it
is never formed against an undersized buffer.
The warning log for unhandled types is updated to include the type
value to aid diagnostics.
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>1 parent c26c542 commit 7183cde
1 file changed
Lines changed: 23 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
473 | 482 | | |
474 | 483 | | |
475 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
476 | 491 | | |
477 | 492 | | |
478 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
479 | 499 | | |
480 | 500 | | |
481 | 501 | | |
482 | 502 | | |
483 | | - | |
| 503 | + | |
| 504 | + | |
484 | 505 | | |
485 | 506 | | |
486 | 507 | | |
| |||
0 commit comments