syzbot


KASAN: slab-use-after-free Write in recv_work (3)

Status: moderation: reported on 2025/10/12 06:44
Subsystems: nbd
[Documentation on labels]
Reported-by: syzbot+1824722b5f062ae66812@syzkaller.appspotmail.com
First crash: 12d, last: 12d
Similar bugs (4)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Write in recv_work (2) nbd 24 C 16 64d 161d 29/29 fixed on 2025/09/04 16:57
upstream KASAN: slab-use-after-free Write in recv_work nbd 24 10 171d 311d 28/29 fixed on 2025/05/06 15:33
upstream KASAN: use-after-free Read in recv_work nbd 19 1 1725d 1721d 0/29 auto-closed as invalid on 2021/03/30 16:37
upstream KASAN: use-after-free Read in recv_work (2) nbd 19 1 1362d 1357d 0/29 auto-closed as invalid on 2022/05/27 07:10

Sample crash report:
Bluetooth: hci0: command tx timeout
==================================================================
BUG: KASAN: slab-use-after-free in instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
BUG: KASAN: slab-use-after-free in atomic_dec include/linux/atomic/atomic-instrumented.h:592 [inline]
BUG: KASAN: slab-use-after-free in recv_work+0x215e/0x24f0 drivers/block/nbd.c:1022
Write of size 4 at addr ffff88800b5c7a78 by task kworker/u5:2/5308

CPU: 0 UID: 0 PID: 5308 Comm: kworker/u5:2 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Workqueue: nbd0-recv recv_work
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xca/0x240 mm/kasan/report.c:482
 kasan_report+0x118/0x150 mm/kasan/report.c:595
 check_region_inline mm/kasan/generic.c:-1 [inline]
 kasan_check_range+0x2b0/0x2c0 mm/kasan/generic.c:200
 instrument_atomic_read_write include/linux/instrumented.h:96 [inline]
 atomic_dec include/linux/atomic/atomic-instrumented.h:592 [inline]
 recv_work+0x215e/0x24f0 drivers/block/nbd.c:1022
 process_one_work kernel/workqueue.c:3263 [inline]
 process_scheduled_works+0xae1/0x17b0 kernel/workqueue.c:3346
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3427
 kthread+0x711/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x4bc/0x870 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
 </TASK>

Allocated by task 5331:
 kasan_save_stack mm/kasan/common.c:56 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:77
 poison_kmalloc_redzone mm/kasan/common.c:400 [inline]
 __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:417
 kasan_kmalloc include/linux/kasan.h:262 [inline]
 __kmalloc_cache_noprof+0x3d5/0x6f0 mm/slub.c:5724
 kmalloc_noprof include/linux/slab.h:957 [inline]
 kzalloc_noprof include/linux/slab.h:1094 [inline]
 nbd_alloc_and_init_config+0x88/0x260 drivers/block/nbd.c:1677
 nbd_genl_connect+0x9d7/0x18f0 drivers/block/nbd.c:2139
 genl_family_rcv_msg_doit+0x215/0x300 net/netlink/genetlink.c:1115
 genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline]
 genl_rcv_msg+0x60e/0x790 net/netlink/genetlink.c:1210
 netlink_rcv_skb+0x208/0x470 net/netlink/af_netlink.c:2552
 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219
 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline]
 netlink_unicast+0x82f/0x9e0 net/netlink/af_netlink.c:1346
 netlink_sendmsg+0x805/0xb30 net/netlink/af_netlink.c:1896
 sock_sendmsg_nosec net/socket.c:727 [inline]
 __sock_sendmsg+0x21c/0x270 net/socket.c:742
 ____sys_sendmsg+0x505/0x830 net/socket.c:2630
 ___sys_sendmsg+0x21f/0x2a0 net/socket.c:2684
 __sys_sendmsg net/socket.c:2716 [inline]
 __do_sys_sendmsg net/socket.c:2721 [inline]
 __se_sys_sendmsg net/socket.c:2719 [inline]
 __x64_sys_sendmsg+0x19b/0x260 net/socket.c:2719
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 5308:
 kasan_save_stack mm/kasan/common.c:56 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:77
 __kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:587
 kasan_save_free_info mm/kasan/kasan.h:406 [inline]
 poison_slab_object mm/kasan/common.c:252 [inline]
 __kasan_slab_free+0x5c/0x80 mm/kasan/common.c:284
 kasan_slab_free include/linux/kasan.h:234 [inline]
 slab_free_hook mm/slub.c:2514 [inline]
 slab_free mm/slub.c:6566 [inline]
 kfree+0x19a/0x6d0 mm/slub.c:6773
 nbd_config_put+0x642/0x790 drivers/block/nbd.c:1457
 recv_work+0x2148/0x24f0 drivers/block/nbd.c:1021
 process_one_work kernel/workqueue.c:3263 [inline]
 process_scheduled_works+0xae1/0x17b0 kernel/workqueue.c:3346
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3427
 kthread+0x711/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x4bc/0x870 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

