Skip to content

schedule: dp: keep DP task kernel objects in a kernel-only record - #11360

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

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

Conversation

@kv2019i

@kv2019i kv2019i commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

scheduler_dp_internal_free() freed the event and thread objects, removed memory domain partitions and deinitialized the memory domain using pointers read from task_memory. That memory is in the module heap, which user threads can write, and the validator did not check mod->mdom at all. A caller could make the kernel free arbitrary kernel objects or operate on a forged memory domain.

Record the event, thread, memory domain, partitions and component id in kernel memory when the DP task is created. The free path, including the syscall, now only uses the task pointer as a lookup key, and rejects unknown or already freed tasks.

scheduler_dp_internal_free() freed the event and thread objects, removed
memory domain partitions and deinitialized the memory domain using
pointers read from task_memory. That memory is in the module heap, which
user threads can write, and the validator did not check mod->mdom at
all. A caller could make the kernel free arbitrary kernel objects or
operate on a forged memory domain.

Record the event, thread, memory domain, partitions and component id in
kernel memory when the DP task is created. The free path, including the
syscall, now only uses the task pointer as a lookup key, and rejects
unknown or already freed tasks.

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.

🟡 Changes recommended

Teardown removes caller authorization checks and still follows user-writable allocator metadata in privileged context.

2 open issues
What changed in this PR

This PR hardens DP scheduler teardown by recording kernel-object ownership outside user-writable task memory.

Changes:

  • Adds a kernel-only task registry protected by a spinlock.
  • Uses recorded objects, domain partitions, and component IDs during cleanup.
  • Rejects unknown or already-freed task pointers and adds allocation-failure cleanup for records.
File Description
src/​schedule/​zephyr_dp_schedule_application.c Adds trusted task records and routes teardown through registry lookup.

Review effort: Balanced

k_object_free(kobj->thread);
scheduler_dp_domain_free(kobj->mod, kobj->mdom, kobj->mpart, kobj->comp_id);

mod_free(kobj->mod, container_of(task, struct scheduler_dp_task_memory, task));
* Do not read task->priv_data: everything needed comes from the
* kernel-only record, and an unknown task pointer is rejected.
*/
K_OOPS(!scheduler_dp_internal_free_kobj(task));
@intel-sofci

Copy link
Copy Markdown

PR 11360: test results

Run date: 2026-10-26 18:02 UTC

Tested commit: 2d0e980434088b49ec5be58ec9dbba9807d4f929

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