ipc4: helper: guard TLV loop against NULL from tlv_next()#10780
Merged
lgirdwood merged 2 commits intoMay 15, 2026
Conversation
Add 'tlvs &&' to the for-loop condition in ipc4_find_dma_config_multiple(). tlv_next() returns NULL on malformed TLV (length not a multiple of 4). The existing loop condition '(uint32_t)tlvs < end_addr' does not catch NULL (0 < end_addr is always true), causing a NULL pointer dereference in the next iteration via tlv_value_ptr_get() or tlv_next(). Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Guards a TLV iteration loop against a NULL return from tlv_next() to prevent a NULL pointer dereference when parsing malformed TLVs.
Changes:
- Add
tlvs &&to thefor-loop condition inipc4_find_dma_config_multiple()so the loop terminates whentlv_next()returns NULL.
lyakh
approved these changes
May 15, 2026
Collaborator
lyakh
left a comment
There was a problem hiding this comment.
@abonislawski are other uses of tlv_next() safe or is the data there guaranteed well formed? E.g. in base_fw.c? If tlv_next() returns NULL there we'll crash too.
Add 'tlv &&' to the while-loop condition in tlv_value_get(). tlv_next() returns NULL on malformed TLV (length not a multiple of 4). The existing condition '(uint32_t)tlv < end_addr' does not catch NULL, causing a NULL dereference on the next iteration. This is reachable from host IPC via copier_host_create() which parses optional TLV data appended to the copier module configuration blob. Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Member
Author
|
@lyakh yes, data in base_fw.c and base_fw_intel.c is well-formed and guaranteed by FW. But there is one more vulnerable spot in tlv_value_get() called from copier_host_create() on host IPC data, same fix applied in follow-up commit. |
lgirdwood
approved these changes
May 15, 2026
tmleman
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add 'tlvs &&' to the for-loop condition in ipc4_find_dma_config_multiple(). tlv_next() returns NULL on malformed TLV (length not a multiple of 4). The existing loop condition '(uint32_t)tlvs < end_addr' does not catch NULL (0 < end_addr is always true), causing a NULL pointer dereference.