syzbot
KCSAN: data-race in bpf_prog_run_clear_cb / ns_capable
Status:
moderation: reported on 2026/11/18 00:01
Subsystems:
lsm
Labels:
prio:low
race:benign
[Documentation on labels]
Reported-by: syzbot+1f5a1d1d73fdd1ac852e@syzkaller.appspotmail.com
First crash: 14h09m, last: 14h09m
✨ AI-generated root cause summary:
In ns_capable_common() (kernel/capability.c:343), 'current->flags |= PF_SUPERPRIV;' executes an unmarked, non-atomic read-modify-write on task_struct::flags. When KCSAN sets a watchpoint on current->flags, an interrupt/softirq (such as handle_softirqs() in kernel/softirq.c) running on the same CPU with in_task() == true reads current->flags, triggering a watchpoint hit. When stack_trace_save() yields no stack frames for the reader, print_report() in kernel/kcsan/report.c accesses other_info->stack_entries[other_skipnr] without bounds checking, reading a stale symbol (bpf_prog_run_clear_cb) left behind from a previous watchpoint slot in the un-zeroed other_infos[] array, producing a misleading bug title and an empty stack trace.
▶
▼
✨ Full AI root cause analysis
Technical Root Cause Breakdown
1. Functions, Structs, and Fields Involved
ns_capable_common() (kernel/capability.c:343): Checks process capabilities and performs current->flags |= PF_SUPERPRIV;.
struct task_struct::flags (include/linux/sched.h): Per-task flag word located at offset 0x2c (bit offset 352) within task_struct. The address 0xffff88810411802c in the report corresponds directly to ¤t->flags of task 3296 (0xffff888104118000).
handle_softirqs() (kernel/softirq.c:628): Interrupt/softirq entry helper that executes unsigned long old_flags = current->flags; before disabling bottom halves (softirq_handle_begin()).
print_report(), release_report(), prepare_report_producer() (kernel/kcsan/report.c): KCSAN reporting infrastructure responsible for managing struct other_info other_infos[].
2. Detailed Technical Mechanism
A. The Underlying Concurrency Race
-
Watchpoint Setup:
task 3296 executes the getsockopt syscall (do_ipt_get_ctl() -> ns_capable() -> ns_capable_common()).
- Line 343 of
kernel/capability.c executes current->flags |= PF_SUPERPRIV;.
- In KCSAN instrumentation (
check_access() -> kcsan_setup_watchpoint()), KCSAN selects this access and installs a watchpoint on 0xffff88810411802c (current->flags).
- With
CONFIG_KCSAN_INTERRUPT_WATCHER=y, local interrupts are kept enabled while the task spins inside delay_access() (udelay()).
-
The Conflicting Read Access:
B. Why the First Stack Trace is Empty and the Title References bpf_prog_run_clear_cb
- Unwind Failure:
- KCSAN Reporting Out-of-Bounds Frame Read:
release_report() (kernel/kcsan/report.c:509) only resets other_info->ai.size = 0 when freeing a report slot; it does not zero out other_info->stack_entries[].
- In
print_report():
other_skipnr = sanitize_stack_entries(other_info->stack_entries,
other_info->num_stack_entries,
other_info->ai.ip, &other_reordered_to);
other_frame = other_info->stack_entries[other_skipnr];
sanitize_stack_entries() calls get_stack_skipnr(), which returns skip == num_entries.
Because there is no check ensuring other_skipnr < other_info->num_stack_entries, other_frame reads stack_entries[other_skipnr], accessing stale residual data from an earlier test report that previously occupied this slot in other_infos[].
- In this instance, the stale frame left in
stack_entries[] was bpf_prog_run_clear_cb.
- Because
other_frame (bpf_prog_run_clear_cb) sorts lexicographically before this_frame (ns_capable), the bug report header prints:
BUG: KCSAN: data-race in bpf_prog_run_clear_cb / ns_capable
- Subsequently,
print_stack_trace() is called with num_entries = other_info->num_stack_entries - other_skipnr == 0, outputting zero lines for the first stack trace.
Sample crash report:
* Struck through repros no longer work on HEAD.