KCSAN: data-race in _copy_to_iter / fat_set_state (14)

Status: moderation: reported on 2026/10/26 17:43
Subsystems: exfat
Labels: race:benign prio:low
[Documentation on labels]
Reported-by: syzbot+3378b1bef4b92747a197@syzkaller.appspotmail.com
First crash: 1d10h, last: 1d10h
✨ AI-generated root cause summary:
A data race occurs when fat_set_state() writes the 1-byte FAT_STATE_DIRTY flag to the boot sector buffer head during mount (via sb_bread() backed by the block device's page cache) while a userspace process (such as udevd) concurrently reads the raw block device via blkdev_read_iter(). Because the page cache folio is already uptodate, filemap_read() copies the sector to userspace without locking that serializes against in-place buffer_head modifications. In a production kernel without sanitizers, this is a benign data race where the concurrent reader atomically observes either the old or new mount state byte, causing no memory corruption, leak, or denial of service.
▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 6b4b543fa187:
### Root Cause Analysis #### 1. Mechanism and Involved Entities The KCSAN report detects a data race between an in-kernel metadata write in `fat_set_state()` (`fs/fat/inode.c`) and a concurrent userspace read from the underlying block device via `_copy_to_iter()` (`lib/iov_iter.c`). - **Mount Path (Writer - CPU 0 / Task 8878):** When mounting a FAT filesystem, `vfat_fill_super()` calls `fat_fill_super()` (`fs/fat/inode.c`), which invokes `fat_set_state(sb, 1, 0)` at line 1880 to mark the filesystem as dirty on disk. `fat_set_state()` reads sector 0 using `sb_bread(sb, 0)`. The resulting `struct buffer_head *bh` has its memory backed directly by the block device's page cache (`sb->s_bdev->bd_mapping`). `fat_set_state()` then casts `bh->b_data` to `struct fat_boot_sector *b` and modifies `b->fat32.state` (or `b->fat16.state`): ```c if (is_fat32(sbi)) { if (set) b->fat32.state |= FAT_STATE_DIRTY; ... ``` In FAT32, `b->fat32.state` is a 1-byte (`__u8`) field located at offset `0x41` (65) within the 512-byte boot sector. This write directly touches the page cache folio memory at `0xffff88811c180041`. - **Userspace Read Path (Reader - CPU 1 / Task 3285 `udevd`):** Concurrently, `udevd` probes the newly attached or mounted block device by opening it read-only and issuing a `read()` for the first 512 bytes (sector 0). The read path proceeds through: `ksys_read()` -> `vfs_read()` -> `blkdev_read_iter()` (`block/fops.c`) -> `filemap_read()` (`mm/filemap.c`) -> `copy_folio_to_iter()` -> `_copy_to_iter()`. Because the folio containing sector 0 was already brought into the page cache and marked uptodate by `sb_bread()`, `filemap_read()` does not execute any I/O or take folio locks; it simply copies 512 bytes from the folio starting at `0xffff88811c180000` to user space using `copy_to_user_iter()`. - **Race Condition:** `blkdev_read_iter()` holds `bd_inode->i_rwsem` in shared mode, but filesystem operations updating `buffer_head` metadata through `sb_bread()` do not take `bd_inode->i_rwsem`, nor does `fat_set_state()` hold any buffer lock. Thus, `fat_set_state()` modifies byte `0x41` in place while `_copy_to_iter()` simultaneously reads the 512-byte buffer, triggering the KCSAN report. --- ### Runtime Impact in Production - **Memory Corruption (`MemoryCorruption = false`):** Neither thread performs out-of-bounds access, invalid frees, or pointer corruption. The write is a single-byte store to valid page cache memory, and the read is an in-bounds copy of valid page cache memory to userspace. - **Information Leak (`InfoLeak = "none"`):** No uninitialized kernel memory or kernel pointers are exposed. The read merely copies on-disk filesystem boot sector data that userspace is already authorized to read. - **Denial of Service (`RawDenialOfService = false`):** Single-byte reads and writes are atomic on x86 and modern architectures. The reader (`udevd`) will observe either the clean state (`0x00`) or the dirty state (`0x01`) in the undocumented mount state flag byte of the FAT boot sector. This has no adverse effect on system stability, causes no deadlock, panic, or resource leak, and is completely benign.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
915594ff assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ✅ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KCSAN: data-race in _copy_to_iter / fat_set_state (14) 2026/10/28 01:47 2026/10/28 01:47 2026/10/28 02:29 96923c60
cebeb981 assessment-kcsan Benign: ✅ ❓ KCSAN: data-race in _copy_to_iter / fat_set_state (14) 2026/10/26 17:41 2026/10/26 17:41 2026/10/26 18:35 168cb7a2
▶ ▼ Similar bugs (13)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (6) exfat 6 4 1103d 1125d 0/29 auto-obsoleted due to no activity on 2023/11/24 07:27
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (5) exfat 6 1 1169d 1169d 0/29 auto-obsoleted due to no activity on 2023/09/19 09:04
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (13) prio:low exfat 6 17 84d 349d 0/29 auto-obsoleted due to no activity on 2026/09/29 19:40
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (4) exfat 6 1 1226d 1226d 0/29 auto-obsoleted due to no activity on 2023/07/24 15:00
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (12) exfat 6 2 476d 479d 0/29 auto-obsoleted due to no activity on 2025/09/03 02:03
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (11) exfat 6 1 618d 618d 0/29 auto-obsoleted due to no activity on 2025/04/13 16:36
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (9) exfat 6 1 765d 765d 0/29 auto-obsoleted due to no activity on 2024/10/27 23:03
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (7) exfat 6 6 971d 1030d 0/29 auto-obsoleted due to no activity on 2024/04/05 03:03
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (10) exfat 6 2 679d 705d 0/29 auto-obsoleted due to no activity on 2025/02/11 10:54
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (8) exfat 6 2 843d 876d 0/29 auto-obsoleted due to no activity on 2024/08/11 01:41
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (3) exfat 6 1 1320d 1320d 0/29 auto-obsoleted due to no activity on 2023/04/29 03:39
upstream KCSAN: data-race in _copy_to_iter / fat_set_state (2) exfat 6 2 1447d 1474d 0/29 auto-obsoleted due to no activity on 2022/12/15 10:49
upstream KCSAN: data-race in _copy_to_iter / fat_set_state exfat 6 1 1546d 1546d 0/29 auto-closed as invalid on 2022/09/08 00:15

Sample crash report:
==================================================================
BUG: KCSAN: data-race in _copy_to_iter / fat_set_state

write to 0xffff88811c180041 of 1 bytes by task 8878 on cpu 0:
 fat_set_state+0x16c/0x1e0 fs/fat/inode.c:-1
 fat_fill_super+0x181f/0x1c60 fs/fat/inode.c:1880
 vfat_fill_super+0x24/0x30 fs/fat/namei_vfat.c:1203
 get_tree_bdev_flags+0x291/0x300 fs/super.c:1883
 get_tree_bdev+0x1f/0x30 fs/super.c:1906
 vfat_get_tree+0x1c/0x30 fs/fat/namei_vfat.c:1208
 vfs_get_tree+0x57/0x1d0 fs/super.c:1943
 fc_mount fs/namespace.c:1282 [inline]
 do_new_mount_fc fs/namespace.c:3910 [inline]
 do_new_mount+0x288/0x730 fs/namespace.c:3986
 path_mount+0x4ad/0xb90 fs/namespace.c:4337
 do_mount fs/namespace.c:4350 [inline]
 __do_sys_mount fs/namespace.c:4565 [inline]
 __se_sys_mount+0x28c/0x2e0 fs/namespace.c:4542
 __x64_sys_mount+0x67/0x80 fs/namespace.c:4542
 x64_sys_call+0xc3b/0x2550 arch/x86/include/generated/asm/syscalls_64.h:166
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x112/0x360 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

read to 0xffff88811c180000 of 512 bytes by task 3285 on cpu 1:
 instrument_copy_to_user include/linux/instrumented.h:130 [inline]
 copy_to_user_iter lib/iov_iter.c:24 [inline]
 iterate_ubuf include/linux/iov_iter.h:30 [inline]
 iterate_and_advance2 include/linux/iov_iter.h:302 [inline]
 iterate_and_advance include/linux/iov_iter.h:330 [inline]
 _copy_to_iter+0x130/0xea0 lib/iov_iter.c:197
 copy_page_to_iter+0x174/0x210 lib/iov_iter.c:374
 copy_folio_to_iter include/linux/uio.h:204 [inline]
 filemap_read+0x3f8/0xad0 mm/filemap.c:2893
 blkdev_read_iter+0x27f/0x350 block/fops.c:889
 new_sync_read fs/read_write.c:493 [inline]
 vfs_read+0x699/0x7c0 fs/read_write.c:574
 ksys_read+0xdc/0x1a0 fs/read_write.c:716
 __do_sys_read fs/read_write.c:725 [inline]
 __se_sys_read fs/read_write.c:723 [inline]
 __x64_sys_read+0x40/0x50 fs/read_write.c:723
 x64_sys_call+0x2135/0x2550 arch/x86/include/generated/asm/syscalls_64.h:1
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x112/0x360 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Reported by Kernel Concurrency Sanitizer on:
CPU: 1 UID: 0 PID: 3285 Comm: udevd Not tainted syzkaller #0 PREEMPT(lazy) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/07/2026
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/10/26 17:41 upstream 6b4b543fa187 168cb7a2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-kcsan-gce KCSAN: data-race in _copy_to_iter / fat_set_state
* Struck through repros no longer work on HEAD.