syzbot


KASAN: slab-use-after-free Read in addr_handler

Status: moderation: reported on 2024/05/17 10:00
Subsystems: rdma
[Documentation on labels]
Reported-by: syzbot+0b80ca320ed831524a56@syzkaller.appspotmail.com
First crash: 32d, last: 32d
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in addr_handler (5) rdma 1 991d 987d 0/27 closed as dup on 2021/10/01 13:34
upstream KASAN: use-after-free Read in addr_handler (4) rdma 1 1007d 1003d 27/27 closed as dup on 2021/09/15 19:36
upstream KASAN: use-after-free Read in addr_handler (3) rdma 1 1148d 1145d 0/27 auto-closed as invalid on 2021/07/22 15:33

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in debug_spin_lock_before kernel/locking/spinlock_debug.c:86 [inline]
BUG: KASAN: slab-use-after-free in do_raw_spin_lock+0x271/0x2c0 kernel/locking/spinlock_debug.c:115
Read of size 4 at addr ffff8880110f13c4 by task kworker/u32:19/26726

CPU: 2 PID: 26726 Comm: kworker/u32:19 Not tainted 6.9.0-syzkaller #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Workqueue: ib_addr process_one_req
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0xc3/0x620 mm/kasan/report.c:488
 kasan_report+0xd9/0x110 mm/kasan/report.c:601
 debug_spin_lock_before kernel/locking/spinlock_debug.c:86 [inline]
 do_raw_spin_lock+0x271/0x2c0 kernel/locking/spinlock_debug.c:115
 __mutex_unlock_slowpath+0x197/0x650 kernel/locking/mutex.c:937
 addr_handler+0x123/0x450 drivers/infiniband/core/cma.c:3520
 process_one_req+0x12b/0x620 drivers/infiniband/core/addr.c:646
 process_one_work+0x902/0x1a30 kernel/workqueue.c:3267
 process_scheduled_works kernel/workqueue.c:3348 [inline]
 worker_thread+0x6c8/0xf70 kernel/workqueue.c:3429
 kthread+0x2c1/0x3a0 kernel/kthread.c:388
 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>

Allocated by task 31293:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:387
 kmalloc include/linux/slab.h:628 [inline]
 kzalloc include/linux/slab.h:749 [inline]
 __rdma_create_id+0x5b/0x630 drivers/infiniband/core/cma.c:993
 __rdma_create_kernel_id+0x3c/0x90 drivers/infiniband/core/cma.c:1033
 rdma_create_trans+0x9a5/0x15b0 net/9p/trans_rdma.c:657
 p9_client_create+0x81a/0x11b0 net/9p/client.c:1012
 v9fs_session_init+0x1f8/0x1a80 fs/9p/v9fs.c:410
 v9fs_mount+0xc6/0xaa0 fs/9p/vfs_super.c:122
 legacy_get_tree+0x109/0x220 fs/fs_context.c:662
 vfs_get_tree+0x8f/0x380 fs/super.c:1779
 do_new_mount fs/namespace.c:3352 [inline]
 path_mount+0x6e1/0x1f10 fs/namespace.c:3679
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount fs/namespace.c:3875 [inline]
 __ia32_sys_mount+0x295/0x320 fs/namespace.c:3875
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x75/0x120 arch/x86/entry/common.c:386
 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
 entry_SYSENTER_compat_after_hwframe+0x84/0x8e

Freed by task 31293:
 kasan_save_stack+0x33/0x60 mm/kasan/common.c:47
 kasan_save_track+0x14/0x30 mm/kasan/common.c:68
 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579
 poison_slab_object mm/kasan/common.c:240 [inline]
 __kasan_slab_free+0x11d/0x1a0 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2111 [inline]
 slab_free mm/slub.c:4286 [inline]
 kfree+0x129/0x3a0 mm/slub.c:4396
 rdma_destroy_trans+0x186/0x210 net/9p/trans_rdma.c:377
 rdma_create_trans+0x11dc/0x15b0 net/9p/trans_rdma.c:743
 p9_client_create+0x81a/0x11b0 net/9p/client.c:1012
 v9fs_session_init+0x1f8/0x1a80 fs/9p/v9fs.c:410
 v9fs_mount+0xc6/0xaa0 fs/9p/vfs_super.c:122
 legacy_get_tree+0x109/0x220 fs/fs_context.c:662
 vfs_get_tree+0x8f/0x380 fs/super.c:1779
 do_new_mount fs/namespace.c:3352 [inline]
 path_mount+0x6e1/0x1f10 fs/namespace.c:3679
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount fs/namespace.c:3875 [inline]
 __ia32_sys_mount+0x295/0x320 fs/namespace.c:3875
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x75/0x120 arch/x86/entry/common.c:386
 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
 entry_SYSENTER_compat_after_hwframe+0x84/0x8e

