syzbot


KASAN: use-after-free Read in __dev_get_by_index

Status: premoderation: reported on 2024/09/29 15:33
Reported-by: syzbot+0b6afc29dc501dfa8b44@syzkaller.appspotmail.com
First crash: 53d, last: 53d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_index_hash net/core/dev.c:218 [inline]
BUG: KASAN: use-after-free in __dev_get_by_index+0x3d/0x110 net/core/dev.c:819
Read of size 8 at addr ffff8881008bea68 by task kworker/1:7/20434

CPU: 1 PID: 20434 Comm: kworker/1:7 Not tainted 6.1.99-syzkaller-00091-g110595418159 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Workqueue: events cleanup_bearer
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x158/0x4e0 mm/kasan/report.c:427
 kasan_report+0x13c/0x170 mm/kasan/report.c:531
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:351
 dev_index_hash net/core/dev.c:218 [inline]
 __dev_get_by_index+0x3d/0x110 net/core/dev.c:819
 __ipv6_sock_mc_close+0x1a0/0x3b0 net/ipv6/mcast.c:331
 ipv6_sock_mc_close+0xe0/0x140 net/ipv6/mcast.c:356
 inet6_release+0x47/0x70 net/ipv6/af_inet6.c:488
 __sock_release net/socket.c:652 [inline]
 sock_release+0x7e/0x140 net/socket.c:680
 udp_tunnel_sock_release+0x76/0x80 net/ipv4/udp_tunnel_core.c:181
 cleanup_bearer+0x2b1/0x300 net/tipc/udp_media.c:820
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
 </TASK>

Allocated by task 22938:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:333
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3421 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x175/0x2c0 mm/slub.c:3445
 kmem_cache_zalloc include/linux/slab.h:682 [inline]
 net_alloc net/core/net_namespace.c:413 [inline]
 copy_net_ns+0x144/0x5b0 net/core/net_namespace.c:468
 create_new_namespaces+0x416/0x670 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x126/0x180 kernel/nsproxy.c:226
 ksys_unshare+0x542/0xa00 kernel/fork.c:3312
 __do_sys_unshare kernel/fork.c:3383 [inline]
 __se_sys_unshare kernel/fork.c:3381 [inline]
 __x64_sys_unshare+0x38/0x40 kernel/fork.c:3381
 x64_sys_call+0x728/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:273
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 19605:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249
 kasan_slab_free include/linux/kasan.h:178 [inline]
 slab_free_hook mm/slub.c:1745 [inline]
 slab_free_freelist_hook mm/slub.c:1771 [inline]
 slab_free mm/slub.c:3684 [inline]
 kmem_cache_free+0x291/0x510 mm/slub.c:3706
 net_free net/core/net_namespace.c:442 [inline]
 cleanup_net+0xb4c/0xbf0 net/core/net_namespace.c:625
 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299
 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

The buggy address belongs to the object at ffff8881008be900
 which belongs to the cache net_namespace of size 4224
The buggy address is located 360 bytes inside of
 4224-byte region [ffff8881008be900, ffff8881008bf980)

The buggy address belongs to the physical page:
page:ffffea0004022e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1008b8
head:ffffea0004022e00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 ffffea0004b3c600 dead000000000002 ffff8881002b2000
raw: 0000000000000000 0000000080070007 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 8302, tgid 8302 (syz-executor), ts 614111604347, free_ts 613853175633
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597
 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425
 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5714
 alloc_slab_page+0x6c/0xf0
 allocate_slab mm/slub.c:1962 [inline]
 new_slab+0x90/0x3e0 mm/slub.c:2015
 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203
 __slab_alloc+0x5d/0xa0 mm/slub.c:3302
 slab_alloc_node mm/slub.c:3387 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x1b9/0x2c0 mm/slub.c:3445
 kmem_cache_zalloc include/linux/slab.h:682 [inline]
 net_alloc net/core/net_namespace.c:413 [inline]
 copy_net_ns+0x144/0x5b0 net/core/net_namespace.c:468
 create_new_namespaces+0x416/0x670 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x126/0x180 kernel/nsproxy.c:226
 ksys_unshare+0x542/0xa00 kernel/fork.c:3312
 __do_sys_unshare kernel/fork.c:3383 [inline]
 __se_sys_unshare kernel/fork.c:3381 [inline]
 __x64_sys_unshare+0x38/0x40 kernel/fork.c:3381
 x64_sys_call+0x728/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:273
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1498 [inline]
 free_pcp_prepare mm/page_alloc.c:1572 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3498
 free_unref_page+0xb2/0x5c0 mm/page_alloc.c:3594
 free_the_page mm/page_alloc.c:798 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5803
 __free_slab+0xce/0x1a0 mm/slub.c:2039
 free_slab mm/slub.c:2054 [inline]
 discard_slab mm/slub.c:2060 [inline]
 __unfreeze_partials+0x165/0x1a0 mm/slub.c:2609
 put_cpu_partial+0xa9/0x100 mm/slub.c:2685
 __slab_free+0x1c8/0x280 mm/slub.c:3561
 do_slab_free mm/slub.c:3638 [inline]
 ___cache_free+0xc6/0xd0 mm/slub.c:3691
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0xc5/0x140 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x24/0x80 mm/kasan/common.c:310
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3421 [inline]
 kmem_cache_alloc_node+0x18a/0x2d0 mm/slub.c:3466
 __alloc_skb+0xcc/0x2d0 net/core/skbuff.c:505
 alloc_skb include/linux/skbuff.h:1290 [inline]
 nlmsg_new include/net/netlink.h:991 [inline]
 inet_netconf_notify_devconf+0x173/0x230 net/ipv4/devinet.c:2115
 __devinet_sysctl_unregister net/ipv4/devinet.c:2626 [inline]
 devinet_sysctl_unregister net/ipv4/devinet.c:2650 [inline]
 inetdev_destroy net/ipv4/devinet.c:327 [inline]
 inetdev_event+0x823/0x1110 net/ipv4/devinet.c:1602

Memory state around the buggy address:
 ffff8881008be900: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881008be980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881008bea00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                          ^
 ffff8881008bea80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881008beb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/29 15:32 android14-6.1 110595418159 ba29ff75 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Read in __dev_get_by_index
* Struck through repros no longer work on HEAD.