Skip to content

audio: drc: register IPC-time blob validator#10943

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

audio: drc: register IPC-time blob validator#10943
singalsu wants to merge 1 commit into
thesofproject:mainfrom
singalsu:model_handler_validator_drc

Conversation

@singalsu

Copy link
Copy Markdown
Collaborator

Hook a drc blob validator into the model handler so a corrupted run-time configuration update is rejected before it can replace the working blob. Playback or capture then continues with the previously set parameters instead of being interrupted by a bad IPC.

The DRC configuration is a fixed-size struct sof_drc_config, so the validator requires the IPC payload size to match exactly and the self-declared config->size to agree with it. The same size check is also reused at prepare time when the initial blob is fetched.

Comment thread src/audio/drc/drc.c Outdated
if (ret < 0)
return ret;

if (config->size != new_data_size) {

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.

not sure why 2 functions are needed, can we just make it a simple check if (new_data_size != sizeof(struct sof_drc_config) || new_data_size != config->size)?

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.

Yep, you are right. It makes sense to combine them.

Hook a drc blob validator into the model handler so a corrupted
run-time configuration update is rejected before it can replace the
working blob. Playback or capture then continues with the previously
set parameters instead of being interrupted by a bad IPC.

The DRC configuration is a fixed-size struct sof_drc_config, so the
validator requires the IPC payload size to match exactly and the
self-declared config->size to agree with it. The same size check is
also reused at prepare time when the initial blob is fetched.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu force-pushed the model_handler_validator_drc branch from 20c85b6 to e0ff5f6 Compare June 29, 2026 16:16
@singalsu singalsu marked this pull request as ready for review June 29, 2026 16:21
@singalsu singalsu requested a review from a team as a code owner June 29, 2026 16:21
Copilot AI review requested due to automatic review settings June 29, 2026 16:21

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

This PR adds an IPC-time validator for the DRC configuration blob so malformed run-time updates are rejected before they can replace the currently active configuration, and reuses the same validation at prepare() time when initially loading the blob.

Changes:

  • Introduce a drc_validator() that enforces exact payload size matching struct sof_drc_config and verifies config->size consistency.
  • Apply the validator to the initial configuration fetch in drc_prepare().
  • Register/unregister the validator on the data-blob handler in drc_prepare()/drc_reset() to prevent corrupted IPC updates from being accepted during streaming.

Comment thread src/audio/drc/drc.c
Comment on lines 394 to 397
} else {
/* Generic function for all formats */
cd->drc_func = drc_default_pass;
}
Comment thread src/audio/drc/drc.c
Comment on lines +146 to +151
if (new_data_size != sizeof(struct sof_drc_config) ||
new_data_size != config->size) {
comp_err(dev, "invalid configuration blob, size %u, expected %zu",
new_data_size, sizeof(struct sof_drc_config));
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.

3 participants