syzbot


KASAN: slab-use-after-free Read in gfs2_invalidate_folio

Status: upstream: reported on 2025/08/04 00:39
Reported-by: syzbot+3e3a6a1d24303b7797e2@syzkaller.appspotmail.com
First crash: 25d, last: 24d
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in gfs2_invalidate_folio gfs2 19 C error 58 3d16h 504d 0/29 upstream: reported C repro on 2024/04/11 16:17
linux-6.1 KASAN: use-after-free Read in gfs2_invalidate_folio 19 5 10d 104d 0/3 upstream: reported on 2025/05/16 19:32

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in list_empty include/linux/list.h:373 [inline]
BUG: KASAN: slab-use-after-free in gfs2_discard fs/gfs2/aops.c:622 [inline]
BUG: KASAN: slab-use-after-free in gfs2_invalidate_folio+0x463/0xa50 fs/gfs2/aops.c:660
Read of size 8 at addr ffff8880266f51d8 by task syz-executor/5786

CPU: 1 PID: 5786 Comm: syz-executor Not tainted 6.6.101-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x16c/0x230 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:364 [inline]
 print_report+0xac/0x220 mm/kasan/report.c:468
 kasan_report+0x117/0x150 mm/kasan/report.c:581
 list_empty include/linux/list.h:373 [inline]
 gfs2_discard fs/gfs2/aops.c:622 [inline]
 gfs2_invalidate_folio+0x463/0xa50 fs/gfs2/aops.c:660
 folio_invalidate mm/truncate.c:158 [inline]
 truncate_cleanup_folio+0x220/0x5c0 mm/truncate.c:178
 truncate_inode_pages_range+0x229/0xf00 mm/truncate.c:367
 gfs2_evict_inode+0x3d8/0x1220 fs/gfs2/super.c:1537
 evict+0x486/0x870 fs/inode.c:705
 gfs2_evict_inodes fs/gfs2/ops_fstype.c:1770 [inline]
 gfs2_kill_sb+0x230/0x320 fs/gfs2/ops_fstype.c:1796
 deactivate_locked_super+0x97/0x100 fs/super.c:481
 cleanup_mnt+0x429/0x4c0 fs/namespace.c:1250
 task_work_run+0x1ce/0x250 kernel/task_work.c:239
 exit_task_work include/linux/task_work.h:43 [inline]
 do_exit+0x90b/0x23c0 kernel/exit.c:883
 do_group_exit+0x21b/0x2d0 kernel/exit.c:1024
 __do_sys_exit_group kernel/exit.c:1035 [inline]
 __se_sys_exit_group kernel/exit.c:1033 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1033
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f53b4f8eb69
Code: Unable to access opcode bytes at 0x7f53b4f8eb3f.
RSP: 002b:00007ffe2e147828 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007f53b5011c02 RCX: 00007f53b4f8eb69
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000001
RBP: 0000000000000005 R08: 00007ffe2e1455c7 R09: 00007ffe2e148a80
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffe2e148a80
R13: 00007f53b5011bdd R14: 0000000000019093 R15: 00007ffe2e148ac0
 </TASK>

Allocated by task 6005:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4e/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook+0x6e/0x4d0 mm/slab.h:767
 slab_alloc_node mm/slub.c:3485 [inline]
 slab_alloc mm/slub.c:3493 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3500 [inline]
 kmem_cache_alloc+0x11e/0x2e0 mm/slub.c:3509
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 gfs2_alloc_bufdata fs/gfs2/trans.c:168 [inline]
 gfs2_trans_add_data+0x1ff/0x620 fs/gfs2/trans.c:209
 gfs2_trans_add_databufs+0x15a/0x1c0 fs/gfs2/aops.c:57
 gfs2_iomap_put_folio+0x1be/0x400 fs/gfs2/bmap.c:988
 iomap_write_end+0x631/0xb90 fs/iomap/buffered-io.c:860
 iomap_write_iter fs/iomap/buffered-io.c:926 [inline]
 iomap_file_buffered_write+0x710/0xd10 fs/iomap/buffered-io.c:975
 gfs2_file_buffered_write+0x4bd/0x820 fs/gfs2/file.c:1060
 gfs2_file_write_iter+0x427/0xe10 fs/gfs2/file.c:1158
 call_write_iter include/linux/fs.h:2018 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x43b/0x940 fs/read_write.c:584
 ksys_write+0x147/0x250 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 6005:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4e/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2e/0x50 mm/kasan/generic.c:522
 ____kasan_slab_free+0x126/0x1e0 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:164 [inline]
 slab_free_hook mm/slub.c:1806 [inline]
 slab_free_freelist_hook+0x130/0x1b0 mm/slub.c:1832
 slab_free mm/slub.c:3816 [inline]
 kmem_cache_free+0xf8/0x280 mm/slub.c:3838
 trans_drain fs/gfs2/log.c:1022 [inline]
 gfs2_log_flush+0x18d1/0x24b0 fs/gfs2/log.c:1162
 gfs2_jdata_writepages+0xf9/0x150 fs/gfs2/aops.c:398
 do_writepages+0x3a2/0x600 mm/page-writeback.c:2575
 filemap_fdatawrite_wbc+0x122/0x180 mm/filemap.c:390
 __filemap_fdatawrite_range mm/filemap.c:423 [inline]
 filemap_fdatawrite_range+0xce/0x120 mm/filemap.c:441
 gfs2_fsync+0xdf/0x350 fs/gfs2/file.c:751
 generic_write_sync include/linux/fs.h:2651 [inline]
 gfs2_file_write_iter+0xc72/0xe10 fs/gfs2/file.c:1160
 do_iter_readv_writev fs/read_write.c:-1 [inline]
 do_iter_write+0x79a/0xc70 fs/read_write.c:860
 vfs_writev fs/read_write.c:933 [inline]
 do_writev+0x252/0x410 fs/read_write.c:976
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff8880266f51c0
 which belongs to the cache gfs2_bufdata of size 80
