syzbot
KCSAN: data-race in ns_capable_noaudit / posixtimer_send_sigqueue
Status:
moderation: reported on 2026/11/18 00:03
Subsystems:
kernel
Labels:
prio:low
race:benign
[Documentation on labels]
Reported-by: syzbot+82f093f6fc44ab5baeac@syzkaller.appspotmail.com
First crash: 5h04m, last: 5h04m
✨ AI cause bisection: introduced by
(AI job) :
commit d2710c8d938ae6a825a6463158e6e6f31eac792a
Author: Thomas Gleixner <tglx@kernel.org>
Date: Fri Sep 11 09:09:12 2026 +0000
signal: Prevent exec() race
✨ AI-generated root cause summary:
A KCSAN data race occurs between task-context capability checking in ns_capable_common() and hardirq-context POSIX timer signal delivery in posixtimer_get_target(). In task context, ns_capable_common() performs an unmarked non-atomic read-modify-write to update current->flags (current->flags |= PF_SUPERPRIV). When a local timer interrupt fires on the same CPU while the task is in ns_capable_common(), the hardirq handler runs posixtimer_send_sigqueue() -> posixtimer_get_target(), which performs an unsynchronized read of current->flags to check !(current->flags & PF_EXITING). Because neither access uses atomic primitives or annotations (such as READ_ONCE or data_race()), KCSAN flags the concurrent 4-byte read and read-write accesses on task_struct::flags.
▶
▼
✨ Full AI root cause analysis
Technical Explanation of Root Cause
1. Involved Structs, Fields, and Functions
- Target Field:
struct task_struct::flags (unsigned int flags, 4 bytes located at offset 0x2c / 352 bits in task_struct, defined in include/linux/sched.h:858).
- Task-Context Modifier:
- Hardirq-Context Reader:
2. Triggering Mechanism and Detailed Breakdown
-
Task-Context Execution (kernel/capability.c:343):
During syscall execution (such as io_uring_setup), a thread on CPU 0 checks whether it has a specific capability using ns_capable_noaudit(). When the check succeeds, ns_capable_common() records capability usage by modifying current->flags:
capable = security_capable(current_cred(), ns, cap, opts);
if (capable == 0) {
current->flags |= PF_SUPERPRIV;
return true;
}
This operation executes in task context without acquiring locks (which is standard kernel practice because task_struct::flags contains task-local PF_* flags typically modified only by the task itself).
-
Hardirq-Context Interruption (kernel/signal.c:2027):
While CPU 0 is in the middle of executing ns_capable_common() (where KCSAN placed a memory watchpoint on current->flags), a local APIC timer interrupt occurs on CPU 0 with local IRQs enabled. The timer interrupt runs hrtimer_interrupt, which fires an expired POSIX interval timer (posix_timer_fn()).
To queue the timer signal, posixtimer_send_sigqueue() calls posixtimer_get_target(tmr):
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;
}
For process-wide timers (tmr->it_pid_type != PIDTYPE_PID), this optimization prefers delivering the signal to current if current belongs to the same thread group and is not exiting (!(current->flags & PF_EXITING)), avoiding waking up an idle thread. On CPU 0, current is the interrupted task.
-
Data Race Detected by KCSAN:
posixtimer_get_target() reads current->flags without synchronization (such as READ_ONCE() or data_race()), while ns_capable_common() performs an unsynchronized read-modify-write on current->flags. KCSAN flags this access as an unsynchronized data race on the 4-byte address of current->flags.
3. Invariants and Correctness Evaluation
- Benign in Real-World Setups:
- Interrupt handlers execute strictly between discrete machine instructions.
- The interrupt handler only reads
current->flags to check bit PF_EXITING (0x00000004); it does not write to current->flags.
- The interrupted task context updates bit
PF_SUPERPRIV (0x00000100). On naturally aligned 32-bit accesses, reading current->flags from the hardirq cannot tear or corrupt the field, nor can the read clobber or alter the value written by current->flags |= PF_SUPERPRIV.
- The
PF_EXITING flag is set exclusively by current itself within exit_signals() (kernel/signal.c:3211) while holding spin_lock_irq(&tsk->sighand->siglock) with interrupts disabled. Thus, PF_EXITING cannot change asynchronously while in ns_capable_common() or during interrupt handling on the local CPU.
- Immediately following target selection,
posixtimer_send_sigqueue() acquires lock_task_sighand(t, &flags) and explicitly calls task_can_queue_signal(t, tmr->it_pid_type) with sighand->siglock held before queueing the signal.
Sample crash report:
* Struck through repros no longer work on HEAD.