The buggy address belongs to the object at ffff88800b5c7a00
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 120 bytes inside of
 freed 256-byte region [ffff88800b5c7a00, ffff88800b5c7b00)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0xb5c7
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000000 ffff88801a441b40 dead000000000100 dead000000000122
raw: 0000000000000000 0000000080080008 00000000f5000000 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 0x252800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 4719, tgid 4719 (udevd), ts 84765823033, free_ts 42600834818
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1850
 prep_new_page mm/page_alloc.c:1858 [inline]
 get_page_from_freelist+0x2365/0x2440 mm/page_alloc.c:3884
 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:5183
 alloc_slab_page mm/slub.c:3032 [inline]
 allocate_slab+0x71/0x3a0 mm/slub.c:3203
 new_slab mm/slub.c:3257 [inline]
 ___slab_alloc+0xe94/0x1920 mm/slub.c:4627
 __slab_alloc+0x65/0x100 mm/slub.c:4746
 __slab_alloc_node mm/slub.c:4822 [inline]
 slab_alloc_node mm/slub.c:5233 [inline]
 __do_kmalloc_node mm/slub.c:5602 [inline]
 __kmalloc_node_noprof+0x5cc/0x800 mm/slub.c:5609
 kmalloc_array_node_noprof include/linux/slab.h:1075 [inline]
 alloc_slab_obj_exts mm/slub.c:2115 [inline]
 account_slab mm/slub.c:3157 [inline]
 allocate_slab+0x179/0x3a0 mm/slub.c:3222
 new_slab mm/slub.c:3257 [inline]
 ___slab_alloc+0xe94/0x1920 mm/slub.c:4627
 __slab_alloc+0x65/0x100 mm/slub.c:4746
 __slab_alloc_node mm/slub.c:4822 [inline]
 slab_alloc_node mm/slub.c:5233 [inline]
 kmem_cache_alloc_lru_noprof+0x3ef/0x6d0 mm/slub.c:5264
 alloc_inode+0xb8/0x1b0 fs/inode.c:348
 iget_locked+0x106/0x580 fs/inode.c:1445
 kernfs_get_inode+0x4f/0x780 fs/kernfs/inode.c:253
 kernfs_iop_lookup+0x1f6/0x320 fs/kernfs/dir.c:1236
 __lookup_slow+0x294/0x3d0 fs/namei.c:1816
page last free pid 29 tgid 29 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1394 [inline]
 __free_frozen_pages+0xbc4/0xd30 mm/page_alloc.c:2906
 __folio_put+0x21b/0x2c0 mm/swap.c:112
 migrate_folio_move mm/migrate.c:1404 [inline]
 migrate_folios_move mm/migrate.c:1713 [inline]
 migrate_pages_batch+0x22a3/0x35e0 mm/migrate.c:1969
 migrate_pages_sync mm/migrate.c:1999 [inline]
 migrate_pages+0x1bcc/0x2930 mm/migrate.c:2108
 compact_zone+0x23e1/0x4ab0 mm/compaction.c:2647
 compact_node+0x1d2/0x280 mm/compaction.c:2916
 kcompactd+0xbc8/0x1290 mm/compaction.c:3214
 kthread+0x711/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x4bc/0x870 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

Memory state around the buggy address:
 ffff88800b5c7900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88800b5c7980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88800b5c7a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff88800b5c7a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88800b5c7b00: 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
2025/10/08 06:38 upstream 0d97f2067c16 7e2882b3 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Write in recv_work
* Struck through repros no longer work on HEAD.