Repository navigation
Conversation
z_impl_vregion_create_map() wrote the region start and size to the caller's buffers and then read them back to build the memory partition. As a system call these buffers are user memory, so another thread could change them in between and get arbitrary memory mapped into the LL domain. Read the requested size once, build the partitions from kernel locals and write the results only at the end. Also set vr->domain after the first partition is added, so a failure adding the second one unmaps the first. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
vregion_verify() accepted any pointer to memory the caller cannot read, as long as the two words at its start looked like a user-writable range. A forged handle let the kernel lock, count, initialize and free kernel memory of the caller's choice. A concurrent vregion_put() could also free a vregion between validation and use. Keep live vregions in a kernel-only list. vregion_verify_get() looks the handle up and takes a reference under the list lock, and the validators drop it after the call. vregion_put() removes the last reference and the list entry atomically with respect to lookups. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
kv2019i
requested review from
abonislawski,
dbaluta,
iuliana-prodan,
lbetlej,
lgirdwood,
lyakh,
mmaka1 and
plbossart
as code owners
November 3, 2026 17:41
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent user-space vregion_put() calls can consume each other’s validator references, freeing the region before another release accesses it and causing a kernel use-after-free.
1 open issue
What changed in this PR
This PR hardens virtual-region syscall validation by checking handles against a kernel-maintained list and taking temporary references during syscall execution.
Changes:
- Adds live-region tracking and reference-taking validation.
- Updates syscall wrappers and the validation API.
- Uses local mapping parameters and improves cleanup after partial mapping failures.
| File | Description |
|---|---|
zephyr/syscall/vregion.c |
Uses reference-taking validation in syscall wrappers. |
zephyr/lib/vregion.c |
Tracks live regions, updates lifetime handling, and hardens mapping setup. |
src/include/sof/lib/vregion.h |
Renames the validator and documents its reference ownership contract. |
Review effort: Balanced
Comment on lines
+64
to
+65
| z_impl_vregion_put(vr); | ||
| return z_impl_vregion_put(vr); |
PR 11396: test resultsRun date: 2026-11-03 18:01 UTC Tested commit: 33a7f58aaf569433959dfecfc3307ee9e1940e18 |
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.

A few fixes to vregion syscall validation.