syzbot


KASAN: use-after-free Read in cpu_map_generic_redirect

Status: upstream: reported on 2024/09/13 03:13
Reported-by: syzbot+714bac975dcb350b3b0e@syzkaller.appspotmail.com
First crash: 69d, last: 69d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-6-1 KASAN: use-after-free Read in cpu_map_generic_redirect 4 13d 92d 0/2 premoderation: reported on 2024/08/21 09:12

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in cpu_map_generic_redirect+0x1c7/0x650 kernel/bpf/cpumap.c:788
Read of size 8 at addr ffff8880797e2418 by task syz.3.857/6297

CPU: 1 PID: 6297 Comm: syz.3.857 Not tainted 6.1.110-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 cpu_map_generic_redirect+0x1c7/0x650 kernel/bpf/cpumap.c:788
 xdp_do_generic_redirect_map net/core/filter.c:4402 [inline]
 xdp_do_generic_redirect+0x401/0x850 net/core/filter.c:4449
 do_xdp_generic+0x50b/0x6d0 net/core/dev.c:4947
 tun_get_user+0x261e/0x42d0 drivers/net/tun.c:1920
 tun_chr_write_iter+0x10c/0x1f0 drivers/net/tun.c:2044
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x857/0xbc0 fs/read_write.c:584
 ksys_write+0x19c/0x2c0 fs/read_write.c:637
 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
RIP: 0033:0x7f0d7c17c9df
Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 c9 8d 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 1c 8e 02 00 48
RSP: 002b:00007f0d7cee5000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f0d7c335f80 RCX: 00007f0d7c17c9df
RDX: 000000000000fdef RSI: 00000000200000c0 RDI: 00000000000000c8
RBP: 00007f0d7c1f0b76 R08: 0000000000000000 R09: 0000000000000000
R10: 000000000000fdef R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0d7c335f80 R15: 00007fffef98e9c8
 </TASK>

Allocated by task 6037:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:557 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 alloc_mnt_ns+0xaf/0x3b0 fs/namespace.c:3437
 mount_subtree+0x98/0x4f0 fs/namespace.c:3550
 mount_subvol fs/btrfs/super.c:1701 [inline]
 btrfs_mount+0x479/0xb40 fs/btrfs/super.c:1927
 legacy_get_tree+0xeb/0x180 fs/fs_context.c:632
 vfs_get_tree+0x88/0x270 fs/super.c:1573
 do_new_mount+0x2ba/0xb40 fs/namespace.c:3051
 do_mount fs/namespace.c:3394 [inline]
 __do_sys_mount fs/namespace.c:3602 [inline]
 __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3579
 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

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 queue_work_on+0x14b/0x250 kernel/workqueue.c:1548
 cpu_map_free+0xd7/0x1b0 kernel/bpf/cpumap.c:641
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2845
 __cpu_map_entry_replace+0x74/0x170 kernel/bpf/cpumap.c:556
 cpu_map_free+0xd7/0x1b0 kernel/bpf/cpumap.c:641
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff8880797e2400
 which belongs to the cache kmalloc-cg-256 of size 256
The buggy address is located 24 bytes inside of
 256-byte region [ffff8880797e2400, ffff8880797e2500)

The buggy address belongs to the physical page:
page:ffffea0001e5f880 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880797e3e00 pfn:0x797e2
head:ffffea0001e5f880 order:1 compound_mapcount:0 compound_pincount:0
memcg:ffff888057213e01
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888017c42c80
raw: ffff8880797e3e00 000000008010000a 00000001ffffffff ffff888057213e01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3640, tgid 3640 (syz-executor), ts 68806358569, free_ts 68786139626
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x322e/0x33b0 mm/page_alloc.c:4290
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5558
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:935 [inline]
 __kmalloc_node+0xa2/0x230 mm/slab_common.c:943
 kmalloc_node include/linux/slab.h:583 [inline]
 kvmalloc_node+0x6e/0x180 mm/util.c:581
 kvmalloc include/linux/slab.h:710 [inline]
 kvzalloc include/linux/slab.h:718 [inline]
 allocate_hook_entries_size net/netfilter/core.c:61 [inline]
 nf_hook_entries_grow+0x331/0x760 net/netfilter/core.c:128
 __nf_register_net_hook+0x29c/0x930 net/netfilter/core.c:423
 nf_register_net_hook+0xac/0x180 net/netfilter/core.c:566
 nf_register_net_hooks+0x3d/0x1a0 net/netfilter/core.c:582
 ip6t_register_table+0x4d0/0x7b0 net/ipv6/netfilter/ip6_tables.c:1789
 ip6table_security_table_init+0x3e/0x60 net/ipv6/netfilter/ip6table_security.c:45
 xt_find_table_lock+0x2cc/0x3a0 net/netfilter/x_tables.c:1259
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1444 [inline]
 free_pcp_prepare mm/page_alloc.c:1494 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3464
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x156/0x170 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc_lru+0x10c/0x2d0 mm/slub.c:3429
 alloc_inode_sb include/linux/fs.h:3198 [inline]
 sock_alloc_inode+0x24/0xc0 net/socket.c:306
 alloc_inode fs/inode.c:261 [inline]
 new_inode_pseudo+0x61/0x1d0 fs/inode.c:1055
 sock_alloc net/socket.c:631 [inline]
 __sock_create+0x11f/0x910 net/socket.c:1514
 sock_create net/socket.c:1601 [inline]
 __sys_socket_create net/socket.c:1638 [inline]
 __sys_socket+0x136/0x3a0 net/socket.c:1666
 __do_sys_socket net/socket.c:1679 [inline]
 __se_sys_socket net/socket.c:1677 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1677
 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

Memory state around the buggy address:
 ffff8880797e2300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880797e2380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880797e2400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff8880797e2480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880797e2500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/13 03:13 linux-6.1.y 5f55cad62cc9 73e8a465 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in cpu_map_generic_redirect
* Struck through repros no longer work on HEAD.