audio: crossover: Improve robustness for invalid configuration#10904
Open
singalsu wants to merge 1 commit into
Open
audio: crossover: Improve robustness for invalid configuration#10904singalsu wants to merge 1 commit into
singalsu wants to merge 1 commit into
Conversation
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>
Contributor
There was a problem hiding this comment.
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 callingcrossover_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; |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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).