syzbot


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

Status: auto-obsoleted due to no activity on 2024/12/20 11:28
Subsystems: netfs
[Documentation on labels]
Reported-by: syzbot+7c48153a9d788824044b@syzkaller.appspotmail.com
First crash: 125d, last: 115d
Cause bisection: introduced by (bisect log) :
commit 983cdcf8fe141b0ce16bc71959a5dc55bcb0764d
Author: David Howells <dhowells@redhat.com>
Date: Thu Jun 6 06:48:55 2024 +0000

  netfs: Simplify the writeback code

Crash: KASAN: slab-use-after-free Read in iov_iter_advance (log)
Repro: C syz .config
  
Fix bisection: fixed by (bisect log) :
commit df9b455633aee0bad3e5c3dc9fc1c860b13c96d2
Author: David Howells <dhowells@redhat.com>
Date: Thu Sep 26 13:58:30 2024 +0000

  netfs: Fix write oops in generic/346 (9p) and generic/074 (cifs)

  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [netfs?] KASAN: slab-use-after-free Read in iov_iter_advance 5 (12) 2024/10/29 08:15
Last patch testing requests (8)
Created Duration User Patch Repo Result
2024/12/20 11:10 17m retest repro upstream OK log
2024/10/11 10:59 22m retest repro upstream report log
2024/10/11 10:48 12m retest repro upstream report log
2024/09/21 09:26 30m hdanton@sina.com patch upstream OK log
2024/09/21 08:10 53m hdanton@sina.com patch upstream error
2024/09/21 02:06 22m hdanton@sina.com patch upstream report log
2024/09/20 23:54 22m hdanton@sina.com patch upstream report log
2024/09/20 17:14 20m aha310510@gmail.com patch git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ master report log

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in iov_iter_folioq_advance lib/iov_iter.c:540 [inline]
BUG: KASAN: slab-use-after-free in iov_iter_advance+0x677/0x6c0 lib/iov_iter.c:576
Read of size 8 at addr ffff888032562520 by task syz.0.111/5869

CPU: 1 UID: 0 PID: 5869 Comm: syz.0.111 Not tainted 6.11.0-syzkaller-11558-g075dbe9f6e3c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:488
 kasan_report+0xd9/0x110 mm/kasan/report.c:601
 iov_iter_folioq_advance lib/iov_iter.c:540 [inline]
 iov_iter_advance+0x677/0x6c0 lib/iov_iter.c:576
 netfs_write_folio+0x745/0x18f0 fs/netfs/write_issue.c:481
 netfs_writepages+0x2ba/0xb90 fs/netfs/write_issue.c:541
 do_writepages+0x1a6/0x7f0 mm/page-writeback.c:2683
 filemap_fdatawrite_wbc mm/filemap.c:398 [inline]
 filemap_fdatawrite_wbc+0x148/0x1c0 mm/filemap.c:388
 __filemap_fdatawrite_range+0xb3/0xf0 mm/filemap.c:431
 v9fs_dir_release+0x429/0x590 fs/9p/vfs_dir.c:219
 __fput+0x3f9/0xb60 fs/file_table.c:431
 task_work_run+0x151/0x250 kernel/task_work.c:228
 get_signal+0x1ca/0x2770 kernel/signal.c:2690
 arch_do_signal_or_restart+0x90/0x7e0 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x150/0x2a0 kernel/entry/common.c:218
 do_syscall_64+0xda/0x250 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fb00fd7df39
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:00007fb010b9e038 EFLAGS: 00000246 ORIG_RAX: 0000000000000028
RAX: 000000000069b000 RBX: 00007fb00ff35f80 RCX: 00007fb00fd7df39
RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000007
RBP: 00007fb00fdf0216 R08: 0000000000000000 R09: 0000000000000000
R10: 000000007ffff000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fb00ff35f80 R15: 00007ffdd0b2c048
 </TASK>

Allocated by task 5869:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394
 kmalloc_noprof include/linux/slab.h:878 [inline]
 netfs_buffer_append_folio+0x181/0x750 fs/netfs/misc.c:25
 netfs_write_folio+0x542/0x18f0 fs/netfs/write_issue.c:421
 netfs_writepages+0x2ba/0xb90 fs/netfs/write_issue.c:541
 do_writepages+0x1a6/0x7f0 mm/page-writeback.c:2683
 filemap_fdatawrite_wbc mm/filemap.c:398 [inline]
 filemap_fdatawrite_wbc+0x148/0x1c0 mm/filemap.c:388
 __filemap_fdatawrite_range+0xb3/0xf0 mm/filemap.c:431
 v9fs_dir_release+0x429/0x590 fs/9p/vfs_dir.c:219
 __fput+0x3f9/0xb60 fs/file_table.c:431
 task_work_run+0x151/0x250 kernel/task_work.c:228
 get_signal+0x1ca/0x2770 kernel/signal.c:2690
 arch_do_signal_or_restart+0x90/0x7e0 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x150/0x2a0 kernel/entry/common.c:218
 do_syscall_64+0xda/0x250 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 1035:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x51/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:2343 [inline]
 slab_free mm/slub.c:4580 [inline]
 kfree+0x14f/0x4b0 mm/slub.c:4728
 netfs_delete_buffer_head+0xa6/0x100 fs/netfs/misc.c:59
 netfs_writeback_unlock_folios fs/netfs/write_collect.c:139 [inline]
 netfs_collect_write_results fs/netfs/write_collect.c:493 [inline]
 netfs_write_collection_worker+0x20f9/0x4f80 fs/netfs/write_collect.c:551
 process_one_work+0x9c8/0x1ba0 kernel/workqueue.c:3229
 process_scheduled_works kernel/workqueue.c:3310 [inline]
 worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391
 kthread+0x2c4/0x3a0 kernel/kthread.c:389
 ret_from_fork+0x48/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

