Re: [PATCH V2] fat: Prevent the race of read/write the FAT32 entry
From: Edward Adam Davis
Date: Mon Aug 18 2025 - 10:20:03 EST
On Tue, 29 Jul 2025 11:06:35 +0100, Al Viro wrote:
syzbot reports data-race in fat32_ent_get/fat32_ent_put.
CPU0(Task A) CPU1(Task B)
==== ====
vfs_write
new_sync_write
generic_file_write_iter
fat_write_begin
block_write_begin
fat_get_block vfs_statfs
fat_add_cluster statfs_by_dentry
fat_chain_add fat_statfs
fat_ent_write fat_count_free_clusters
fat32_ent_put fat32_ent_get
In fat_add_cluster(), fat_alloc_clusters() retrieves an free
cluster and marks the entry with a value of FAT_ENT_EOF, protected
by lock_fat(). There is no lock protection in fat_chain_add().
When fat_ent_write() writes the last entry to new_dclus, this has
no effect on fat_count_free_clusters() in the statfs operation.
The last entry is not FAT_ENT_FREE before or after the write.
Therefore, the race condition reported here is invalid.
BR,
Edward