syzbot
KCSAN: data-race in capable / posixtimer_send_sigqueue
Status:
moderation: reported on 2026/11/18 05:19
Subsystems:
kernel
Labels:
prio:low
race:benign
[Documentation on labels]
Reported-by: syzbot+ed63626b2df76b1c6ca3@syzkaller.appspotmail.com
First crash: 1d18h, last: 1d09h
✨ AI-generated root cause summary:
A data race was detected by KCSAN between task-context flag modification and an interrupt-context check in POSIX timer signal delivery. In kernel/capability.c:ns_capable_common(), a running task updates its per-task flags via an unmarked read-modify-write (current->flags |= PF_SUPERPRIV). When interrupted on the same CPU by a local APIC timer interrupt, posixtimer_get_target() in kernel/signal.c performs an unmarked plain read of current->flags to verify !(current->flags & PF_EXITING) before redirecting a process-wide timer signal to current. Because current->flags is routinely updated in task context without disabling local interrupts, the unannotated interrupt read races with the interrupted task's update.
▶
▼
✨ Full AI root cause analysis
Technical Mechanism and Root Cause
1. Functions, Structs, and Fields Involved
struct task_struct::flags (include/linux/sched.h): An unsigned int field containing per-task process flags (PF_*). By design, only current writes to its own flags, but writes are frequently performed with plain C read-modify-write operations (current->flags |= ...) without disabling local interrupts.
ns_capable_common() (kernel/capability.c:343): Updates current->flags |= PF_SUPERPRIV; when a capability check succeeds.
posixtimer_get_target() (kernel/signal.c:2022-2030): Selects the target task for delivering a POSIX timer signal. For process-targeted timers (PIDTYPE_TGID), it attempts to target current if current belongs to the same thread group, provided !(current->flags & PF_EXITING).
posixtimer_send_sigqueue() (kernel/signal.c:2046): Invoked from POSIX timer expiry callback posix_timer_fn() via posix_timer_queue_signal() in hardirq context (hrtimer_interrupt).
2. Triggering Flow and Data-Race Mechanism
-
Task-Context Flag Modification:
Task 12250 on CPU 0 invokes a system call (__do_sys_acct) that executes capable() -> ns_capable() -> ns_capable_common(). Upon verifying the capability, line 343 executes:
current->flags |= PF_SUPERPRIV;
This is an unmarked 4-byte read-modify-write on current->flags executed with local IRQs enabled.
-
Hardirq Interruption on the Same CPU:
While task 12250 is running on CPU 0, a local APIC timer interrupt occurs on CPU 0 (sysvec_apic_timer_interrupt). The hardirq handler runs hrtimer_interrupt() -> __hrtimer_run_queues() -> posix_timer_fn() -> posix_timer_queue_signal() -> posixtimer_send_sigqueue().
-
Interrupt-Context Read:
Inside posixtimer_send_sigqueue(), posixtimer_get_target() is called under rcu_read_lock():
static inline struct task_struct *posixtimer_get_target(struct k_itimer *tmr)
{
struct task_struct *t = pid_task(tmr->it_pid, tmr->it_pid_type);
if (t && tmr->it_pid_type != PIDTYPE_PID &&
same_thread_group(t, current) && !(current->flags & PF_EXITING))
t = current;
return t;
}
In interrupt context, current points to the interrupted task on CPU 0 (task 12250). At line 2027, posixtimer_get_target() performs a plain, unmarked 4-byte read of current->flags to check bit PF_EXITING.
-
KCSAN Detection:
Because current->flags was being modified in task context without IRQs disabled, KCSAN detected a concurrent/reentrant read vs. read-modify-write data race on the same 4-byte memory location (¤t->flags).
3. Invariants and Fix
- Per
include/linux/sched.h, task_struct::flags is owned by current. While process context updates various flags without disabling interrupts, hardirq context only reads current->flags and never writes to it.
- Because
PF_EXITING (bit 0x4) is set only once in exit_signals() under &tsk->sighand->siglock with IRQs disabled and is never cleared, reading current->flags in posixtimer_get_target() is functionally safe against word tearing and bit corruption on aligned 32-bit words, but violates the C memory model and KCSAN rules regarding unmarked concurrent accesses.
- To silence the warning, reading
current->flags in posixtimer_get_target() should be annotated with READ_ONCE() or data_race().
Sample crash report:
* Struck through repros no longer work on HEAD.