syzbot
KCSAN: data-race in do_exit / get_signal (3)
Status:
moderation: reported on 2026/11/20 00:08
Subsystems:
kernel
Labels:
race:benign
prio:low
[Documentation on labels]
Reported-by: syzbot+3c7d70c3bcdea393cc30@syzkaller.appspotmail.com
First crash: 2d18h, last: 11h08m
✨ AI-generated root cause summary:
A KCSAN data race occurs on task_struct::flags between a thread setting PF_SIGNALED in get_signal() (current->flags |= PF_SIGNALED after dropping sighand->siglock) and an exiting sibling thread checking !(t->flags & PF_EXITING) in find_alive_thread() while holding tasklist_lock. Neither side uses READ_ONCE()/WRITE_ONCE() or shares a common lock for t->flags updates outside exit_signals(), allowing concurrent unmarked 4-byte accesses to the same unsigned int flags field. The race is benign in practice because current is the sole writer to t->flags and tasklist_lock serializes exit_notify().
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
The KCSAN report identifies a data race on the 4-byte flags field (unsigned int flags at offset 44 in struct task_struct, include/linux/sched.h:858) of task 7741 between two concurrent paths in the same thread group:
-
Read-write side (kernel/signal.c:3084, task 7741):
In get_signal(), after handling a fatal signal and releasing sighand->siglock at line 3077, task 7741 performs an unmarked read-modify-write on its own task_struct::flags:
current->flags |= PF_SIGNALED; // PF_SIGNALED = 0x00000400
Task 7741 then enters do_group_exit() -> do_exit(), setting PF_POSTCOREDUMP (0x00000008 in synchronize_group_exit() at kernel/exit.c:892) and PF_EXITING (0x00000004 in exit_signals() at kernel/signal.c:3211), which explains the observed transition 0x00400140 -> 0x0040054c (0x0000040c) during the KCSAN watchpoint window.
-
Read side (kernel/exit.c:596, task 7739):
Task 7739, an exiting sibling thread in do_exit() -> exit_notify() (kernel/exit.c:748), acquires write_lock_irq(&tasklist_lock) and calls forget_original_parent() -> find_new_reaper() -> find_alive_thread(father):
static struct task_struct *find_alive_thread(struct task_struct *p)
{
struct task_struct *t;
for_each_thread(p, t) {
if (!(t->flags & PF_EXITING))
return t;
}
return NULL;
}
find_alive_thread() reads t->flags directly without READ_ONCE() and without holding t->sighand->siglock.
Trigger & Invariant Details
task_struct::flags is generally updated only by current without locking, except exit_signals() (kernel/signal.c:3210-3211) sets PF_EXITING under tsk->sighand->siglock so signal-delivery paths holding siglock see a consistent PF_EXITING state.
find_alive_thread() holds tasklist_lock rather than sighand->siglock while scanning sibling threads (or subreaper threads), and performs an unmarked read of t->flags.
- Meanwhile,
get_signal() sets PF_SIGNALED on current->flags after dropping sighand->siglock (and without WRITE_ONCE() or tasklist_lock), causing an unmarked concurrent read and read-modify-write on t->flags.
- Functionally,
tasklist_lock still preserves reparenting invariants: exit_signals() sets PF_EXITING before do_exit() reaches exit_notify(), which acquires write_lock_irq(&tasklist_lock). Any sibling t returned by find_alive_thread() while tasklist_lock is held cannot yet have executed exit_notify(), so t will acquire tasklist_lock afterwards and reparent any children assigned to it. To satisfy KCSAN and avoid compiler load/store tearing on cross-thread t->flags inspection, find_alive_thread() should use READ_ONCE(t->flags) (paired with WRITE_ONCE() / atomic or marked updates on current->flags when modifying flags concurrently with external readers).
Sample crash report:
* Struck through repros no longer work on HEAD.