================================================================== BUG: KASAN: double-free in dev_free drivers/usb/gadget/legacy/raw_gadget.c:225 [inline] BUG: KASAN: double-free in kref_put+0x4ab/0x7c0 include/linux/kref.h:65 Free of addr ffff888029261a80 by task syz.3.2157/17687 CPU: 1 UID: 0 PID: 17687 Comm: syz.3.2157 Not tainted 6.11.0-rc6-syzkaller-00326-gd1f2d51b711a #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024 Call Trace: __dump_stack lib/dump_stack.c:93 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report_invalid_free+0x11a/0x140 mm/kasan/report.c:563 poison_slab_object+0xf4/0x150 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2256 [inline] slab_free mm/slub.c:4477 [inline] kfree+0x149/0x360 mm/slub.c:4598 dev_free drivers/usb/gadget/legacy/raw_gadget.c:225 [inline] kref_put+0x4ab/0x7c0 include/linux/kref.h:65 raw_release+0x138/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:473 __fput+0x24a/0x8a0 fs/file_table.c:422 __do_sys_close fs/open.c:1566 [inline] __se_sys_close fs/open.c:1551 [inline] __ia32_sys_close+0x7f/0x110 fs/open.c:1551 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0xb4/0x110 arch/x86/entry/common.c:386 do_fast_syscall_32+0x34/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf741d579 Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 RSP: 002b:00000000f56f5530 EFLAGS: 00000206 ORIG_RAX: 0000000000000006 RAX: ffffffffffffffda RBX: 0000000000000006 RCX: 00000000f56f5b40 RDX: 0000000000000000 RSI: 00000000f740fff4 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Allocated by task 17699: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:370 [inline] __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slub.c:4162 [inline] __kmalloc_node_track_caller_noprof+0x225/0x440 mm/slub.c:4181 memdup_user+0x2b/0xc0 mm/util.c:226 raw_ioctl_ep_enable drivers/usb/gadget/legacy/raw_gadget.c:847 [inline] raw_ioctl+0xd0f/0x3cd0 drivers/usb/gadget/legacy/raw_gadget.c:1318 __do_compat_sys_ioctl fs/ioctl.c:1007 [inline] __se_compat_sys_ioctl+0x51c/0xca0 fs/ioctl.c:950 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0xb4/0x110 arch/x86/entry/common.c:386 do_fast_syscall_32+0x34/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Freed by task 17687: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3f/0x80 mm/kasan/common.c:68 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256 kasan_slab_free include/linux/kasan.h:184 [inline] slab_free_hook mm/slub.c:2256 [inline] slab_free mm/slub.c:4477 [inline] kfree+0x149/0x360 mm/slub.c:4598 dev_free drivers/usb/gadget/legacy/raw_gadget.c:225 [inline] kref_put+0x4ab/0x7c0 include/linux/kref.h:65 raw_release+0x138/0x1e0 drivers/usb/gadget/legacy/raw_gadget.c:473 __fput+0x24a/0x8a0 fs/file_table.c:422 __do_sys_close fs/open.c:1566 [inline] __se_sys_close fs/open.c:1551 [inline] __ia32_sys_close+0x7f/0x110 fs/open.c:1551 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0xb4/0x110 arch/x86/entry/common.c:386 do_fast_syscall_32+0x34/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e The buggy address belongs to the object at ffff888029261a80 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 0 bytes inside of 16-byte region [ffff888029261a80, ffff888029261a90) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x29261 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: 0xfdffffff(slab) raw: 00fff00000000000 ffff88801ac41640 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000800080 00000001fdffffff 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 0x352800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 14166, tgid 14166 (syz-executor), ts 924419807140, free_ts 924419384848 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1500 prep_new_page mm/page_alloc.c:1508 [inline] get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3446 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4702 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline] alloc_pages_node_noprof include/linux/gfp.h:296 [inline] alloc_slab_page+0x5f/0x120 mm/slub.c:2325 allocate_slab+0x5a/0x2f0 mm/slub.c:2488 new_slab mm/slub.c:2541 [inline] ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3727 __slab_alloc+0x58/0xa0 mm/slub.c:3817 __slab_alloc_node mm/slub.c:3870 [inline] slab_alloc_node mm/slub.c:4029 [inline] __do_kmalloc_node mm/slub.c:4161 [inline] __kmalloc_node_noprof+0x286/0x440 mm/slub.c:4168 __kvmalloc_node_noprof+0x72/0x190 mm/util.c:650 xt_jumpstack_alloc net/netfilter/x_tables.c:1355 [inline] xt_replace_table+0x1a2/0x780 net/netfilter/x_tables.c:1394 __do_replace+0x1ae/0xa50 net/ipv6/netfilter/ip6_tables.c:1081 compat_do_replace net/ipv6/netfilter/ip6_tables.c:1538 [inline] do_ip6t_set_ctl+0xd28/0x1270 net/ipv6/netfilter/ip6_tables.c:1641 nf_setsockopt+0x295/0x2c0 net/netfilter/nf_sockopt.c:101 do_sock_setsockopt+0x3af/0x720 net/socket.c:2324 __sys_setsockopt+0x1ae/0x250 net/socket.c:2347 __do_compat_sys_socketcall net/compat.c:491 [inline] __se_compat_sys_socketcall+0x85a/0x1430 net/compat.c:423 page last free pid 14166 tgid 14166 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1101 [inline] free_unref_page+0xd22/0xea0 mm/page_alloc.c:2619 vfree+0x186/0x2e0 mm/vmalloc.c:3367 compat_copy_entries_to_user+0x5b3/0x680 net/ipv6/netfilter/ip6_tables.c:1583 compat_get_entries net/ipv6/netfilter/ip6_tables.c:1613 [inline] do_ip6t_get_ctl+0xe48/0x1820 net/ipv6/netfilter/ip6_tables.c:1674 nf_getsockopt+0x299/0x2c0 net/netfilter/nf_sockopt.c:116 ipv6_getsockopt+0x263/0x380 net/ipv6/ipv6_sockglue.c:1493 tcp_getsockopt+0x163/0x1c0 net/ipv4/tcp.c:4409 do_sock_getsockopt+0x3c4/0x7e0 net/socket.c:2386 __sys_getsockopt+0x271/0x330 net/socket.c:2415 __do_compat_sys_socketcall net/compat.c:494 [inline] __se_compat_sys_socketcall+0x349/0x1430 net/compat.c:423 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0xb4/0x110 arch/x86/entry/common.c:386 do_fast_syscall_32+0x34/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e Memory state around the buggy address: ffff888029261980: 00 00 fc fc fa fb fc fc fa fb fc fc fa fb fc fc ffff888029261a00: 00 05 fc fc fa fb fc fc fa fb fc fc 00 01 fc fc >ffff888029261a80: fa fb fc fc fa fb fc fc fa fb fc fc 00 00 fc fc ^ ffff888029261b00: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ffff888029261b80: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ================================================================== ---------------- Code disassembly (best guess), 2 bytes skipped: 0: 10 06 adc %al,(%rsi) 2: 03 74 b4 01 add 0x1(%rsp,%rsi,4),%esi 6: 10 07 adc %al,(%rdi) 8: 03 74 b0 01 add 0x1(%rax,%rsi,4),%esi c: 10 08 adc %cl,(%rax) e: 03 74 d8 01 add 0x1(%rax,%rbx,8),%esi 1e: 00 51 52 add %dl,0x52(%rcx) 21: 55 push %rbp 22: 89 e5 mov %esp,%ebp 24: 0f 34 sysenter 26: cd 80 int $0x80 * 28: 5d pop %rbp <-- trapping instruction 29: 5a pop %rdx 2a: 59 pop %rcx 2b: c3 ret 2c: 90 nop 2d: 90 nop 2e: 90 nop 2f: 90 nop 30: 90 nop 31: 90 nop 32: 90 nop 33: 90 nop 34: 90 nop 35: 90 nop 36: 90 nop 37: 90 nop 38: 90 nop 39: 90 nop 3a: 90 nop 3b: 90 nop 3c: 90 nop 3d: 90 nop