Skip to content

schedule: zephyr_ll_user: return heap address instead of user copy - #11365

Open
kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202610-sched-robust-fix2
Open

kv2019i wants to merge 1 commit into
thesofproject:mainfrom
kv2019i:202610-sched-robust-fix2

Conversation

@kv2019i

@kv2019i kv2019i commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

zephyr_ll_user_heap() returned zephyr_ll_heap, a pointer stored in user-writable memory (APP_SYSUSER_DATA). Kernel code reaching it through sof_sys_user_heap_get(), for example dma_init() under the sof_dma_get() system call or the data blob allocations under mod_data_blob_handler_new(), would then run the heap code in supervisor mode on whatever k_heap a user thread had pointed it at.

The heap object's address is a link-time constant, so return it directly. User threads can still call the function, as taking the address reads no kernel memory, and the heap system call validators already compare the pointer with this address. The user-writable copy is no longer needed and is removed. zephyr_ll_user_resources_init() runs before platform_init(), so no caller relies on the old NULL return before initialization.

zephyr_ll_user_heap() returned zephyr_ll_heap, a pointer stored in
user-writable memory (APP_SYSUSER_DATA). Kernel code reaching it through
sof_sys_user_heap_get(), for example dma_init() under the sof_dma_get()
system call or the data blob allocations under mod_data_blob_handler_new(),
would then run the heap code in supervisor mode on whatever k_heap a user
thread had pointed it at.

The heap object's address is a link-time constant, so return it
directly. User threads can still call the function, as taking the
address reads no kernel memory, and the heap system call validators
already compare the pointer with this address. The user-writable copy
is no longer needed and is removed. zephyr_ll_user_resources_init() runs
before platform_init(), so no caller relies on the old NULL return
before initialization.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>

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.

🟢 Approval recommended

The focused change removes an untrusted pointer dependency while preserving validator consistency and initialization ordering.

No open issues 🎉

What changed in this PR

This PR hardens the LL scheduler’s heap accessor so kernel callers no longer rely on a heap pointer stored in user-writable memory.

Changes:

  • Return the kernel heap object’s address directly and remove the user-writable pointer and its initialization.
  • Update documentation to explain the accessor’s safety and heap-pointer validation.
File Description
src/​schedule/​zephyr_ll_user.c Returns the heap address directly and documents safe kernel and user-space use.
src/​include/​sof/​userspace/​README.md Updates the userspace guidance to reflect the direct-address accessor.

Review effort: Balanced

@intel-sofci

Copy link
Copy Markdown

PR 11365: test results

Run date: 2026-10-27 12:35 UTC

Tested commit: 59487c2de7bca7528dcf18a649021730daf4a153

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

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