The buggy address belongs to the object at ffff8880110f1000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 964 bytes inside of
 freed 2048-byte region [ffff8880110f1000, ffff8880110f1800)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x110f0
head: order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0xfff00000000840(slab|head|node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffffff()
raw: 00fff00000000840 ffff888014c42f00 0000000000000000 dead000000000001
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
head: 00fff00000000840 ffff888014c42f00 0000000000000000 dead000000000001
head: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
head: 00fff00000000003 ffffea0000443c01 dead000000000122 00000000ffffffff
head: 0000000800000000 0000000000000000 00000000ffffffff 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 31006, tgid 31005 (syz-executor.2), ts 1005192695362, free_ts 1005113826857
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x2d4/0x350 mm/page_alloc.c:1534
 prep_new_page mm/page_alloc.c:1541 [inline]
 get_page_from_freelist+0xa28/0x3780 mm/page_alloc.c:3317
 __alloc_pages+0x22b/0x2460 mm/page_alloc.c:4575
 __alloc_pages_node include/linux/gfp.h:238 [inline]
 alloc_pages_node include/linux/gfp.h:261 [inline]
 alloc_slab_page mm/slub.c:2180 [inline]
 allocate_slab mm/slub.c:2343 [inline]
 new_slab+0xcc/0x3a0 mm/slub.c:2396
 ___slab_alloc+0x670/0x16d0 mm/slub.c:3530
 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3615
 __slab_alloc_node mm/slub.c:3668 [inline]
 slab_alloc_node mm/slub.c:3841 [inline]
 __do_kmalloc_node mm/slub.c:3971 [inline]
 __kmalloc+0x3bf/0x440 mm/slub.c:3985
 kmalloc include/linux/slab.h:632 [inline]
 sk_prot_alloc+0x1a8/0x2a0 net/core/sock.c:2080
 sk_alloc+0x36/0xb90 net/core/sock.c:2133
 __netlink_create+0x63/0x300 net/netlink/af_netlink.c:647
 netlink_create+0x3dc/0x670 net/netlink/af_netlink.c:708
 __sock_create+0x32e/0x800 net/socket.c:1571
 sock_create net/socket.c:1622 [inline]
 __sys_socket_create net/socket.c:1659 [inline]
 __sys_socket+0x14f/0x260 net/socket.c:1706
 __do_sys_socket net/socket.c:1720 [inline]
 __se_sys_socket net/socket.c:1718 [inline]
 __ia32_sys_socket+0x72/0xb0 net/socket.c:1718
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x75/0x120 arch/x86/entry/common.c:386
 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
page last free pid 30994 tgid 30993 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1141 [inline]
 free_unref_page_prepare+0x527/0xb10 mm/page_alloc.c:2347
 free_unref_page+0x33/0x3c0 mm/page_alloc.c:2487
 __folio_put_large mm/swap.c:132 [inline]
 __folio_put+0x210/0x290 mm/swap.c:140
 bpf_check+0x1c42/0xb970 kernel/bpf/verifier.c:21433
 bpf_prog_load+0xe3f/0x2670 kernel/bpf/syscall.c:2895
 __sys_bpf+0x9cb/0x58b0 kernel/bpf/syscall.c:5660
 __do_sys_bpf kernel/bpf/syscall.c:5767 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5765 [inline]
 __ia32_sys_bpf+0x76/0xe0 kernel/bpf/syscall.c:5765
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x75/0x120 arch/x86/entry/common.c:386
 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
 entry_SYSENTER_compat_after_hwframe+0x84/0x8e

Memory state around the buggy address:
 ffff8880110f1280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880110f1300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880110f1380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff8880110f1400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880110f1480: 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/05/13 09:52 upstream a38297e3fb01 9026e142 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: slab-use-after-free Read in addr_handler
* Struck through repros no longer work on HEAD.