================================================================== BUG: KASAN: use-after-free in ex_handler_refcount+0x164/0x1a0 arch/x86/mm/extable.c:49 Write of size 4 at addr ffff888099868978 by task syz-executor381/8062 CPU: 0 PID: 8062 Comm: syz-executor381 Not tainted 4.14.304-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x1b2/0x281 lib/dump_stack.c:58 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252 kasan_report_error.cold+0x8a/0x191 mm/kasan/report.c:351 kasan_report mm/kasan/report.c:409 [inline] __asan_report_store4_noabort+0x68/0x70 mm/kasan/report.c:434 ex_handler_refcount+0x164/0x1a0 arch/x86/mm/extable.c:49 fixup_exception+0x8a/0xd0 arch/x86/mm/extable.c:197 do_trap_no_signal arch/x86/kernel/traps.c:208 [inline] do_trap+0x61/0x250 arch/x86/kernel/traps.c:257 do_error_trap+0x132/0x2d0 arch/x86/kernel/traps.c:301 invalid_op+0x1b/0x40 arch/x86/entry/entry_64.S:967 RIP: 0010:flags_string.cold+0x2ef4/0x6c57 RSP: 0018:ffff88808caa7c98 EFLAGS: 00010297 RAX: ffff8880b4b84100 RBX: 00000000fffffffd RCX: ffff888099868978 RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffff888099868940 RBP: ffff888099868940 R08: ffffffff8b9df6f8 R09: 0000000000000000 R10: 0000000000000000 R11: ffff8880b4b84100 R12: ffffffff89855be0 R13: 0000000000000000 R14: ffff8880b2f76b28 R15: 0000000000008001 gadgetfs_kill_sb+0x2a/0x60 drivers/usb/gadget/legacy/inode.c:2085 deactivate_locked_super+0x6c/0xd0 fs/super.c:319 mount_single+0x126/0x150 fs/super.c:1208 mount_fs+0x92/0x2a0 fs/super.c:1237 vfs_kern_mount.part.0+0x5b/0x470 fs/namespace.c:1046 vfs_kern_mount fs/namespace.c:1036 [inline] do_new_mount fs/namespace.c:2572 [inline] do_mount+0xe65/0x2a30 fs/namespace.c:2905 SYSC_mount fs/namespace.c:3121 [inline] SyS_mount+0xa8/0x120 fs/namespace.c:3098 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 RIP: 0033:0x7ff0a120fe29 RSP: 002b:00007ffce36b8038 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00000000000f4240 RCX: 00007ff0a120fe29 RDX: 0000000020000480 RSI: 0000000020000440 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000001 R10: 0000000000008001 R11: 0000000000000246 R12: 0000000000007091 R13: 00007ffce36b804c R14: 00007ffce36b8060 R15: 00007ffce36b8050 Allocated by task 8064: save_stack mm/kasan/kasan.c:447 [inline] set_track mm/kasan/kasan.c:459 [inline] kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551 kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618 kmalloc include/linux/slab.h:488 [inline] kzalloc include/linux/slab.h:661 [inline] dev_new drivers/usb/gadget/legacy/inode.c:173 [inline] gadgetfs_fill_super+0x1de/0x440 drivers/usb/gadget/legacy/inode.c:2048 mount_single+0xe1/0x150 fs/super.c:1206 mount_fs+0x92/0x2a0 fs/super.c:1237 vfs_kern_mount.part.0+0x5b/0x470 fs/namespace.c:1046 vfs_kern_mount fs/namespace.c:1036 [inline] do_new_mount fs/namespace.c:2572 [inline] do_mount+0xe65/0x2a30 fs/namespace.c:2905 SYSC_mount fs/namespace.c:3121 [inline] SyS_mount+0xa8/0x120 fs/namespace.c:3098 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 Freed by task 8064: save_stack mm/kasan/kasan.c:447 [inline] set_track mm/kasan/kasan.c:459 [inline] kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524 __cache_free mm/slab.c:3496 [inline] kfree+0xc9/0x250 mm/slab.c:3815 put_dev+0x59/0x70 drivers/usb/gadget/legacy/inode.c:166 gadgetfs_kill_sb+0x2a/0x60 drivers/usb/gadget/legacy/inode.c:2085 deactivate_locked_super+0x6c/0xd0 fs/super.c:319 deactivate_super+0x7f/0xa0 fs/super.c:350 cleanup_mnt+0x186/0x2c0 fs/namespace.c:1183 task_work_run+0x11f/0x190 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:191 [inline] exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline] syscall_return_slowpath arch/x86/entry/common.c:270 [inline] do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297 entry_SYSCALL_64_after_hwframe+0x5e/0xd3 The buggy address belongs to the object at ffff888099868940 which belongs to the cache kmalloc-1024 of size 1024 The buggy address is located 56 bytes inside of 1024-byte region [ffff888099868940, ffff888099868d40) The buggy address belongs to the page: page:ffffea0002661a00 count:1 mapcount:0 mapping:ffff888099868040 index:0x0 compound_mapcount: 0 flags: 0xfff00000008100(slab|head) raw: 00fff00000008100 ffff888099868040 0000000000000000 0000000100000007 raw: ffffea0002cbb2a0 ffffea0002ca1c20 ffff88813fe74ac0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888099868800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888099868880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888099868900: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb ^ ffff888099868980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888099868a00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================