syzbot


KASAN: use-after-free Read in nr_rt_ioctl

Status: upstream: reported C repro on 2025/01/03 08:20
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+6123f0423e02aee4ddcf@syzkaller.appspotmail.com
First crash: 32d, last: 12d
Bug presence (1)
Date Name Commit Repro Result
2025/01/12 upstream (ToT) b62cef9a5c67 C [report] KASAN: slab-use-after-free Read in nr_rt_ioctl

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in nr_dec_obs net/netrom/nr_route.c:471 [inline]
BUG: KASAN: use-after-free in nr_rt_ioctl+0x595/0xfb0 net/netrom/nr_route.c:692
Read of size 2 at addr ffff88802bc1c832 by task syz-executor324/4415

CPU: 1 PID: 4415 Comm: syz-executor324 Not tainted 6.1.124-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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:316 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:427
 kasan_report+0x136/0x160 mm/kasan/report.c:531
 nr_dec_obs net/netrom/nr_route.c:471 [inline]
 nr_rt_ioctl+0x595/0xfb0 net/netrom/nr_route.c:692
 sock_do_ioctl+0x152/0x450 net/socket.c:1204
 sock_ioctl+0x47f/0x770 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 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:0x7fa6a9158869
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 31 1a 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffda4791fc8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fa6a9158869
RDX: 0000000000000000 RSI: 00000000000089e2 RDI: 0000000000000005
RBP: 0000000000000000 R08: 00007fa6a91a6214 R09: 00007fa6a91a6214
R10: 00007fa6a91a6214 R11: 0000000000000246 R12: 00007ffda4791fec
R13: 00007ffda4792020 R14: 00007ffda4792000 R15: 0000000000000016
 </TASK>

Allocated by task 4415:
 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:563 [inline]
 nr_add_node+0x850/0x2210 net/netrom/nr_route.c:146
 nr_rt_ioctl+0xd38/0xfb0 net/netrom/nr_route.c:651
 sock_do_ioctl+0x152/0x450 net/socket.c:1204
 sock_ioctl+0x47f/0x770 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 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 4415:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
 nr_dec_obs net/netrom/nr_route.c:469 [inline]
 nr_rt_ioctl+0x2e1/0xfb0 net/netrom/nr_route.c:692
 sock_do_ioctl+0x152/0x450 net/socket.c:1204
 sock_ioctl+0x47f/0x770 net/socket.c:1321
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 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 ffff88802bc1c800
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 50 bytes inside of
 64-byte region [ffff88802bc1c800, ffff88802bc1c840)

The buggy address belongs to the physical page:
page:ffffea0000af0700 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x2bc1c
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0000aedf40 dead000000000005 ffff888017c41640
raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY), pid 3623, tgid 3623 (udevadm), ts 24249069221, free_ts 21327125005
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4328
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5605
 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+0xa1/0x230 mm/slab_common.c:949
 kmalloc include/linux/slab.h:568 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 tomoyo_encode2 security/tomoyo/realpath.c:45 [inline]
 tomoyo_encode+0x26b/0x530 security/tomoyo/realpath.c:80
 tomoyo_realpath_from_path+0x594/0x5d0 security/tomoyo/realpath.c:283
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x29f/0x710 security/tomoyo/file.c:822
 security_inode_getattr+0xcf/0x120 security/security.c:1361
 vfs_getattr+0x26/0x360 fs/stat.c:158
 vfs_statx+0x194/0x4b0 fs/stat.c:233
 vfs_fstatat fs/stat.c:267 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __x64_sys_newfstatat+0x151/0x1e0 fs/stat.c:431
 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:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x12a6/0x15b0 mm/page_alloc.c:3384
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3479
 kasan_depopulate_vmalloc_pte+0x66/0x80 mm/kasan/shadow.c:375
 apply_to_pte_range mm/memory.c:2662 [inline]
 apply_to_pmd_range mm/memory.c:2706 [inline]
 apply_to_pud_range mm/memory.c:2742 [inline]
 apply_to_p4d_range mm/memory.c:2778 [inline]
 __apply_to_page_range+0x9c5/0xcc0 mm/memory.c:2812
 kasan_release_vmalloc+0x96/0xb0 mm/kasan/shadow.c:492
 __purge_vmap_area_lazy+0x157c/0x1720 mm/vmalloc.c:1774
 _vm_unmap_aliases+0x476/0x4e0 mm/vmalloc.c:2177
 change_page_attr_set_clr+0x304/0xe70 arch/x86/mm/pat/set_memory.c:1821
 change_page_attr_set arch/x86/mm/pat/set_memory.c:1871 [inline]
 set_memory_nx+0xee/0x130 arch/x86/mm/pat/set_memory.c:2064
 free_init_pages arch/x86/mm/init.c:933 [inline]
 free_kernel_image_pages arch/x86/mm/init.c:952 [inline]
 free_initmem+0x71/0xc0 arch/x86/mm/init.c:979
 kernel_init+0x2d/0x290 init/main.c:1523
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff88802bc1c700: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88802bc1c780: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88802bc1c800: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                                     ^
 ffff88802bc1c880: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
 ffff88802bc1c900: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/11 11:18 linux-6.1.y c63962be84ef 6dbc6a9b .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in nr_rt_ioctl
2025/01/11 09:26 linux-6.1.y c63962be84ef 6dbc6a9b .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in nr_rt_ioctl
2025/01/23 04:55 linux-6.1.y f4f677285b38 a44b0418 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in nr_rt_ioctl
2025/01/03 08:19 linux-6.1.y 7dc732d24ff7 d3ccff63 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in nr_rt_ioctl
* Struck through repros no longer work on HEAD.