syzbot
KCSAN: data-race in capable_wrt_inode_uidgid / posixtimer_send_sigqueue
Status:
moderation: reported on 2026/11/17 15:54
Subsystems:
kernel
Labels:
prio:low
race:benign
[Documentation on labels]
Reported-by: syzbot+642b44a2c031c8743f73@syzkaller.appspotmail.com
First crash: 14h01m, last: 5h13m
✨ 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 data race is flagged by KCSAN on current->flags (an unsigned int at offset 0x2c of struct task_struct) between task context and hardirq context on the same CPU. In task context during a setxattr syscall, ns_capable_common() (kernel/capability.c:343) executes an unmarked read-modify-write (current->flags |= PF_SUPERPRIV) with interrupts enabled, which is standard practice for task-private flags. Concurrently, a POSIX interval timer expiry interrupts the CPU in posix_timer_fn(), calling posixtimer_send_sigqueue() -> posixtimer_get_target() (kernel/signal.c:2027), which performs an unmarked, lockless read !(current->flags & PF_EXITING) prior to acquiring sighand->siglock. Because the hardirq read lacks READ_ONCE() or data_race() annotation to pair with the plain compound assignment in task context, KCSAN detects a data race under the Linux Kernel Memory Model.
▶
▼
✨ Full AI root cause analysis
Technical Explanation and Root Cause Analysis
1. Functions, Structs, Fields, and Files Involved
2. Triggering Mechanism and Race Condition
-
Task Context Read-Modify-Write:
In kernel/capability.c:343, when a capability check succeeds, ns_capable_common() performs a plain compound assignment:
capable = security_capable(current_cred(), ns, cap, opts);
if (capable == 0) {
current->flags |= PF_SUPERPRIV;
return true;
}
Per Linux task lifecycle rules documented in include/linux/sched.h:1839-1848, current->flags is task-private memory written only by the task itself. These updates use standard plain C bitwise operations (|=, &=) without disabling local interrupts.
-
Hardirq Context Interruption and Plain Read:
While task 4219 is executing ns_capable_common() on CPU 0, a local APIC timer interrupt occurs on CPU 0. In hardirq context, hrtimer_interrupt() processes an expiring POSIX interval timer belonging to the process running on CPU 0.
posix_timer_fn() invokes posixtimer_send_sigqueue(), which 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;
}
When tmr->it_pid_type != PIDTYPE_PID (process-wide timer) and same_thread_group(t, current) holds, posixtimer_get_target() performs a lockless read of current->flags & PF_EXITING to determine whether current can be chosen as the target thread to deliver the timer signal (avoiding waking up an idle thread).
-
Violation and Sanitizer Detection:
Because posixtimer_get_target() executes an unmarked load (current->flags) in interrupt context concurrently with an unmarked store (current->flags |= PF_SUPERPRIV) in interrupted thread context on the same CPU, KCSAN detects an unsynchronized read-write concurrency under the Linux Kernel Memory Model (LKMM) and emits the data-race report.
3. Invariant Assessment
posixtimer_get_target() is merely a lockless target selection heuristic. After calling posixtimer_get_target(tmr), posixtimer_send_sigqueue() proceeds to acquire lock_task_sighand(t, &flags) (holding t->sighand->siglock) and calls task_can_queue_signal(t, tmr->it_pid_type) under lock.
PF_EXITING is written only once during task termination in exit_signals() (kernel/signal.c:3211) under tsk->sighand->siglock with interrupts disabled.
- Because
posixtimer_get_target() reads current->flags without writing to it, no task-context update to current->flags can be lost, making the race benign in production kernels. Annotating the read with READ_ONCE() or data_race() resolves the KCSAN warning.
Sample crash report:
* Struck through repros no longer work on HEAD.