Skip to content

data-blob: add a syscall to call comp_data_blob_set() from userspace - #11251

Open
lyakh wants to merge 2 commits into
thesofproject:mainfrom
lyakh:blob
Open

lyakh wants to merge 2 commits into
thesofproject:mainfrom
lyakh:blob

Conversation

@lyakh

@lyakh lyakh commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

This continues work in #11199 which in 78d5c92 enabled using data blobs in module context, but to use it in userspace an additional syscall is needed. This is needed for #11135

Copilot AI balanced review requested due to automatic review settings September 30, 2026 08:38

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.

Copilot review overview

🟡 Changes recommended

The syscall lacks userspace buffer validation and introduces problematic singleton blob-handler semantics.

Review effort: Balanced
Findings: 2 High severity · 1 Low severity

Open (3)
What changed in this PR

Adds userspace access to module data-blob configuration, supporting DP modules such as microwakeword.

Changes:

  • Adds mod_data_blob_set() syscall and verifier.
  • Reuses tracked blob handlers.
  • Moves zero-size allocation rejection before locking.
File Description
generic.h Declares the data-blob syscall API.
generic.c Implements blob lookup, setting, verification, and allocation adjustment.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/audio/module_adapter/module/generic.c
Comment thread src/include/sof/audio/module_adapter/module/generic.h
Comment thread src/audio/module_adapter/module/generic.c
Checking for size == 0 can be done in the beginning of
z_impl_mod_alloc_ext() to simplify clean up.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Modules, running in the userspace cannot call comp_data_blob_set()
directly. Add a module wrapper syscall for it. This also performs the
same access rights check as other module syscalls. Also enforce a
single data blob per module.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>

@kv2019i kv2019i left a comment

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.

Spotted one problem, but it's not specific to this PR, so needs to be handled in a follow-up.

struct module_resource *container;

k_mutex_lock(&mod_res_lock, K_FOREVER);
int ret = objpool_iterate(&res->objpool, mod_data_blob_find, &bhp);

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 a new issue with this PR, but now realize this is not safe. objpool_iterate will go through pointers that may not be safe and z_vrfy_mod_data_blob_set() won't cover this.

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