syzbot


KASAN: use-after-free Read in release_metapage (2)

Status: upstream: reported on 2024/11/12 12:14
Reported-by: syzbot+4b6494f0e706e8a1fe4d@syzkaller.appspotmail.com
First crash: 21d, last: 14d
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in release_metapage jfs C error done 1094 1h52m 701d 0/28 upstream: reported C repro on 2023/01/02 10:00
linux-6.1 KASAN: use-after-free Read in release_metapage 1 440d 440d 0/3 auto-obsoleted due to no activity on 2023/12/29 12:55
linux-4.14 KASAN: use-after-free Read in release_metapage 1 755d 755d 0/1 auto-obsoleted due to no activity on 2023/03/09 00:53
linux-6.1 KASAN: use-after-free Read in release_metapage (2) 1 215d 215d 0/3 auto-obsoleted due to no activity on 2024/08/10 05:44
linux-5.15 KASAN: use-after-free Read in release_metapage 1 418d 418d 0/3 auto-obsoleted due to no activity on 2024/01/20 09:39
linux-6.1 KASAN: use-after-free Read in release_metapage (3) 1 21d 21d 0/3 upstream: reported on 2024/11/12 12:24
linux-5.15 BUG: spinlock bad magic in release_metapage origin:upstream C 34 1d22h 79d 0/3 upstream: reported C repro on 2024/09/15 11:43

Sample crash report:
ERROR: (device loop1): release_metapage: write_one_page() failed
ERROR: (device loop1): remounting filesystem as read-only
==================================================================
BUG: KASAN: use-after-free in drop_metapage fs/jfs/jfs_metapage.c:222 [inline]
BUG: KASAN: use-after-free in release_metapage+0x829/0xe00 fs/jfs/jfs_metapage.c:758
Read of size 8 at addr ffff888061c41ad0 by task syz.1.406/6485

CPU: 0 PID: 6485 Comm: syz.1.406 Not tainted 5.15.171-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 drop_metapage fs/jfs/jfs_metapage.c:222 [inline]
 release_metapage+0x829/0xe00 fs/jfs/jfs_metapage.c:758
 write_metapage fs/jfs/jfs_metapage.h:75 [inline]
 flush_metapage fs/jfs/jfs_metapage.h:81 [inline]
 ea_write+0x69f/0xe50 fs/jfs/xattr.c:280
 ea_put fs/jfs/xattr.c:621 [inline]
 __jfs_setxattr+0x8a5/0x11d0 fs/jfs/xattr.c:787
 __jfs_xattr_set+0xf5/0x180 fs/jfs/xattr.c:936
 __vfs_setxattr+0x3e7/0x420 fs/xattr.c:182
 __vfs_setxattr_noperm+0x12a/0x5e0 fs/xattr.c:216
 vfs_setxattr+0x21d/0x420 fs/xattr.c:303
 do_setxattr fs/xattr.c:588 [inline]
 setxattr+0x27e/0x2e0 fs/xattr.c:611
 path_setxattr+0x1bc/0x2a0 fs/xattr.c:630
 __do_sys_lsetxattr fs/xattr.c:653 [inline]
 __se_sys_lsetxattr fs/xattr.c:649 [inline]
 __x64_sys_lsetxattr+0xb4/0xd0 fs/xattr.c:649
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7fb0a7176719
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb0a55ac038 EFLAGS: 00000246 ORIG_RAX: 00000000000000bd
RAX: ffffffffffffffda RBX: 00007fb0a732e130 RCX: 00007fb0a7176719
RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000020000040
RBP: 00007fb0a71e9616 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000001 R14: 00007fb0a732e130 R15: 00007ffdbd7d83f8
 </TASK>

Allocated by task 6485:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 __kasan_slab_alloc+0x8e/0xc0 mm/kasan/common.c:467
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 mempool_alloc+0x17f/0x590 mm/mempool.c:393
 alloc_metapage fs/jfs/jfs_metapage.c:175 [inline]
 __get_metapage+0x672/0x1070 fs/jfs/jfs_metapage.c:652
 ea_write+0x633/0xe50 fs/jfs/xattr.c:256
 ea_put fs/jfs/xattr.c:621 [inline]
 __jfs_setxattr+0x8a5/0x11d0 fs/jfs/xattr.c:787
 __jfs_xattr_set+0xf5/0x180 fs/jfs/xattr.c:936
 __vfs_setxattr+0x3e7/0x420 fs/xattr.c:182
 __vfs_setxattr_noperm+0x12a/0x5e0 fs/xattr.c:216
 vfs_setxattr+0x21d/0x420 fs/xattr.c:303
 do_setxattr fs/xattr.c:588 [inline]
 setxattr+0x27e/0x2e0 fs/xattr.c:611
 path_setxattr+0x1bc/0x2a0 fs/xattr.c:630
 __do_sys_lsetxattr fs/xattr.c:653 [inline]
 __se_sys_lsetxattr fs/xattr.c:649 [inline]
 __x64_sys_lsetxattr+0xb4/0xd0 fs/xattr.c:649
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 6484:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kmem_cache_free+0x91/0x1f0 mm/slub.c:3515
 free_metapage fs/jfs/jfs_metapage.c:190 [inline]
 metapage_releasepage+0x5cb/0x730 fs/jfs/jfs_metapage.c:552
 do_invalidatepage mm/truncate.c:157 [inline]
 truncate_cleanup_page+0x179/0x440 mm/truncate.c:176
 truncate_inode_pages_range+0x2e7/0x1290 mm/truncate.c:325
 jfs_remount+0x360/0x6a0 fs/jfs/super.c:456
 reconfigure_super+0x43a/0x870 fs/super.c:938
 vfs_fsconfig_locked fs/fsopen.c:254 [inline]
 __do_sys_fsconfig fs/fsopen.c:439 [inline]
 __se_sys_fsconfig+0x98b/0xec0 fs/fsopen.c:314
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888061c41aa8
 which belongs to the cache jfs_mp of size 184
The buggy address is located 40 bytes inside of
 184-byte region [ffff888061c41aa8, ffff888061c41b60)
The buggy address belongs to the page:
page:ffffea0001871040 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x61c41
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 0000000100000001 ffff888146b67780
raw: 0000000000000000 0000000080100010 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 0x192800(GFP_NOWAIT|__GFP_NOWARN|__GFP_NORETRY|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4716, ts 113152704119, free_ts 113131609587
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5464
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0x18e/0x280 mm/slub.c:3233
 mempool_alloc+0x17f/0x590 mm/mempool.c:393
 alloc_metapage fs/jfs/jfs_metapage.c:175 [inline]
 __get_metapage+0x672/0x1070 fs/jfs/jfs_metapage.c:652
 diIAGRead fs/jfs/jfs_imap.c:2672 [inline]
 diRead+0x211/0xbb0 fs/jfs/jfs_imap.c:316
 jfs_iget+0x88/0x3b0 fs/jfs/inode.c:35
 jfs_fill_super+0x826/0xc70 fs/jfs/super.c:585
 mount_bdev+0x2c9/0x3f0 fs/super.c:1400
 legacy_get_tree+0xeb/0x180 fs/fs_context.c:611
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x2ba/0xb40 fs/namespace.c:3012
 do_mount fs/namespace.c:3355 [inline]
 __do_sys_mount fs/namespace.c:3563 [inline]
 __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3540
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 shmem_alloc_inode+0x16/0x30 mm/shmem.c:3794
 alloc_inode fs/inode.c:236 [inline]
 new_inode_pseudo+0x60/0x210 fs/inode.c:976
 new_inode+0x25/0x1d0 fs/inode.c:1005
 shmem_get_inode+0x327/0xad0 mm/shmem.c:2295
 shmem_mknod+0x54/0x1b0 mm/shmem.c:2855
 lookup_open fs/namei.c:3462 [inline]
 open_last_lookups fs/namei.c:3532 [inline]
 path_openat+0x130a/0x2f20 fs/namei.c:3739
 do_filp_open+0x21c/0x460 fs/namei.c:3769
 do_sys_openat2+0x13b/0x4f0 fs/open.c:1253

Memory state around the buggy address:
 ffff888061c41980: fc fc fc fc fc fc fb fb fb fb fb fb fb fb fb fb
 ffff888061c41a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
>ffff888061c41a80: fc fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff888061c41b00: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff888061c41b80: fc fc fc fc fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/12 12:13 linux-5.15.y 3c17fc483905 75bb1b32 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in release_metapage
2024/11/19 10:57 linux-5.15.y 0a51d2d4527b 571351cb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in release_metapage
* Struck through repros no longer work on HEAD.