syzbot


KASAN: use-after-free Read in devlink_notify

Status: auto-obsoleted due to no activity on 2024/08/10 04:33
Reported-by: syzbot+39a0f9ccae0719b58cb1@syzkaller.appspotmail.com
First crash: 291d, last: 203d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in genlmsg_multicast_netns include/net/genetlink.h:314 [inline]
BUG: KASAN: use-after-free in devlink_notify+0xeb/0x150 net/core/devlink.c:756
Read of size 8 at addr ffff88807c1d1c58 by task syz-executor.4/7767

CPU: 0 PID: 7767 Comm: syz-executor.4 Not tainted 5.15.157-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/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
 genlmsg_multicast_netns include/net/genetlink.h:314 [inline]
 devlink_notify+0xeb/0x150 net/core/devlink.c:756
 devlink_unregister+0x13e/0x1d0 net/core/devlink.c:8987
 nsim_dev_remove+0xdf/0x100 drivers/net/netdevsim/dev.c:1583
 __device_release_driver drivers/base/dd.c:1227 [inline]
 device_release_driver_internal+0x4cb/0x7f0 drivers/base/dd.c:1262
 bus_remove_device+0x2e5/0x400 drivers/base/bus.c:529
 device_del+0x6e2/0xbd0 drivers/base/core.c:3597
 device_unregister+0x1c/0xc0 drivers/base/core.c:3630
 nsim_bus_dev_del drivers/net/netdevsim/bus.c:454 [inline]
 del_device_store+0x321/0x470 drivers/net/netdevsim/bus.c:354
 kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:296
 call_write_iter include/linux/fs.h:2172 [inline]
 new_sync_write fs/read_write.c:507 [inline]
 vfs_write+0xacf/0xe50 fs/read_write.c:594
 ksys_write+0x1a2/0x2c0 fs/read_write.c:647
 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:0x7fec90359bef
Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 b9 80 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 0c 81 02 00 48
RSP: 002b:00007fffeccac570 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007fec90359bef
RDX: 0000000000000001 RSI: 00007fffeccac5c0 RDI: 0000000000000005
RBP: 00007fec903a7039 R08: 0000000000000000 R09: 00007fffeccac3c7
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000001
R13: 00007fffeccac5c0 R14: 00007fec90fb1620 R15: 0000000000000003
 </TASK>

Allocated by task 7161:
 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
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 net_alloc net/core/net_namespace.c:405 [inline]
 copy_net_ns+0x143/0x5d0 net/core/net_namespace.c:460
 create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
 ksys_unshare+0x580/0xb20 kernel/fork.c:3101
 __do_sys_unshare kernel/fork.c:3175 [inline]
 __se_sys_unshare kernel/fork.c:3173 [inline]
 __x64_sys_unshare+0x34/0x40 kernel/fork.c:3173
 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 1232:
 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
 net_free net/core/net_namespace.c:434 [inline]
 cleanup_net+0xab5/0xb60 net/core/net_namespace.c:617
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:300

The buggy address belongs to the object at ffff88807c1d1a80
 which belongs to the cache net_namespace of size 6528
The buggy address is located 472 bytes inside of
 6528-byte region [ffff88807c1d1a80, ffff88807c1d3400)
The buggy address belongs to the page:
page:ffffea0001f07400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7c1d0
head:ffffea0001f07400 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88805d292941
flags: 0xfff80000010200(slab|head|node=0|zone=1|lastcpupid=0xfff)
raw: 00fff80000010200 0000000000000000 dead000000000122 ffff888011dec3c0
raw: 0000000000000000 0000000080040004 00000001ffffffff ffff88805d292941
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 5954, ts 158062595147, free_ts 157943666526
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5423
 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
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 net_alloc net/core/net_namespace.c:405 [inline]
 copy_net_ns+0x143/0x5d0 net/core/net_namespace.c:460
 create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
 ksys_unshare+0x580/0xb20 kernel/fork.c:3101
 __do_sys_unshare kernel/fork.c:3175 [inline]
 __se_sys_unshare kernel/fork.c:3173 [inline]
 __x64_sys_unshare+0x34/0x40 kernel/fork.c:3173
 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
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]
 __kmalloc+0x120/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 alloc_workqueue+0x193/0x13f0 kernel/workqueue.c:4335
 loop_configure+0x5e1/0x1470 drivers/block/loop.c:1259
 lo_ioctl+0x933/0x23b0
 blkdev_ioctl+0x333/0x6b0 block/ioctl.c:604
 block_ioctl+0xb1/0xf0 block/fops.c:493
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 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

Memory state around the buggy address:
 ffff88807c1d1b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807c1d1b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807c1d1c00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                    ^
 ffff88807c1d1c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807c1d1d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/30 15:17 linux-5.15.y b925f60c6ee7 3ce4924c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/04/11 14:56 linux-5.15.y cdfd0a7f0139 95ed9ece .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/04/11 14:47 linux-5.15.y cdfd0a7f0139 95ed9ece .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/03/31 07:56 linux-5.15.y 9465fef4ae35 6baf5069 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/03/18 13:51 linux-5.15.y b95c01af2113 baa80228 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/03/13 05:09 linux-5.15.y 574362648507 db5b7ff0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/03/12 13:17 linux-5.15.y 574362648507 c35c26ec .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/02/15 17:21 linux-5.15.y 6139f2a02fe0 fd39cf6f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/02/04 02:17 linux-5.15.y 6139f2a02fe0 a67b2c42 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in devlink_notify
2024/05/02 04:32 linux-5.15.y b925f60c6ee7 3ba885bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in devlink_notify
2024/03/07 13:16 linux-5.15.y 574362648507 2b789849 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in devlink_notify
* Struck through repros no longer work on HEAD.