syzbot


KASAN: invalid-free in raw_release

Status: upstream: reported on 2024/08/28 08:13
Reported-by: syzbot+10a3b0b839849e772d1a@syzkaller.appspotmail.com
First crash: 20d, last: 20d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: invalid-free in raw_release usb 9 4d09h 31d 0/28 upstream: reported on 2024/08/16 21:20

Sample crash report:
==================================================================
BUG: KASAN: double-free in dev_free drivers/usb/gadget/legacy/raw_gadget.c:224 [inline]
BUG: KASAN: double-free in kref_put+0x4a4/0x7c0 include/linux/kref.h:65
Free of addr ffff888058682120 by task syz.4.2560/13838

CPU: 1 PID: 13838 Comm: syz.4.2560 Not tainted 6.1.106-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_invalid_free+0x10c/0x130 mm/kasan/report.c:460
 ____kasan_slab_free+0xfb/0x120
 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
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:224 [inline]
 kref_put+0x4a4/0x7c0 include/linux/kref.h:65
 raw_release+0x134/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:426
 __fput+0x3f6/0x8d0 fs/file_table.c:320
 task_work_run+0x246/0x300 kernel/task_work.c:203
 exit_task_work include/linux/task_work.h:39 [inline]
 do_exit+0xa73/0x26a0 kernel/exit.c:871
 do_group_exit+0x202/0x2b0 kernel/exit.c:1021
 get_signal+0x16f7/0x17d0 kernel/signal.c:2870
 arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:871
 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:174
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f06c8379a7b
Code: Unable to access opcode bytes at 0x7f06c8379a51.
RSP: 002b:00007f06c911af10 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: fffffffffffffff0 RBX: 0000000000000006 RCX: 00007f06c8379a7b
RDX: 0000000000000000 RSI: 0000000000005501 RDI: 0000000000000006
RBP: 00007f06c911bfe0 R08: 0000000000000000 R09: 00342e6364755f79
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f06c911afb0 R14: 00000000200000c0 R15: 00007f06c86424c0
 </TASK>

Allocated by task 13838:
 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:955 [inline]
 __kmalloc_node_track_caller+0xb1/0x220 mm/slab_common.c:975
 memdup_user+0x27/0xb0 mm/util.c:174
 raw_ioctl_ep_enable drivers/usb/gadget/legacy/raw_gadget.c:801 [inline]
 raw_ioctl+0x64b/0x3bf0 drivers/usb/gadget/legacy/raw_gadget.c:1273
 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 13820:
 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
 dev_free drivers/usb/gadget/legacy/raw_gadget.c:224 [inline]
 kref_put+0x4a4/0x7c0 include/linux/kref.h:65
 raw_release+0x134/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:426
 __fput+0x3f6/0x8d0 fs/file_table.c:320
 task_work_run+0x246/0x300 kernel/task_work.c:203
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff888058682120
 which belongs to the cache kmalloc-16 of size 16
The buggy address is located 0 bytes inside of
 16-byte region [ffff888058682120, ffff888058682130)

The buggy address belongs to the physical page:
page:ffffea000161a080 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x58682
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 0000000000000000 dead000000000001 ffff8880128413c0
raw: 0000000000000000 0000000000800080 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 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 3635, tgid 3635 (syz-executor), ts 59565497453, free_ts 59565308338
 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_pages_node include/linux/gfp.h:237 [inline]
 alloc_slab_page+0x59/0x150 mm/slub.c:1796
 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:954 [inline]
 __kmalloc_node+0xa2/0x230 mm/slab_common.c:962
 kmalloc_node include/linux/slab.h:582 [inline]
 kvmalloc_node+0x6e/0x180 mm/util.c:581
 xt_jumpstack_alloc net/netfilter/x_tables.c:1354 [inline]
 xt_replace_table+0x177/0x790 net/netfilter/x_tables.c:1393
 xt_register_table+0x28f/0x750 net/netfilter/x_tables.c:1479
 ipt_register_table+0x167/0x7a0 net/ipv4/netfilter/ip_tables.c:1750
 iptable_nat_table_init+0x3f/0x2d0 net/ipv4/netfilter/iptable_nat.c:115
 xt_find_table_lock+0x2cc/0x3a0 net/netfilter/x_tables.c:1259
 xt_request_find_table_lock+0x22/0xf0 net/netfilter/x_tables.c:1284
 get_info net/ipv4/netfilter/ip_tables.c:965 [inline]
 do_ipt_get_ctl+0x872/0x1890 net/ipv4/netfilter/ip_tables.c:1661
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
 __vunmap+0x834/0x9a0 mm/vmalloc.c:2717
 copy_entries_to_user net/ipv4/netfilter/ip_tables.c:868 [inline]
 get_entries net/ipv4/netfilter/ip_tables.c:1024 [inline]
 do_ipt_get_ctl+0x11d8/0x1890 net/ipv4/netfilter/ip_tables.c:1670
 nf_getsockopt+0x28e/0x2b0 net/netfilter/nf_sockopt.c:116
 ip_getsockopt+0x21a/0x2d0 net/ipv4/ip_sockglue.c:1826
 tcp_getsockopt+0x15c/0x1c0 net/ipv4/tcp.c:4450
 __sys_getsockopt+0x2b2/0x5d0 net/socket.c:2327
 __do_sys_getsockopt net/socket.c:2342 [inline]
 __se_sys_getsockopt net/socket.c:2339 [inline]
 __x64_sys_getsockopt+0xb1/0xc0 net/socket.c:2339
 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:
 ffff888058682000: fa fb fc fc fa fb fc fc 00 04 fc fc 00 01 fc fc
 ffff888058682080: 00 06 fc fc 00 07 fc fc fa fb fc fc 00 00 fc fc
>ffff888058682100: 00 00 fc fc fa fb fc fc fa fb fc fc 00 05 fc fc
                               ^
 ffff888058682180: 00 05 fc fc fa fb fc fc 00 01 fc fc fa fb fc fc
 ffff888058682200: 00 00 fc fc 00 03 fc fc 00 01 fc fc 00 00 fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/28 08:13 linux-6.1.y ee5e09825b81 6c853ff9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: invalid-free in raw_release
* Struck through repros no longer work on HEAD.