-
Notifications
You must be signed in to change notification settings - Fork 361
copier: validate host-supplied gateway config and queue indices #10908
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
Changes from all commits
8112cf2
950e2b1
41c285f
adea8a7
c48d2a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,6 +88,16 @@ static int copier_alh_assign_dai_index(struct comp_dev *dev, | |
| switch (dai->type) { | ||
| case SOF_DAI_INTEL_HDA: | ||
| /* We use DAI_INTEL_HDA for ACE 2.0 platforms */ | ||
| /* | ||
| * alh_cfg.count is host-controlled and scales the config size | ||
| * and mapping[] walk below; bound it before any arithmetic so a | ||
| * crafted blob cannot read past the gateway config. | ||
| */ | ||
| if (alh_blob->alh_cfg.count > IPC4_ALH_MAX_NUMBER_OF_GTW) { | ||
| comp_err(mod->dev, "Invalid ALH count: %u", | ||
| alh_blob->alh_cfg.count); | ||
| return -EINVAL; | ||
| } | ||
|
Comment on lines
+96
to
+100
Member
Author
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.
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. it would be more logical to just use
Member
Author
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. @lyakh Agree, at some point we need to go through and clean up logging APIs as the Zephyr transition is now ready for this, I would land this after userspace though. |
||
| alh_cfg_size = get_alh_config_size(alh_blob); | ||
| dma_config = (uint8_t *)gtw_cfg_data + alh_cfg_size; | ||
| dma_config_length = (cd->config.gtw_cfg.config_length << 2) - alh_cfg_size; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -330,6 +330,12 @@ void copier_update_params(struct copier_data *cd, struct comp_dev *dev, | |
| int j; | ||
| j = IPC4_SRC_QUEUE_ID(buf_get_id(sink)); | ||
|
|
||
| /* src_queue id is host-controlled; bound it before indexing out_fmt[] */ | ||
| if (j >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) { | ||
| comp_err(dev, "invalid src_queue id %d", j); | ||
| continue; | ||
| } | ||
|
|
||
| ipc4_update_buffer_format(sink, &cd->out_fmt[j]); | ||
|
Comment on lines
330
to
339
Member
Author
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.
|
||
| } | ||
|
|
||
|
|
||
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.
Fixed — changed the format specifier to
%u(data_offsetisuint32_t).