diff options
| author | Tejun Heo <tj@kernel.org> | 2026-07-13 22:18:42 -1000 |
|---|---|---|
| committer | Tejun Heo <tj@kernel.org> | 2026-07-13 22:18:42 -1000 |
| commit | cc7c254c8fd71818b4bd2fbf3dddcd2ebc79e678 (patch) | |
| tree | e665c178bf8fd05732f3d304a79daa86d741e4a8 /tools/perf/scripts/python/export-to-sqlite.py | |
| parent | 8dba3bbd63e39c97a4d45aea6e95e00b5d14bc8d (diff) | |
sched_ext: Add scx_cmask_ref for validated arena cmask access
kfuncs taking struct scx_cmask * from BPF arena memory have two problems.
The pointer can be any value the BPF prog hands in, and the header (@base,
@nr_cids, @alloc_words) can be mutated by the prog concurrently with kernel
access.
Add scx_cmask_ref, a validated handle. _init() normalizes the input pointer
into the arena's kern_vm range via scx_arena_to_kaddr() and snapshots the
header, rejecting a range outside the machine or a nr_cids whose words
exceed the declared @alloc_words. Downstream sizing uses the snapshot, not
the live header. _shard() reads slices while _or() and _copy() write back,
all bounded by the snapshot. No callers yet.
struct scx_cmask's bits[] carried __counted_by(alloc_words), so
UBSAN_BOUNDS and FORTIFY_SOURCE bound accesses to the array. That bound is
read from @alloc_words at the access. For an arena cmask @alloc_words is
BPF-writable. A prog that sets it larger than the real allocation makes the
check pass on a genuine overrun, so the annotation catches nothing, and it
only runs under those debug configs. Drop it - _init() validates
@alloc_words explicitly, and kernel-owned cmasks set it themselves.
v2: Validate @alloc_words in _init(), drop __counted_by. (Andrea, sashiko AI)
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Diffstat (limited to 'tools/perf/scripts/python/export-to-sqlite.py')
0 files changed, 0 insertions, 0 deletions
