Skip to content

audio: crossover: Improve robustness for invalid configuration#10904

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

audio: crossover: Improve robustness for invalid configuration#10904
singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:crossover_updates

Conversation

@singalsu

Copy link
Copy Markdown
Collaborator

crossover_validate_config() was only run on the initial blob in crossover_prepare(). Runtime IPC updates fetched in crossover_process_audio_stream() were applied without revalidation, so a bad blob could drive crossover_setup() with an out-of-range num_sinks. Validate the new blob before crossover_setup() runs.

Also extend the validator to cross-check config->size against the size reported by the framework and to require enough payload for the LR4 biquads that crossover_init_coef_ch() reads (1 pair for 2-way, 3 pairs for 3-way and 4-way).

crossover_validate_config() was only run on the initial blob in
crossover_prepare(). Runtime IPC updates fetched in
crossover_process_audio_stream() were applied without revalidation, so
a bad blob could drive crossover_setup() with an out-of-range
num_sinks. Validate the new blob before crossover_setup() runs.

Also extend the validator to cross-check config->size against the size
reported by the framework and to require enough payload for the LR4
biquads that crossover_init_coef_ch() reads (1 pair for 2-way, 3 pairs
for 3-way and 4-way).

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu marked this pull request as ready for review June 12, 2026 18:02
@singalsu singalsu requested a review from a team as a code owner June 12, 2026 18:02
Copilot AI review requested due to automatic review settings June 12, 2026 18:02

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.

Improves robustness of the crossover module by validating runtime-updated configuration blobs before applying them, and strengthening config validation to prevent out-of-range or undersized blobs from reaching setup/init paths.

Changes:

  • Re-validate IPC-updated config blobs in crossover_process_audio_stream() before calling crossover_setup().
  • Extend crossover_validate_config() to verify blob header size matches framework-reported size.
  • Add minimum payload-size checks for required LR4 biquad coefficients.

Comment on lines +381 to +387
/* Each channel reads 2 * num_lr4s biquads from config->coef[]; the
* runtime uses 1 LR4 pair for 2-way and 3 LR4 pairs otherwise.
* See tune/sof_crossover_generate_config.m script.
*/
num_lr4s = (config->num_sinks == CROSSOVER_2WAY_NUM_SINKS) ? 1 : 3;
required_size = sizeof(*config) + (size_t)num_lr4s * 2 * sizeof(struct sof_eq_iir_biquad);
if (size < required_size) {
Comment on lines 478 to +484
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, &cfg_size, NULL);
if (!cd->config || !cfg_size ||
crossover_validate_config(mod, cd->config, cfg_size) < 0) {
comp_err(dev, "invalid runtime config blob");
return -EINVAL;
}
Comment on lines +369 to 371
if (size > SOF_CROSSOVER_MAX_SIZE || !size || size != new_size) {
comp_err(dev, "size %d is invalid", size);
return -EINVAL;
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.

2 participants