================================================================== 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 ffff88805743f480 by task syz.1.1044/6823 CPU: 0 PID: 6823 Comm: syz.1.1044 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 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:0x7fe258f7cc8a Code: Unable to access opcode bytes at 0x7fe258f7cc60. RSP: 002b:00007fe259cb1ff0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 00007fe259135f80 RCX: 00007fe258f7cc8a RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003 RBP: 00007fe258ff0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000003 R11: 0000000000000293 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fe259135f80 R15: 00007fff5f0090c8 Allocated by task 6847: 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 6823: 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 ffff88805743f480 which belongs to the cache kmalloc-16 of size 16 The buggy address is located 0 bytes inside of 16-byte region [ffff88805743f480, ffff88805743f490) The buggy address belongs to the physical page: page:ffffea00015d0fc0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5743f flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 dead000000000100 dead000000000122 ffff888017c413c0 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 3650, tgid 3650 (syz-executor), ts 71831818258, free_ts 71824312541 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/0xa60 net/ipv4/netfilter/ip_tables.c:1066 do_replace net/ipv4/netfilter/ip_tables.c:1143 [inline] do_ipt_set_ctl+0xee3/0x1230 net/ipv4/netfilter/ip_tables.c:1637 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 __vunmap+0x834/0x9a0 mm/vmalloc.c:2717 free_work+0x57/0x80 mm/vmalloc.c:97 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439 kthread+0x28d/0x320 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Memory state around the buggy address: ffff88805743f380: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ffff88805743f400: fa fb fc fc 00 03 fc fc fa fb fc fc fa fb fc fc >ffff88805743f480: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ^ ffff88805743f500: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ffff88805743f580: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc ==================================================================