summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/stackcollapse.py
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2026-10-17 16:37:31 +0000
committerAlexei Starovoitov <ast@kernel.org>2026-10-17 22:01:15 +0000
commit8d0358f6e8b31fcf7d355026a83aac70cc675b19 (patch)
tree908569644264b71d8469ace113211c3b4dda708c /tools/perf/scripts/python/stackcollapse.py
parent7fe348f18b37b3f4c8beb981ef3f84564047380a (diff)
bpf: Keep iterator programs off special map fields
The bpf_map_elem iterator, for all but the per-cpu maps, and the bpf_sk_storage_map iterator hand the live value of an element to the program as a writable buffer. The verifier does not know the map when it checks the program, so nothing keeps the program from writing over a bpf_spin_lock, a bpf_timer, a kptr or another special field, which neither a map update nor a pointer to a map value can touch. With CAP_BPF and CAP_PERFMON, or a BPF token, a program can so make the kernel follow a pointer of its choice: after a write over a bpf_timer the kernel crashes on the written value when the element is removed. Offsets into a buffer are constants. Let the verifier record the range of bytes that a program may write through a read-write buffer, and refuse the program with -EACCES, at attach and at a link update, if a special field of the map lies in that range. A program that only reads, or that writes beside the special fields, works as before. One that writes on both sides of a special field is refused, since the range covers the field. Fixes: d6c4503cc296 ("bpf: Implement bpf iterator for hash maps") Fixes: 5ce6e77c7edf ("bpf: Implement bpf iterator for sock local storage map") Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261017163745.3341787-30-alexei.starovoitov@gmail.com
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions