syzbot


KASAN: use-after-free Read in locked_inode_to_wb_and_lock_list

Status: auto-obsoleted due to no activity on 2024/01/06 01:51
Reported-by: syzbot+61e14760930c006d629d@syzkaller.appspotmail.com
First crash: 177d, last: 147d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in wb_get include/linux/backing-dev-defs.h:242 [inline]
BUG: KASAN: use-after-free in locked_inode_to_wb_and_lock_list+0x68/0x2f0 fs/fs-writeback.c:303
Read of size 8 at addr ffff88811cbc1060 by task syz-executor.4/23659

CPU: 1 PID: 23659 Comm: syz-executor.4 Not tainted 5.10.194-syzkaller-00508-ga27512601c2d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:452
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 wb_get include/linux/backing-dev-defs.h:242 [inline]
 locked_inode_to_wb_and_lock_list+0x68/0x2f0 fs/fs-writeback.c:303
 __mark_inode_dirty+0x400/0x9d0 fs/fs-writeback.c:2311
 inc_valid_node_count+0x571/0x9d0 fs/f2fs/f2fs.h:2606
 f2fs_new_node_page+0x241/0x990 fs/f2fs/node.c:1292
 f2fs_get_dnode_of_data+0x6f0/0x1fb0 fs/f2fs/node.c:809
 f2fs_reserve_block+0x53/0x310 fs/f2fs/data.c:1173
 f2fs_get_new_data_page+0x18f/0x8f0 fs/f2fs/data.c:1350
 f2fs_add_regular_entry+0x4c8/0xb10 fs/f2fs/dir.c:752
 f2fs_add_dentry+0x207/0x340 fs/f2fs/dir.c:821
 f2fs_do_add_link+0x29b/0x400 fs/f2fs/dir.c:860
 f2fs_add_link fs/f2fs/f2fs.h:3516 [inline]
 f2fs_create+0xd17/0x1900 fs/f2fs/namei.c:372
 lookup_open fs/namei.c:3253 [inline]
 open_last_lookups fs/namei.c:3323 [inline]
 path_openat+0x1377/0x3000 fs/namei.c:3512
 do_filp_open+0x21c/0x460 fs/namei.c:3542
 do_sys_openat2+0x13f/0x6f0 fs/open.c:1217
 do_sys_open fs/open.c:1233 [inline]
 __do_sys_creat fs/open.c:1307 [inline]
 __se_sys_creat fs/open.c:1301 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1301
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f982b0a2ae9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9829e250c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f982b1c1f80 RCX: 00007f982b0a2ae9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000400
RBP: 00007f982b0ee47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f982b1c1f80 R15: 00007ffc2a65b448

Allocated by task 22972:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:430 [inline]
 ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:509
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:518
 kasan_kmalloc include/linux/kasan.h:254 [inline]
 __kmalloc+0x1aa/0x330 mm/slub.c:4033
 kmalloc include/linux/slab.h:557 [inline]
 f2fs_kmalloc fs/f2fs/f2fs.h:3348 [inline]
 f2fs_fill_super+0x3733/0x7e30 fs/f2fs/super.c:4144
 mount_bdev+0x262/0x370 fs/super.c:1429
 f2fs_mount+0x34/0x40 fs/f2fs/super.c:4550
 legacy_get_tree+0xf1/0x190 fs/fs_context.c:593
 vfs_get_tree+0x88/0x290 fs/super.c:1559
 do_new_mount+0x28b/0xad0 fs/namespace.c:2899
 path_mount+0x56f/0xcb0 fs/namespace.c:3229
 do_mount fs/namespace.c:3242 [inline]
 __do_sys_mount fs/namespace.c:3450 [inline]
 __se_sys_mount+0x2c4/0x3b0 fs/namespace.c:3427
 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3427
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Freed by task 458:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x121/0x160 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:370
 kasan_slab_free include/linux/kasan.h:220 [inline]
 slab_free_hook mm/slub.c:1595 [inline]
 slab_free_freelist_hook+0xc0/0x190 mm/slub.c:1621
 slab_free mm/slub.c:3203 [inline]
 kfree+0xc3/0x270 mm/slub.c:4191
 kvfree+0x35/0x40 mm/util.c:647
 f2fs_put_super+0xa3b/0xc10 fs/f2fs/super.c:1650
 generic_shutdown_super+0x14f/0x2d0 fs/super.c:465
 kill_block_super+0x7e/0xe0 fs/super.c:1456
 kill_f2fs_super+0x2f9/0x3c0 fs/f2fs/super.c:4582
 deactivate_locked_super+0xad/0x110 fs/super.c:335
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xbf/0xd0 kernel/entry/common.c:172
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xc5/0x1d0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 insert_work+0x56/0x310 kernel/workqueue.c:1352
 __queue_work+0x970/0xd10 kernel/workqueue.c:1518
 queue_work_on+0x105/0x160 kernel/workqueue.c:1545
 queue_work include/linux/workqueue.h:514 [inline]
 schedule_work include/linux/workqueue.h:575 [inline]
 destroy_super_rcu+0xd1/0xe0 fs/super.c:172
 rcu_do_batch+0x597/0xc40 kernel/rcu/tree.c:2493
 rcu_core+0x5ad/0xe40 kernel/rcu/tree.c:2734
 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2747
 __do_softirq+0x268/0x5bb kernel/softirq.c:309

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0x100 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu kernel/rcu/tree.c:2975 [inline]
 call_rcu+0x135/0x11f0 kernel/rcu/tree.c:3049
 __put_super+0x25c/0x2b0 fs/super.c:299
 put_super fs/super.c:313 [inline]
 deactivate_locked_super+0xe1/0x110 fs/super.c:346
 deactivate_super+0xbe/0xf0 fs/super.c:366
 cleanup_mnt+0x45c/0x510 fs/namespace.c:1118
 __cleanup_mnt+0x19/0x20 fs/namespace.c:1125
 task_work_run+0x129/0x190 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_user_mode_loop+0xbf/0xd0 kernel/entry/common.c:172
 exit_to_user_mode_prepare kernel/entry/common.c:199 [inline]
 syscall_exit_to_user_mode+0xc5/0x1d0 kernel/entry/common.c:274
 do_syscall_64+0x40/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x61/0xc6

The buggy address belongs to the object at ffff88811cbc1000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 96 bytes inside of
 2048-byte region [ffff88811cbc1000, ffff88811cbc1800)
The buggy address belongs to the page:
page:ffffea000472f000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11cbc0
head:ffffea000472f000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head)
raw: 4000000000010200 dead000000000100 dead000000000122 ffff888100042d80
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 455, ts 185656126329, free_ts 185641356632
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2456 [inline]
 prep_new_page+0x166/0x180 mm/page_alloc.c:2462
 get_page_from_freelist+0x2d8c/0x2f30 mm/page_alloc.c:4254
 __alloc_pages_nodemask+0x435/0xaf0 mm/page_alloc.c:5346
 allocate_slab mm/slub.c:1808 [inline]
 new_slab+0x80/0x400 mm/slub.c:1869
 new_slab_objects mm/slub.c:2627 [inline]
 ___slab_alloc+0x302/0x4b0 mm/slub.c:2791
 __slab_alloc+0x63/0xa0 mm/slub.c:2831
 slab_alloc_node mm/slub.c:2913 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 __kmalloc+0x204/0x330 mm/slub.c:4029
 __kmalloc_node include/linux/slab.h:418 [inline]
 kmalloc_node include/linux/slab.h:575 [inline]
 kvmalloc_node+0x82/0x130 mm/util.c:612
 kvmalloc include/linux/mm.h:822 [inline]
 xt_alloc_table_info+0x42/0xb0 net/netfilter/x_tables.c:1172
 do_replace net/ipv6/netfilter/ip6_tables.c:1141 [inline]
 do_ip6t_set_ctl+0xacc/0x3f50 net/ipv6/netfilter/ip6_tables.c:1638
 nf_setsockopt+0x274/0x2a0 net/netfilter/nf_sockopt.c:101
 ipv6_setsockopt+0x2789/0x3ea0 net/ipv6/ipv6_sockglue.c:1011
 tcp_setsockopt+0x22d/0x3660 net/ipv4/tcp.c:3463
 sock_common_setsockopt+0xa2/0xc0 net/core/sock.c:3302
 __sys_setsockopt+0x502/0x870 net/socket.c:2127
 __do_sys_setsockopt net/socket.c:2138 [inline]
 __se_sys_setsockopt net/socket.c:2135 [inline]
 __x64_sys_setsockopt+0xbf/0xd0 net/socket.c:2135
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1349 [inline]
 __free_pages_ok+0x82c/0x850 mm/page_alloc.c:1629
 free_the_page+0x76/0x370 mm/page_alloc.c:5407
 __free_pages+0x67/0xc0 mm/page_alloc.c:5416
 __free_slab+0xcf/0x190 mm/slub.c:1894
 free_slab mm/slub.c:1909 [inline]
 discard_slab mm/slub.c:1915 [inline]
 unfreeze_partials+0x15e/0x190 mm/slub.c:2410
 put_cpu_partial+0xbf/0x180 mm/slub.c:2446
 __slab_free+0x2c8/0x3a0 mm/slub.c:3095
 do_slab_free mm/slub.c:3191 [inline]
 ___cache_free+0x111/0x130 mm/slub.c:3210
 qlink_free+0x50/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x47/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:440
 kasan_slab_alloc include/linux/kasan.h:244 [inline]
 slab_post_alloc_hook+0x61/0x2f0 mm/slab.h:583
 slab_alloc_node mm/slub.c:2947 [inline]
 slab_alloc mm/slub.c:2955 [inline]
 kmem_cache_alloc+0x168/0x2e0 mm/slub.c:2960
 getname_flags+0xba/0x520 fs/namei.c:141
 getname+0x19/0x20 fs/namei.c:212

Memory state around the buggy address:
 ffff88811cbc0f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88811cbc0f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88811cbc1000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff88811cbc1080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88811cbc1100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
general protection fault, probably for non-canonical address 0xffff110313cc1288: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0xfff8a8189e609440-0xfff8a8189e609447]
CPU: 1 PID: 23659 Comm: syz-executor.4 Tainted: G    B             5.10.194-syzkaller-00508-ga27512601c2d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
RIP: 0010:percpu_ref_get_many include/linux/percpu-refcount.h:205 [inline]
RIP: 0010:percpu_ref_get include/linux/percpu-refcount.h:222 [inline]
RIP: 0010:wb_get include/linux/backing-dev-defs.h:243 [inline]
RIP: 0010:locked_inode_to_wb_and_lock_list+0xc4/0x2f0 fs/fs-writeback.c:303
Code: 89 df e8 5f ad eb ff 48 8b 1b 48 89 de 48 83 e6 03 31 ff e8 0e 5d ae ff 48 89 d8 48 83 e0 03 0f 85 8e 00 00 00 e8 bc 58 ae ff <65> 48 ff 03 e8 c3 67 9b ff eb 05 e8 ac 58 ae ff 48 8b 7d d0 e8 53
RSP: 0018:ffffc9000751ee38 EFLAGS: 00010287
RAX: ffffffff81bc4774 RBX: ffff88811cbc1288 RCX: 0000000000040000
RDX: ffffc90004124000 RSI: 000000000003deed RDI: 000000000003deee
RBP: ffffc9000751ee70 R08: ffffffff81bc4762 R09: 0000000000000003
R10: fffffbfff0e10048 R11: dffffc0000000001 R12: ffff88811cbc1060
R13: dffffc0000000000 R14: 1ffff1102397820c R15: ffff88816bf9ee80
FS:  00007f9829e256c0(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020404030 CR3: 000000016585a000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 __mark_inode_dirty+0x400/0x9d0 fs/fs-writeback.c:2311
 inc_valid_node_count+0x571/0x9d0 fs/f2fs/f2fs.h:2606
 f2fs_new_node_page+0x241/0x990 fs/f2fs/node.c:1292
 f2fs_get_dnode_of_data+0x6f0/0x1fb0 fs/f2fs/node.c:809
 f2fs_reserve_block+0x53/0x310 fs/f2fs/data.c:1173
 f2fs_get_new_data_page+0x18f/0x8f0 fs/f2fs/data.c:1350
 f2fs_add_regular_entry+0x4c8/0xb10 fs/f2fs/dir.c:752
 f2fs_add_dentry+0x207/0x340 fs/f2fs/dir.c:821
 f2fs_do_add_link+0x29b/0x400 fs/f2fs/dir.c:860
 f2fs_add_link fs/f2fs/f2fs.h:3516 [inline]
 f2fs_create+0xd17/0x1900 fs/f2fs/namei.c:372
 lookup_open fs/namei.c:3253 [inline]
 open_last_lookups fs/namei.c:3323 [inline]
 path_openat+0x1377/0x3000 fs/namei.c:3512
 do_filp_open+0x21c/0x460 fs/namei.c:3542
 do_sys_openat2+0x13f/0x6f0 fs/open.c:1217
 do_sys_open fs/open.c:1233 [inline]
 __do_sys_creat fs/open.c:1307 [inline]
 __se_sys_creat fs/open.c:1301 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1301
 do_syscall_64+0x34/0x70
 entry_SYSCALL_64_after_hwframe+0x61/0xc6
RIP: 0033:0x7f982b0a2ae9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9829e250c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f982b1c1f80 RCX: 00007f982b0a2ae9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000400
RBP: 00007f982b0ee47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f982b1c1f80 R15: 00007ffc2a65b448
Modules linked in:
---[ end trace ffe5a370f289d7de ]---
RIP: 0010:percpu_ref_get_many include/linux/percpu-refcount.h:205 [inline]
RIP: 0010:percpu_ref_get include/linux/percpu-refcount.h:222 [inline]
RIP: 0010:wb_get include/linux/backing-dev-defs.h:243 [inline]
RIP: 0010:locked_inode_to_wb_and_lock_list+0xc4/0x2f0 fs/fs-writeback.c:303
Code: 89 df e8 5f ad eb ff 48 8b 1b 48 89 de 48 83 e6 03 31 ff e8 0e 5d ae ff 48 89 d8 48 83 e0 03 0f 85 8e 00 00 00 e8 bc 58 ae ff <65> 48 ff 03 e8 c3 67 9b ff eb 05 e8 ac 58 ae ff 48 8b 7d d0 e8 53
RSP: 0018:ffffc9000751ee38 EFLAGS: 00010287
RAX: ffffffff81bc4774 RBX: ffff88811cbc1288 RCX: 0000000000040000
RDX: ffffc90004124000 RSI: 000000000003deed RDI: 000000000003deee
RBP: ffffc9000751ee70 R08: ffffffff81bc4762 R09: 0000000000000003
R10: fffffbfff0e10048 R11: dffffc0000000001 R12: ffff88811cbc1060
R13: dffffc0000000000 R14: 1ffff1102397820c R15: ffff88816bf9ee80
FS:  00007f9829e256c0(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020404030 CR3: 000000016585a000 CR4: 00000000003526a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	89 df                	mov    %ebx,%edi
   2:	e8 5f ad eb ff       	call   0xffebad66
   7:	48 8b 1b             	mov    (%rbx),%rbx
   a:	48 89 de             	mov    %rbx,%rsi
   d:	48 83 e6 03          	and    $0x3,%rsi
  11:	31 ff                	xor    %edi,%edi
  13:	e8 0e 5d ae ff       	call   0xffae5d26
  18:	48 89 d8             	mov    %rbx,%rax
  1b:	48 83 e0 03          	and    $0x3,%rax
  1f:	0f 85 8e 00 00 00    	jne    0xb3
  25:	e8 bc 58 ae ff       	call   0xffae58e6
* 2a:	65 48 ff 03          	incq   %gs:(%rbx) <-- trapping instruction
  2e:	e8 c3 67 9b ff       	call   0xff9b67f6
  33:	eb 05                	jmp    0x3a
  35:	e8 ac 58 ae ff       	call   0xffae58e6
  3a:	48 8b 7d d0          	mov    -0x30(%rbp),%rdi
  3e:	e8                   	.byte 0xe8
  3f:	53                   	push   %rbx

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/08 01:46 android13-5.10-lts a27512601c2d 5e837c76 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in locked_inode_to_wb_and_lock_list
2023/09/07 13:06 android13-5.10-lts a27512601c2d 72324844 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-10 KASAN: use-after-free Read in locked_inode_to_wb_and_lock_list
* Struck through repros no longer work on HEAD.