syzbot
KCSAN: data-race in alloc_empty_file / percpu_counter_add_batch (2)
Status:
moderation: reported on 2026/11/19 00:05
Subsystems:
fs
Labels:
prio:high
race:benign
[Documentation on labels]
Reported-by: syzbot+9822bf047405e317be17@syzkaller.appspotmail.com
First crash: 1d10h, last: 15h53m
✨ AI-generated root cause summary:
A KCSAN data race occurs between a lockless read in percpu_counter_read_positive() and an in-lock update in percpu_counter_add_batch(). In alloc_empty_file(), get_nr_files() calls percpu_counter_read_positive() to read fbc->count locklessly via READ_ONCE(fbc->count), while a concurrent alloc_empty_file() updates fbc->count via plain arithmetic under raw_spin_lock in percpu_counter_add_batch(). Because the read lacks a data_race() annotation to signal that a concurrent plain write under lock is intentional, KCSAN detects the concurrent unmarked write and flags a data race.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
1. Functions, Structs, and Fields Involved
- Functions:
- Data Structures and Fields:
struct percpu_counter: global instance nr_files (fs/file_table.c)
struct percpu_counter::count (s64 fbc->count)
2. Triggering Mechanism and Race Lifecycle
-
Reader Path:
-
Writer Path:
-
Inconsistency / KCSAN Report:
- Under the Linux Kernel Memory Model and KCSAN rules, when an unmarked write (plain access) races with a marked read (
READ_ONCE), KCSAN treats it as a data race because the writer is not marked with WRITE_ONCE() or data_race().
- In
percpu_counter, lock-protected updates intentionally remain plain accesses so that inadvertent lockless writes can still be detected. Therefore, intentional lockless readers (such as in __percpu_counter_limited_add()) are expected to be annotated using data_race(READ_ONCE(fbc->count)).
- Because
percpu_counter_read_positive() in include/linux/percpu_counter.h uses READ_ONCE(fbc->count) without data_race(...), KCSAN detects the concurrent unmarked write from percpu_counter_add_batch() and flags a data race.
Sample crash report:
* Struck through repros no longer work on HEAD.