syzbot


KASAN: use-after-free Read in dev_map_generic_redirect

Status: upstream: reported on 2024/08/19 13:49
Reported-by: syzbot+d3199baa0cdf04ff148c@syzkaller.appspotmail.com
First crash: 94d, last: 4d02h
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-6-1 general protection fault in dev_map_generic_redirect origin:lts syz 72 2d05h 233d 0/2 premoderation: reported syz repro on 2024/04/02 16:15
upstream BUG: unable to handle kernel NULL pointer dereference in dev_map_generic_redirect bpf net 20 128d 227d 0/28 auto-obsoleted due to no activity on 2024/10/01 02:11

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in dev_map_generic_redirect+0xa0/0x650 kernel/bpf/devmap.c:668
Read of size 8 at addr ffff8880594fe380 by task syz.2.498/6186

CPU: 1 PID: 6186 Comm: syz.2.498 Not tainted 6.1.118-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/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
 dev_map_generic_redirect+0xa0/0x650 kernel/bpf/devmap.c:668
 xdp_do_generic_redirect_map net/core/filter.c:4392 [inline]
 xdp_do_generic_redirect+0x4bf/0x850 net/core/filter.c:4451
 do_xdp_generic+0x50b/0x6d0 net/core/dev.c:4955
 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:0x7fac7457d1ff
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:00007fac7537d000 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007fac74735f80 RCX: 00007fac7457d1ff
RDX: 0000000000000d86 RSI: 0000000020002340 RDI: 00000000000000c8
RBP: 00007fac745f175e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000d86 R11: 0000000000000293 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fac74735f80 R15: 00007ffca522da78
 </TASK>

Allocated by task 4259:
 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
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:936 [inline]
 __kmalloc_node+0xb3/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]
 alloc_fdtable+0x154/0x280 fs/file.c:137
 dup_fd+0x95c/0xca0 fs/file.c:336
 copy_files+0x72/0xe0 kernel/fork.c:1636
 copy_process+0x1873/0x4060 kernel/fork.c:2254
 kernel_clone+0x222/0x920 kernel/fork.c:2681
 __do_sys_clone kernel/fork.c:2822 [inline]
 __se_sys_clone kernel/fork.c:2806 [inline]
 __x64_sys_clone+0x231/0x280 kernel/fork.c:2806
 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

The buggy address belongs to the object at ffff8880594fe380
 which belongs to the cache kmalloc-cg-96 of size 96
The buggy address is located 0 bytes inside of
 96-byte region [ffff8880594fe380, ffff8880594fe3e0)

The buggy address belongs to the physical page:
page:ffffea0001653f80 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880594fee00 pfn:0x594fe
memcg:ffff88807b1ef401
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea000164dac8 ffffea000160a5c8 ffff888017c428c0
raw: ffff8880594fee00 0000000000200001 00000001ffffffff ffff88807b1ef401
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 4441, tgid 4441 (syz.4.41), ts 84059899561, free_ts 84027054401
 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+0x3731/0x38d0 mm/page_alloc.c:4313
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5589
 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
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:557 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 get_undo_list ipc/sem.c:1856 [inline]
 copy_semundo+0xb1/0x230 ipc/sem.c:2314
 copy_process+0x1848/0x4060 kernel/fork.c:2251
 kernel_clone+0x222/0x920 kernel/fork.c:2681
 __do_sys_clone3 kernel/fork.c:2980 [inline]
 __se_sys_clone3+0x373/0x410 kernel/fork.c:2964
 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
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]
 __kmem_cache_alloc_node+0x137/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:935 [inline]
 __kmalloc+0xa1/0x230 mm/slab_common.c:949
 kmalloc include/linux/slab.h:562 [inline]
 tomoyo_realpath_from_path+0xcb/0x5d0 security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_check_open_permission+0x240/0x4c0 security/tomoyo/file.c:771
 security_file_open+0x5f/0xa0 security/security.c:1681
 do_dentry_open+0x308/0x10f0 fs/open.c:869
 do_open fs/namei.c:3626 [inline]
 path_openat+0x2644/0x2e60 fs/namei.c:3783
 do_filp_open+0x230/0x480 fs/namei.c:3810
 do_sys_openat2+0x13b/0x4f0 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_openat fs/open.c:1350 [inline]
 __se_sys_openat fs/open.c:1345 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1345

Memory state around the buggy address:
 ffff8880594fe280: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff8880594fe300: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
>ffff8880594fe380: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
                   ^
 ffff8880594fe400: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff8880594fe480: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
==================================================================

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/17 19:08 linux-6.1.y b67dc5c9ade9 cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_map_generic_redirect
2024/11/13 15:05 linux-6.1.y d7039b844a1c bb3f8425 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_map_generic_redirect
2024/11/13 15:05 linux-6.1.y d7039b844a1c bb3f8425 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_map_generic_redirect
2024/11/13 15:05 linux-6.1.y d7039b844a1c bb3f8425 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_map_generic_redirect
2024/11/13 15:03 linux-6.1.y d7039b844a1c bb3f8425 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_map_generic_redirect
2024/11/08 06:41 linux-6.1.y 7c15117f9468 179b040e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_map_generic_redirect
2024/09/13 03:14 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 dev_map_generic_redirect
2024/09/13 03:14 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 dev_map_generic_redirect
2024/08/28 15:06 linux-6.1.y ee5e09825b81 ef3de9e8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in dev_map_generic_redirect
2024/08/19 13:48 linux-6.1.y ee5e09825b81 9f0ab3fb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in dev_map_generic_redirect
* Struck through repros no longer work on HEAD.