syzbot


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

Status: upstream: reported C repro on 2024/09/20 18:38
Subsystems: netfs
[Documentation on labels]
Reported-by: syzbot+e6089e62b4d92c4a7792@syzkaller.appspotmail.com
First crash: 26d, last: 18d
Discussions (2)
Title Replies (including bot) Last reply
[syzbot] Monthly netfs report (Sep 2024) 0 (1) 2024/09/25 12:47
[syzbot] [netfs?] KASAN: slab-use-after-free Read in iov_iter_folioq_advance 0 (1) 2024/09/20 18:38
Last patch testing requests (1)
Created Duration User Patch Repo Result
2024/10/08 15:18 21m retest repro upstream OK log

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in iov_iter_folioq_advance+0x10c/0x360 lib/iov_iter.c:540
Read of size 8 at addr ffff88807d570520 by task syz.0.1507/17447

CPU: 1 UID: 0 PID: 17447 Comm: syz.0.1507 Not tainted 6.11.0-syzkaller-04003-gfc1dc0d50780 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 iov_iter_folioq_advance+0x10c/0x360 lib/iov_iter.c:540
 netfs_write_folio+0x154b/0x1fe0 fs/netfs/write_issue.c:481
 netfs_writepages+0x89f/0xe80 fs/netfs/write_issue.c:541
 do_writepages+0x35f/0x870 mm/page-writeback.c:2683
 filemap_fdatawrite_wbc+0x125/0x180 mm/filemap.c:397
 __filemap_fdatawrite_range mm/filemap.c:430 [inline]
 __filemap_fdatawrite mm/filemap.c:436 [inline]
 filemap_fdatawrite+0xfb/0x160 mm/filemap.c:441
 v9fs_dir_release+0x151/0x560 fs/9p/vfs_dir.c:219
 __fput+0x241/0x880 fs/file_table.c:431
 task_work_run+0x251/0x310 kernel/task_work.c:228
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [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+0x168/0x370 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f85ca77def9
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:00007fff612af318 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007f85ca937a80 RCX: 00007f85ca77def9
RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003
RBP: 00007f85ca937a80 R08: 00007f85ca922000 R09: 00007fff612af60f
R10: 00000000005e7644 R11: 0000000000000246 R12: 00000000001a1f10
R13: 00007fff612af420 R14: 0000000000000032 R15: ffffffffffffffff
 </TASK>

Allocated by task 17447:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __kmalloc_cache_noprof+0x19c/0x2c0 mm/slub.c:4190
 kmalloc_noprof include/linux/slab.h:690 [inline]
 netfs_buffer_append_folio+0x1f1/0x8b0 fs/netfs/misc.c:25
 netfs_write_folio+0xe69/0x1fe0 fs/netfs/write_issue.c:421
 netfs_writepages+0x89f/0xe80 fs/netfs/write_issue.c:541
 do_writepages+0x35f/0x870 mm/page-writeback.c:2683
 filemap_fdatawrite_wbc+0x125/0x180 mm/filemap.c:397
 __filemap_fdatawrite_range mm/filemap.c:430 [inline]
 __filemap_fdatawrite mm/filemap.c:436 [inline]
 filemap_fdatawrite+0xfb/0x160 mm/filemap.c:441
 v9fs_dir_release+0x151/0x560 fs/9p/vfs_dir.c:219
 __fput+0x241/0x880 fs/file_table.c:431
 task_work_run+0x251/0x310 kernel/task_work.c:228
 resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:114 [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+0x168/0x370 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5624:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2250 [inline]
 slab_free mm/slub.c:4474 [inline]
 kfree+0x149/0x360 mm/slub.c:4595
 netfs_delete_buffer_head+0x9f/0xd0 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+0x1b9a/0x4950 fs/netfs/write_collect.c:551
 process_one_work kernel/workqueue.c:3231 [inline]
 process_scheduled_works+0xa2e/0x1830 kernel/workqueue.c:3312
 worker_thread+0x870/0xd30 kernel/workqueue.c:3393
 kthread+0x2f2/0x390 kernel/kthread.c:389
 ret_from_fork+0x4d/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 ffff88807d570400
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 288 bytes inside of
 freed 512-byte region [ffff88807d570400, ffff88807d570600)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7d570
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: 0xfdffffff(slab)
raw: 00fff00000000040 ffff88801ac41c80 0000000000000000 dead000000000001
raw: 0000000000000000 0000000000100010 00000001fdffffff 0000000000000000
head: 00fff00000000040 ffff88801ac41c80 0000000000000000 dead000000000001
head: 0000000000000000 0000000000100010 00000001fdffffff 0000000000000000
head: 00fff00000000002 ffffea0001f55c01 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5238, tgid 5238 (syz-executor), ts 64956103056, free_ts 64903642045
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1500
 prep_new_page mm/page_alloc.c:1508 [inline]
 get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3446
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4702
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x5f/0x120 mm/slub.c:2319
 allocate_slab+0x5a/0x2f0 mm/slub.c:2482
 new_slab mm/slub.c:2535 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3721
 __slab_alloc+0x58/0xa0 mm/slub.c:3811
 __slab_alloc_node mm/slub.c:3864 [inline]
 slab_alloc_node mm/slub.c:4026 [inline]
 __kmalloc_cache_noprof+0x1d5/0x2c0 mm/slub.c:4185
 kmalloc_noprof include/linux/slab.h:690 [inline]
 kzalloc_noprof include/linux/slab.h:816 [inline]
 mca_alloc net/ipv6/mcast.c:881 [inline]
 __ipv6_dev_mc_inc+0x429/0xaa0 net/ipv6/mcast.c:937
 ipv6_add_dev+0xe12/0x1220 net/ipv6/addrconf.c:471
 addrconf_notify+0x6a7/0x1020 net/ipv6/addrconf.c:3655
 notifier_call_chain+0x1a1/0x3e0 kernel/notifier.c:93
 call_netdevice_notifiers_extack net/core/dev.c:2034 [inline]
 call_netdevice_notifiers net/core/dev.c:2048 [inline]
 register_netdevice+0x167f/0x1b00 net/core/dev.c:10520
 register_netdev+0x3b/0x50 net/core/dev.c:10624
 vti6_init_net+0x233/0x2f0 net/ipv6/ip6_vti.c:1155
 ops_init+0x320/0x590 net/core/net_namespace.c:139
page last free pid 5235 tgid 5235 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1101 [inline]
 free_unref_page+0xd22/0xea0 mm/page_alloc.c:2619
 __slab_free+0x31b/0x3d0 mm/slub.c:4385
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x9e/0x140 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3989 [inline]
 slab_alloc_node mm/slub.c:4038 [inline]
 __kmalloc_cache_noprof+0x132/0x2c0 mm/slub.c:4185
 kmalloc_noprof include/linux/slab.h:690 [inline]
 kzalloc_noprof include/linux/slab.h:816 [inline]
 ref_tracker_alloc+0x14b/0x490 lib/ref_tracker.c:203
 __netdev_tracker_alloc include/linux/netdevice.h:4050 [inline]
 netdev_hold include/linux/netdevice.h:4079 [inline]
 netdev_queue_add_kobject net/core/net-sysfs.c:1786 [inline]
 netdev_queue_update_kobjects+0x181/0x550 net/core/net-sysfs.c:1841
 register_queue_kobjects net/core/net-sysfs.c:1903 [inline]
 netdev_register_kobject+0x265/0x310 net/core/net-sysfs.c:2143
 register_netdevice+0x12c5/0x1b00 net/core/dev.c:10487
 register_netdev+0x3b/0x50 net/core/dev.c:10624
 sit_init_net+0x1f9/0x500 net/ipv6/sit.c:1861
 ops_init+0x320/0x590 net/core/net_namespace.c:139
 setup_net+0x287/0x9e0 net/core/net_namespace.c:356
 copy_net_ns+0x33f/0x570 net/core/net_namespace.c:494
 create_new_namespaces+0x425/0x7b0 kernel/nsproxy.c:110

Memory state around the buggy address:
 ffff88807d570400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807d570480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807d570500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff88807d570580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807d570600: 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/17 18:58 upstream fc1dc0d50780 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/17 18:58 upstream fc1dc0d50780 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/17 05:54 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/17 05:53 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/16 18:31 upstream adfc3ded5c33 49cf0773 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/16 23:23 upstream adfc3ded5c33 49cf0773 .config console log report syz / log C [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/16 21:38 upstream adfc3ded5c33 49cf0773 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/24 15:13 linux-next 4d0326b60bb7 5643e0e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/24 15:13 linux-next 4d0326b60bb7 5643e0e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/24 15:11 linux-next 4d0326b60bb7 5643e0e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
2024/09/24 15:11 linux-next 4d0326b60bb7 5643e0e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root KASAN: slab-use-after-free Read in iov_iter_folioq_advance
* Struck through repros no longer work on HEAD.