================================================================== 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 ffff88807b0397e0 by task syz.2.1691/9624 CPU: 0 PID: 9624 Comm: syz.2.1691 Not tainted 6.1.112-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: __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 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 RIP: 0033:0x7fa88457dff9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007ffc8e786be8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4 RAX: 0000000000000000 RBX: 00007fa884737a80 RCX: 00007fa88457dff9 RDX: 0000000000000000 RSI: 000000000000001e RDI: 0000000000000003 RBP: 00007fa884737a80 R08: 00007fa884722000 R09: 00007ffc8e786edf R10: 00000000003ffbc8 R11: 0000000000000246 R12: 000000000008d963 R13: 00007ffc8e786cf0 R14: 0000000000000032 R15: ffffffffffffffff Allocated by task 9627: 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:936 [inline] __kmalloc_node_track_caller+0xb1/0x220 mm/slab_common.c:956 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 9625: 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 ffff88807b0397e0 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 0 bytes inside of 16-byte region [ffff88807b0397e0, ffff88807b0397f0) The buggy address belongs to the physical page: page:ffffea0001ec0e40 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff88807b039fa0 pfn:0x7b039 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 dead000000000100 dead000000000122 ffff888017c413c0 raw: ffff88807b039fa0 0000000080800074 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 3645, tgid 3645 (syz-executor), ts 76413903428, free_ts 69495061586 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:935 [inline] __kmalloc_node+0xa2/0x230 mm/slab_common.c:943 kmalloc_node include/linux/slab.h:583 [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 __do_replace+0x1a4/0xa70 net/ipv6/netfilter/ip6_tables.c:1083 do_replace net/ipv6/netfilter/ip6_tables.c:1160 [inline] do_ip6t_set_ctl+0xef2/0x1250 net/ipv6/netfilter/ip6_tables.c:1646 nf_setsockopt+0x28a/0x2b0 net/netfilter/nf_sockopt.c:101 __sys_setsockopt+0x57e/0xa00 net/socket.c:2283 __do_sys_setsockopt net/socket.c:2294 [inline] __se_sys_setsockopt net/socket.c:2291 [inline] __x64_sys_setsockopt+0xb1/0xc0 net/socket.c:2291 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: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 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x156/0x170 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:201 [inline] slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737 slab_alloc_node mm/slub.c:3398 [inline] __kmem_cache_alloc_node+0x137/0x260 mm/slub.c:3437 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026 kmalloc include/linux/slab.h:557 [inline] kzalloc include/linux/slab.h:693 [inline] kobject_uevent_env+0x281/0x8c0 lib/kobject_uevent.c:539 __kobject_del+0xd3/0x310 lib/kobject.c:593 kobject_cleanup lib/kobject.c:672 [inline] kobject_release lib/kobject.c:712 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x238/0x460 lib/kobject.c:729 netdev_queue_update_kobjects+0x3d6/0x480 net/core/net-sysfs.c:1731 netif_set_real_num_tx_queues+0x18c/0x910 net/core/dev.c:2920 veth_init_queues drivers/net/veth.c:1670 [inline] veth_newlink+0x8cc/0xc70 drivers/net/veth.c:1787 rtnl_newlink_create net/core/rtnetlink.c:3390 [inline] __rtnl_newlink net/core/rtnetlink.c:3610 [inline] rtnl_newlink+0x14e3/0x2050 net/core/rtnetlink.c:3623 rtnetlink_rcv_msg+0x818/0xff0 net/core/rtnetlink.c:6121 Memory state around the buggy address: ffff88807b039680: fb fb fc fc fb fb fc fc fb fb fc fc fb fb fc fc ffff88807b039700: fb fb fc fc fb fb fc fc 00 00 fc fc 00 00 fc fc >ffff88807b039780: fb fb fc fc fb fb fc fc fb fb fc fc fa fb fc fc ^ ffff88807b039800: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ffff88807b039880: fb fb fc fc fb fb fc fc fa fb fc fc fa fb fc fc ==================================================================