syzbot
KCSAN: data-race in has_bh_in_lru / invalidate_bh_lrus_cpu (18)
Status:
moderation: reported on 2026/11/19 00:08
Subsystems:
ext4
Labels:
prio:low
race:benign
[Documentation on labels]
Reported-by: syzbot+785951b7fab6dfb99cab@syzkaller.appspotmail.com
First crash: 1d09h, last: 7h34m
✨ AI-generated root cause summary:
A data race occurs in fs/buffer.c between has_bh_in_lru() and invalidate_bh_lrus_cpu() due to unsynchronized concurrent access to the per-CPU buffer head LRU array, bh_lrus. While task 4160 on CPU 0 executes invalidate_bh_lrus() via on_each_cpu_cond(), it invokes has_bh_in_lru() to inspect remote CPUs' bh_lrus.bhs[] entries using plain reads without locks or atomic read annotations. Concurrently, task 3369 on CPU 1 executes invalidate_bh_lrus_cpu() via workqueue folio draining and calls __invalidate_bh_lrus(), which clears bh_lrus.bhs[] to NULL using plain writes while holding only its local CPU's bh_lru_lock(). Because neither access uses atomic primitives (such as READ_ONCE/WRITE_ONCE) or data_race() annotations, KCSAN flags the concurrent load and store as a data race.
▶
▼
✨ Full AI root cause analysis
Root Cause Analysis
Involved Functions, Structs, Fields, and Files
Technical Breakdown & Mechanism
-
Per-CPU LRU Cache and Synchronization Rules:
- In
fs/buffer.c, the buffer cache maintains a per-CPU LRU structure defined by struct bh_lru and instantiated as bh_lrus. Each CPU caches up to BH_LRU_SIZE (16) buffer_head pointers in bhs[].
- Under standard operations (
bh_lru_install, lookup_bh_lru, and invalidate_bh_lrus_cpu), each CPU accesses its own per-CPU instance of bh_lrus protected by bh_lru_lock(), which expands to local_irq_disable() on SMP configurations. This local interrupt disable only synchronizes local execution against interrupts or preemption on the same CPU, providing no cross-CPU mutual exclusion.
-
The Read Path (has_bh_in_lru):
-
The Concurrent Write Path (__invalidate_bh_lrus via invalidate_bh_lrus_cpu):
-
The Race Condition:
- While CPU 1 executes
b->bhs[i] = NULL; at fs/buffer.c:1430, CPU 0 concurrently evaluates if (b->bhs[i]) at fs/buffer.c:1452 for CPU 1's per-CPU array.
- Because both the read and write accesses are unannotated plain C memory accesses to the same memory location (
0xffff888237d27d00), KCSAN flags this as a data race between has_bh_in_lru and invalidate_bh_lrus_cpu.
Sample crash report:
* Struck through repros no longer work on HEAD.