The buggy address belongs to the object at ffff888032562400
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 288 bytes inside of
 freed 512-byte region [ffff888032562400, ffff888032562600)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x32560
head: order:2 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801b041c80 0000000000000000 dead000000000001
raw: 0000000000000000 0000000080100010 00000001f5000000 0000000000000000
head: 00fff00000000040 ffff88801b041c80 0000000000000000 dead000000000001
head: 0000000000000000 0000000080100010 00000001f5000000 0000000000000000
head: 00fff00000000002 ffffea0000c95801 ffffffffffffffff 0000000000000000
head: 0000000000000004 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x52820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 2543, tgid 2543 (kworker/u8:8), ts 84626646065, free_ts 84598226035
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1537
 prep_new_page mm/page_alloc.c:1545 [inline]
 get_page_from_freelist+0x101e/0x3070 mm/page_alloc.c:3457
 __alloc_pages_noprof+0x223/0x25c0 mm/page_alloc.c:4733
 alloc_pages_mpol_noprof+0x275/0x610 mm/mempolicy.c:2265
 alloc_slab_page mm/slub.c:2413 [inline]
 allocate_slab mm/slub.c:2579 [inline]
 new_slab+0x28b/0x3f0 mm/slub.c:2632
 ___slab_alloc+0xd1d/0x16f0 mm/slub.c:3819
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3909
 __slab_alloc_node mm/slub.c:3962 [inline]
 slab_alloc_node mm/slub.c:4123 [inline]
 __do_kmalloc_node mm/slub.c:4264 [inline]
 __kmalloc_noprof+0x367/0x400 mm/slub.c:4277
 kmalloc_noprof include/linux/slab.h:882 [inline]
 switchdev_deferred_enqueue+0x2b/0x2b0 net/switchdev/switchdev.c:117
 switchdev_port_attr_set_defer net/switchdev/switchdev.c:183 [inline]
 switchdev_port_attr_set+0xb5/0x120 net/switchdev/switchdev.c:202
 br_set_state+0x237/0x880 net/bridge/br_stp.c:52
 br_init_port+0xc6/0x250 net/bridge/br_stp_if.c:39
 br_stp_enable_port+0x15/0x50 net/bridge/br_stp_if.c:93
 br_port_carrier_check+0x264/0x4c0 net/bridge/br_if.c:89
 br_device_event+0x50b/0x920 net/bridge/br.c:89
 notifier_call_chain+0xbc/0x410 kernel/notifier.c:93
page last free pid 5240 tgid 5240 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1108 [inline]
 free_unref_page+0x5f4/0xdc0 mm/page_alloc.c:2638
 __put_partials+0x14c/0x170 mm/slub.c:3146
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x4e/0x120 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x192/0x1e0 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x69/0x90 mm/kasan/common.c:329
 kasan_slab_alloc include/linux/kasan.h:247 [inline]
 slab_post_alloc_hook mm/slub.c:4086 [inline]
 slab_alloc_node mm/slub.c:4135 [inline]
 __do_kmalloc_node mm/slub.c:4264 [inline]
 __kmalloc_noprof+0x199/0x400 mm/slub.c:4277
 kmalloc_noprof include/linux/slab.h:882 [inline]
 kzalloc_noprof include/linux/slab.h:1014 [inline]
 fib6_info_alloc+0x40/0x160 net/ipv6/ip6_fib.c:155
 ip6_route_info_create+0x337/0x1910 net/ipv6/route.c:3761
 ip6_route_add+0x26/0x1c0 net/ipv6/route.c:3853
 addrconf_prefix_route+0x2fe/0x510 net/ipv6/addrconf.c:2486
 add_v4_addrs+0x6ce/0x9f0 net/ipv6/addrconf.c:3271
 addrconf_gre_config net/ipv6/addrconf.c:3546 [inline]
 addrconf_init_auto_addrs+0x18a/0x820 net/ipv6/addrconf.c:3564
 addrconf_notify+0xe91/0x19c0 net/ipv6/addrconf.c:3745
 notifier_call_chain+0xbc/0x410 kernel/notifier.c:93
 call_netdevice_notifiers_info+0xbe/0x140 net/core/dev.c:1996
 call_netdevice_notifiers_extack net/core/dev.c:2034 [inline]
 call_netdevice_notifiers net/core/dev.c:2048 [inline]
 __dev_notify_flags+0x12d/0x2e0 net/core/dev.c:8876

Memory state around the buggy address:
 ffff888032562400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888032562480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888032562500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff888032562580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888032562600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/27 10:47 upstream 075dbe9f6e3c 9314348a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/27 10:44 upstream 075dbe9f6e3c 9314348a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/27 10:41 upstream 075dbe9f6e3c 9314348a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/27 04:57 upstream 075dbe9f6e3c 9314348a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/25 14:11 upstream a430d95c5efa 349a68c4 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/24 17:35 upstream a430d95c5efa 5643e0e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/19 09:39 upstream a430d95c5efa c673ca06 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/17 07:36 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/17 07:29 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/18 01:48 upstream a940d9a43e62 c673ca06 .config console log report syz / log [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in iov_iter_advance
2024/09/17 23:38 upstream a940d9a43e62 c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream KASAN: slab-use-after-free Read in iov_iter_advance
* Struck through repros no longer work on HEAD.