-
Notifications
You must be signed in to change notification settings - Fork 353
ipc4: base_fw: fix OOB reads and input validation in LargeConfig handlers #10757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tmleman
wants to merge
3
commits into
thesofproject:main
Choose a base branch
from
tmleman:topic/upstream/pr/ipc4/fix/base_fw
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−14
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -470,17 +470,38 @@ __cold static int fw_config_set_force_l1_exit(const struct sof_tlv *tlv) | |
| __cold static int basefw_set_fw_config(bool first_block, bool last_block, | ||
| uint32_t data_offset, const char *data) | ||
| { | ||
| assert_can_be_cold(); | ||
|
|
||
| /* Validate minimum TLV header (type + length fields) is present */ | ||
| if (data_offset < sizeof(struct sof_tlv)) { | ||
| tr_err(&basefw_comp_tr, "FW_CONFIG payload too small: %u < %zu", | ||
| data_offset, sizeof(struct sof_tlv)); | ||
| return IPC4_INVALID_CONFIG_DATA_LEN; | ||
| } | ||
|
|
||
| const struct sof_tlv *tlv = (const struct sof_tlv *)data; | ||
|
|
||
| assert_can_be_cold(); | ||
| /* Validate the TLV value payload fits within the reported buffer size */ | ||
| if (tlv->length > data_offset - sizeof(struct sof_tlv)) { | ||
| tr_err(&basefw_comp_tr, | ||
| "FW_CONFIG TLV value truncated: len %u exceeds payload %u", | ||
| tlv->length, data_offset); | ||
| return IPC4_INVALID_CONFIG_DATA_LEN; | ||
| } | ||
|
|
||
| switch (tlv->type) { | ||
| case IPC4_DMI_FORCE_L1_EXIT: | ||
| if (tlv->length < sizeof(uint32_t)) { | ||
| tr_err(&basefw_comp_tr, "DMI_FORCE_L1_EXIT value too small: %u", | ||
| tlv->length); | ||
| return IPC4_INVALID_CONFIG_DATA_LEN; | ||
| } | ||
| return fw_config_set_force_l1_exit(tlv); | ||
| default: | ||
| break; | ||
| } | ||
| tr_warn(&basefw_comp_tr, "returning success for Set FW_CONFIG without handling it"); | ||
|
|
||
| tr_warn(&basefw_comp_tr, "Set FW_CONFIG: no handler for type %u", tlv->type); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you add a linefeed above, I'd keep one empty line between function body and return to conform with codebase style. |
||
| return 0; | ||
| } | ||
|
|
||
|
|
@@ -502,9 +523,15 @@ static int basefw_mic_priv_state_changed(bool first_block, | |
| const char *data) | ||
| { | ||
| #if CONFIG_INTEL_ADSP_MIC_PRIVACY | ||
| tr_info(&basefw_comp_tr, "state changed to %d", *data); | ||
| if (data_offset_or_size < sizeof(uint8_t)) { | ||
| tr_err(&basefw_comp_tr, "mic_priv_state_changed: payload too small: %u", | ||
| data_offset_or_size); | ||
| return IPC4_ERROR_INVALID_PARAM; | ||
| } | ||
|
|
||
| uint32_t mic_disable_status = (uint32_t)(uint8_t)(*data); | ||
|
|
||
| uint32_t mic_disable_status = (uint32_t)(*data); | ||
| tr_info(&basefw_comp_tr, "state changed to %u", mic_disable_status); | ||
| struct mic_privacy_settings settings; | ||
|
|
||
| mic_privacy_fill_settings(&settings, mic_disable_status); | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this
IPC4_LIBRARIES_INFO_GETIPC has never been used until now