The buggy address is located 24 bytes inside of
 freed 80-byte region [ffff8880266f51c0, ffff8880266f5210)

The buggy address belongs to the physical page:
page:ffffea000099bd40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x266f5
flags: 0xfff00000000800(slab|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000800 ffff888019fc0780 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080240024 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_HARDWALL), pid 6005, tgid 6004 (syz.0.18), ts 102459781295, free_ts 102445633779
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x1cd/0x210 mm/page_alloc.c:1554
 prep_new_page mm/page_alloc.c:1561 [inline]
 get_page_from_freelist+0x195c/0x19f0 mm/page_alloc.c:3191
 __alloc_pages+0x1e3/0x460 mm/page_alloc.c:4457
 alloc_slab_page+0x5d/0x170 mm/slub.c:1876
 allocate_slab mm/slub.c:2023 [inline]
 new_slab+0x87/0x2e0 mm/slub.c:2076
 ___slab_alloc+0xc6d/0x12f0 mm/slub.c:3230
 __slab_alloc mm/slub.c:3329 [inline]
 __slab_alloc_node mm/slub.c:3382 [inline]
 slab_alloc_node mm/slub.c:3475 [inline]
 slab_alloc mm/slub.c:3493 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3500 [inline]
 kmem_cache_alloc+0x1b7/0x2e0 mm/slub.c:3509
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 gfs2_alloc_bufdata fs/gfs2/trans.c:168 [inline]
 gfs2_trans_add_meta+0x30c/0xc20 fs/gfs2/trans.c:251
 do_gfs2_set_flags fs/gfs2/file.c:265 [inline]
 gfs2_fileattr_set+0x77d/0x9b0 fs/gfs2/file.c:311
 vfs_fileattr_set+0x846/0xaf0 fs/ioctl.c:697
 ioctl_setflags fs/ioctl.c:729 [inline]
 do_vfs_ioctl+0x135a/0x1bb0 fs/ioctl.c:840
 __do_sys_ioctl fs/ioctl.c:869 [inline]
 __se_sys_ioctl+0x83/0x170 fs/ioctl.c:857
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1154 [inline]
 free_unref_page_prepare+0x7ce/0x8e0 mm/page_alloc.c:2336
 free_unref_page+0x32/0x2e0 mm/page_alloc.c:2429
 __slab_free+0x35e/0x410 mm/slub.c:3722
 qlink_free mm/kasan/quarantine.c:166 [inline]
 qlist_free_all+0x75/0xe0 mm/kasan/quarantine.c:185
 kasan_quarantine_reduce+0x143/0x160 mm/kasan/quarantine.c:292
 __kasan_slab_alloc+0x22/0x80 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:188 [inline]
 slab_post_alloc_hook+0x6e/0x4d0 mm/slab.h:767
 slab_alloc_node mm/slub.c:3485 [inline]
 __kmem_cache_alloc_node+0x13e/0x260 mm/slub.c:3524
 __do_kmalloc_node mm/slab_common.c:1006 [inline]
 __kmalloc+0xa4/0x240 mm/slab_common.c:1020
 kmalloc include/linux/slab.h:604 [inline]
 tomoyo_realpath_from_path+0xe3/0x5d0 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x1c3/0x3c0 security/tomoyo/file.c:771
 security_file_open+0x62/0xa0 security/security.c:2854
 do_dentry_open+0x380/0x1500 fs/open.c:916
 do_open fs/namei.c:3632 [inline]
 path_openat+0x274b/0x3190 fs/namei.c:3789
 do_filp_open+0x1c5/0x3d0 fs/namei.c:3816
 do_sys_openat2+0x12c/0x1c0 fs/open.c:1419

Memory state around the buggy address:
 ffff8880266f5080: fb fb fb fb fb fb fb fb fc fc fc fc fa fb fb fb
 ffff8880266f5100: fb fb fb fb fb fb fc fc fc fc fa fb fb fb fb fb
>ffff8880266f5180: fb fb fb fb fc fc fc fc fa fb fb fb fb fb fb fb
                                                    ^
 ffff8880266f5200: fb fb fc fc fc fc fa fb fb fb fb fb fb fb fb fb
 ffff8880266f5280: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fc fc
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/08/04 00:41 linux-6.6.y 3a8ababb8b6a 7368264b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in gfs2_invalidate_folio
2025/08/04 00:38 linux-6.6.y 3a8ababb8b6a 7368264b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan KASAN: slab-use-after-free Read in gfs2_invalidate_folio
* Struck through repros no longer work on HEAD.