Skip to content

audio: crossover: Improve robustness for invalid configuration#10904

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
singalsu:crossover_updates
Jun 18, 2026
Merged

audio: crossover: Improve robustness for invalid configuration#10904
lgirdwood merged 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).

@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 thread src/audio/crossover/crossover.c
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;
}

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 opinion appears for every module. I think we should address it at framework level to let a component validate what comp_is_new_data_blob_available() offers before copying it with comp_get_data_blob(),

Comment thread src/audio/crossover/crossover.c Outdated
Comment thread src/audio/crossover/crossover.c Outdated
Comment thread src/audio/crossover/crossover.c Outdated
@singalsu

Copy link
Copy Markdown
Collaborator Author

Note: I can't test this in a device at the moment but tested it in sof-testbench4, e.g.

sox --encoding signed-integer /usr/share/sounds/alsa/Front_Left.wav -L -r 48000 -c 2 -b 32 in.raw
tools/testbench/build_testbench/install/bin/sof-testbench4 -r 48000 -c 2 -b S32_LE   -p 1,101,102 -t tools/build_tools/topology/topology2/development/sof-tgl-nocodec-crossover-2way.tplg   -i in.raw -o out1.raw,out2.raw
sox --encoding signed-integer -L -r 48000 -c 2 -b 32 out1.raw ~/tmp/out1.wav
sox --encoding signed-integer -L -r 48000 -c 2 -b 32 out2.raw ~/tmp/out2.wav

With a chirp e.g. left up, right down the effect of filtering is very visible in spectrogram.

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 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread src/audio/crossover/crossover.c
Comment thread src/audio/crossover/crossover.c

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 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/audio/crossover/crossover.c Outdated
@singalsu singalsu force-pushed the crossover_updates branch from 55695c8 to f073d83 Compare June 15, 2026 10:29
@singalsu

Copy link
Copy Markdown
Collaborator Author

The quickbuild fail for MTL (only, other platforms OK) Test HDA passthrough compress data is not related to this change.

@singalsu singalsu requested review from kv2019i and lgirdwood June 16, 2026 13:31
Comment thread src/audio/crossover/crossover.c Outdated
@singalsu singalsu force-pushed the crossover_updates branch from f073d83 to 4ebae2c Compare June 17, 2026 10:52
@singalsu singalsu requested a review from lyakh June 17, 2026 10:52
Comment thread src/audio/crossover/crossover.c Outdated
return ret;
}

if (cd->config) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ok, I should've commented on this earlier, so, you don't need to do a new version just for that, but if you do end up doing a new iteration - I'd join these two if (cd->config) branches and removed int from int ret below to not overshadow the new ret variable that you've added globally in this function. If you don't redo this PR, we can fix it as a follow-up.

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.

Oops - I've fixed it now. There was also one wrong comp_err() trace print that I fixed.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

thanks :-)

@singalsu

Copy link
Copy Markdown
Collaborator Author

The quickbuild test fail basic hda link random dma can't be related to this.

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 force-pushed the crossover_updates branch from 4ebae2c to 7251254 Compare June 18, 2026 08:15
@lgirdwood

Copy link
Copy Markdown
Member

The quickbuild test fail basic hda link random dma can't be related to this.

Agree, cross over not tested by internal CI.

@lgirdwood lgirdwood merged commit 121c9c7 into thesofproject:main Jun 18, 2026
43 checks passed
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.

5 participants