Skip to content

audio: eq_fir: Improve robustness for invalid configuration#10895

Open
singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:fir_updates
Open

audio: eq_fir: Improve robustness for invalid configuration#10895
singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:fir_updates

Conversation

@singalsu

@singalsu singalsu commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Validate the IPC configuration blob to prevent out-of-bounds reads when walking FIR coefficient sections:

@singalsu singalsu marked this pull request as ready for review June 12, 2026 10:28
Copilot AI review requested due to automatic review settings June 12, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Tightens validation of the EQ FIR IPC configuration blob to avoid out-of-bounds reads when parsing coefficient sections.

Changes:

  • Track configuration blob size in comp_data and validate it on prepare and on runtime updates.
  • Pass blob size into eq_fir_init_coef() and add size/structure bounds checks while walking responses.
  • Update validator path to supply new_data_size for cross-checking blob self-declared size.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/audio/eq_fir/eq_fir.h Store the configuration blob size alongside the config pointer.
src/audio/eq_fir/eq_fir.c Thread blob size through init/validation paths and add bounds checks while parsing FIR response data.

Comment thread src/audio/eq_fir/eq_fir.c
Comment thread src/audio/eq_fir/eq_fir.c
Comment thread src/audio/eq_fir/eq_fir.c Outdated
Comment on lines +369 to +376
if (comp_is_new_data_blob_available(cd->model_handler)) {
cd->config = comp_get_data_blob(cd->model_handler, NULL, NULL);
cd->config = comp_get_data_blob(cd->model_handler, &cd->config_size, NULL);
if (!cd->config || cd->config_size < sizeof(*cd->config) ||
cd->config_size > SOF_EQ_FIR_MAX_SIZE) {
comp_err(mod->dev, "invalid configuration blob, size %zu",
cd->config_size);
return -EINVAL;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something to address later.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread src/audio/eq_fir/eq_fir.c
Comment thread src/audio/eq_fir/eq_fir.c
Comment thread src/audio/eq_fir/eq_fir.c
Harden the EQ FIR setup path against malformed IPC configuration blobs.

The blob length returned by comp_get_data_blob() is now stored and
checked against the expected range every time a new blob is taken, and
the blob's self-declared size is cross-checked against it before use.
The per-response walk that previously trusted the FIR length field from
the blob now bounds the header and coefficient data against the blob,
and rejects lengths that are non-positive, exceed SOF_FIR_MAX_LENGTH or
are not a multiple of four.

The IPC validator applies the same blob length bounds before calling
into eq_fir_init_coef(), so an oversized or truncated blob is rejected
up front rather than at prepare or process time. Also a blob that has
an odd channels_in_config is rejected to ensure the coefficients are
aligned per current ASSUME_ALIGNED() constraint.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread src/audio/eq_fir/eq_fir.c
Comment on lines +105 to +108
if (config->size != config_size) {
comp_err(dev, "Incorrect configuration blob size");
return -EINVAL;
}
Comment thread src/audio/eq_fir/eq_fir.c
Comment on lines +116 to +124
/* channels_in_config indexes into a int16_t array. An odd count would
* leave the coefficient area at a 2-byte alignment, breaking the
* 4-byte aligned int32_t loads in the optimized FIR kernels.
*/
if (config->channels_in_config & 0x1) {
comp_err(dev, "channels_in_config %u must be even",
config->channels_in_config);
return -EINVAL;
}
Comment thread src/audio/eq_fir/eq_fir.c
Comment on lines +281 to +286
static int eq_fir_check_blob_size(struct comp_dev *dev, size_t size)
{
if (size < sizeof(struct sof_eq_fir_config) || size > SOF_EQ_FIR_MAX_SIZE) {
comp_err(dev, "invalid configuration blob, size %zu", size);
return -EINVAL;
}
Comment thread src/audio/eq_fir/eq_fir.c
Comment on lines 470 to 476
cd->eq_fir_func = eq_fir_passthrough;
cd->config = comp_get_data_blob(cd->model_handler, &data_size, NULL);
if (cd->config && data_size > 0) {
cd->config = comp_get_data_blob(cd->model_handler, &cd->config_size, NULL);
if (cd->config) {
if (eq_fir_check_blob_size(dev, cd->config_size) < 0)
return -EINVAL;

ret = eq_fir_setup(mod, channels);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants