syzbot
KCSAN: data-race in 0x0 / capable_wrt_inode_uidgid
Status:
moderation: reported on 2026/11/19 00:03
Subsystems:
lsm
Labels:
prio:low
race:benign
[Documentation on labels]
Reported-by: syzbot+32f5a9784b5443d09ccb@syzkaller.appspotmail.com
First crash: 2d19h, last: 2d04h
✨ AI-generated root cause summary:
In ns_capable_common() (kernel/capability.c), when a capability check succeeds, current->flags |= PF_SUPERPRIV performs an unsynchronized, plain read-modify-write on current->flags. When KCSAN instruments this access with CONFIG_KCSAN_INTERRUPT_WATCHER=y, it installs a watchpoint and delays execution via udelay() without disabling interrupts or preemption. During this delay, an asynchronous event (such as preemption or scheduler/PSI hooks) on the same CPU in task context reads task_struct::flags, consuming the watchpoint. When stack unwinding for the reading context yields no non-KCSAN frames, KCSAN reports a data-race between 0x0 and capable_wrt_inode_uidgid.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
1. Functions, Structs, and Fields Involved
- File:
kernel/capability.c
- Function:
ns_capable_common() (invoked via ns_capable() and capable_wrt_inode_uidgid())
- Structure and Field:
struct task_struct::flags (offset 0x2c / byte 44 in the 64-byte slab-aligned task object 0xffff888104b41140, accessing address 0xffff888104b4116c)
- Flag:
PF_SUPERPRIV (0x00000100 defined in include/linux/sched.h)
2. Technical Mechanism and Trigger
-
Unsynchronized Read-Modify-Write in Capability Checks:
In kernel/capability.c:343:
static bool ns_capable_common(struct user_namespace *ns, int cap, unsigned int opts)
{
int capable;
...
capable = security_capable(current_cred(), ns, cap, opts);
if (capable == 0) {
current->flags |= PF_SUPERPRIV;
return true;
}
return false;
}
When a capability check succeeds during operations such as chown (chown_common -> notify_change -> shmem_setattr -> setattr_prepare -> chgrp_ok -> capable_wrt_inode_uidgid), ns_capable_common() sets PF_SUPERPRIV on current->flags using a plain C bitwise OR (|=).
-
KCSAN Watchpoint Setup:
Because current->flags |= PF_SUPERPRIV is compiled into a 4-byte read-modify-write (__tsan_read_write4), KCSAN selects this access and enters kcsan_setup_watchpoint() (kernel/kcsan/core.c):
- A watchpoint is installed for the 4 bytes at
0xffff888104b4116c.
- With
CONFIG_KCSAN_INTERRUPT_WATCHER=y enabled, interrupt_watcher is true; therefore, local interrupts are not disabled, and preemption remains enabled.
- The task executes
delay_access(), looping in udelay(kcsan_udelay_task) to artificially widen the race window.
-
Concurrent Access and Watchpoint Trigger:
- While
task 3283 is delaying inside udelay(), an asynchronous event (e.g., preemption via preempt_schedule_irq() entering __schedule(), or a tracing/PSI hook such as psi_task_switch()) occurs on CPU 1.
- Because
in_task() remains true while current is still task 3283 during schedule preemption or task-context hooks, KCSAN records the reader identity as task 3283 on cpu 1.
- The reader inspects
task_struct::flags (a plain 4-byte read), triggering kcsan_found_watchpoint().
-
Empty Stack Trace and 0x0 Symbol:
- The reading access is consumed via
kcsan_report_set_info(). Because plain reads are not scoped accesses (KCSAN_ACCESS_SCOPED is not set), ai.ip is initialized to 0.
- When saving the reader's stack trace (
stack_trace_save(..., skipnr=2) in prepare_report_producer()), stack unwinding across the scheduler/interrupt boundary either yields only KCSAN runtime frames or fails to unwind.
get_stack_skipnr() in sanitize_stack_entries() skips all captured frames, resulting in other_frame = 0 (0x0) and 0 frames printed under the read stack.
- Finally,
print_report() formats the bug header as data-race in 0x0 / capable_wrt_inode_uidgid.
Sample crash report:
* Struck through repros no longer work on HEAD.