================================================================== BUG: KASAN: use-after-free in driver_find drivers/base/driver.c:293 [inline] BUG: KASAN: use-after-free in driver_register+0x352/0x3a0 drivers/base/driver.c:233 Read of size 8 at addr ffff88811941d4c8 by task syz-executor.1/1604 CPU: 0 PID: 1604 Comm: syz-executor.1 Not tainted 5.19.0-rc3-syzkaller-00071-g105f3fd2f789 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xeb/0x495 mm/kasan/report.c:313 print_report mm/kasan/report.c:429 [inline] kasan_report.cold+0xf4/0x1c6 mm/kasan/report.c:491 driver_find drivers/base/driver.c:293 [inline] driver_register+0x352/0x3a0 drivers/base/driver.c:233 usb_gadget_register_driver_owner+0xfb/0x1e0 drivers/usb/gadget/udc/core.c:1558 raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:515 [inline] raw_ioctl+0x188d/0x2730 drivers/usb/gadget/legacy/raw_gadget.c:1222 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 RIP: 0033:0x7f828953eec7 Code: 3c 1c 48 f7 d8 49 39 c4 72 b8 e8 34 54 02 00 85 c0 78 bd 48 83 c4 08 4c 89 e0 5b 41 5c c3 0f 1f 44 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f8288c71098 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f8288c72110 RCX: 00007f828953eec7 RDX: 0000000000000000 RSI: 0000000000005501 RDI: 0000000000000003 RBP: 0000000000000003 R08: 000000000000ffff R09: 000000000000000b R10: 00007f8288c71140 R11: 0000000000000246 R12: 0000000000000000 R13: 00000000200002c0 R14: 0000000020000980 R15: 00000000000010d0 Allocated by task 1557: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc mm/kasan/common.c:515 [inline] __kasan_kmalloc+0x81/0xa0 mm/kasan/common.c:524 kmalloc include/linux/slab.h:600 [inline] kzalloc include/linux/slab.h:733 [inline] bus_add_driver+0xd4/0x640 drivers/base/bus.c:602 driver_register+0x220/0x3a0 drivers/base/driver.c:240 usb_gadget_register_driver_owner+0xfb/0x1e0 drivers/usb/gadget/udc/core.c:1558 raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:515 [inline] raw_ioctl+0x188d/0x2730 drivers/usb/gadget/legacy/raw_gadget.c:1222 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Freed by task 1604: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x10f/0x190 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:200 [inline] slab_free_hook mm/slub.c:1727 [inline] slab_free_freelist_hook mm/slub.c:1753 [inline] slab_free mm/slub.c:3507 [inline] kfree+0xc1/0x4f0 mm/slub.c:4555 kobject_cleanup lib/kobject.c:673 [inline] kobject_release lib/kobject.c:704 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x1c8/0x540 lib/kobject.c:721 driver_find drivers/base/driver.c:291 [inline] driver_register+0x1e3/0x3a0 drivers/base/driver.c:233 usb_gadget_register_driver_owner+0xfb/0x1e0 drivers/usb/gadget/udc/core.c:1558 raw_ioctl_run drivers/usb/gadget/legacy/raw_gadget.c:515 [inline] raw_ioctl+0x188d/0x2730 drivers/usb/gadget/legacy/raw_gadget.c:1222 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0x9f/0xb0 mm/kasan/generic.c:348 kvfree_call_rcu+0x74/0x990 kernel/rcu/tree.c:3647 drop_sysctl_table+0x3c0/0x4e0 fs/proc/proc_sysctl.c:1716 unregister_sysctl_table fs/proc/proc_sysctl.c:1754 [inline] unregister_sysctl_table+0xc0/0x190 fs/proc/proc_sysctl.c:1729 neigh_sysctl_unregister+0x5b/0x80 net/core/neighbour.c:3812 devinet_sysctl_unregister net/ipv4/devinet.c:2638 [inline] inetdev_destroy net/ipv4/devinet.c:327 [inline] inetdev_event+0xd01/0x15d0 net/ipv4/devinet.c:1602 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1943 call_netdevice_notifiers_extack net/core/dev.c:1981 [inline] call_netdevice_notifiers net/core/dev.c:1995 [inline] unregister_netdevice_many+0x925/0x1830 net/core/dev.c:10834 unregister_netdevice_queue net/core/dev.c:10766 [inline] unregister_netdevice_queue+0x2dd/0x3c0 net/core/dev.c:10756 unregister_netdevice include/linux/netdevice.h:3018 [inline] unregister_netdev+0x18/0x20 net/core/dev.c:10893 r871xu_dev_remove+0x285/0x470 drivers/staging/rtl8712/usb_intf.c:597 usb_unbind_interface+0x1d8/0x8e0 drivers/usb/core/driver.c:458 device_remove drivers/base/dd.c:545 [inline] device_remove+0x11f/0x170 drivers/base/dd.c:537 __device_release_driver drivers/base/dd.c:1222 [inline] device_release_driver_internal+0x4a1/0x700 drivers/base/dd.c:1248 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529 device_del+0x4f3/0xc80 drivers/base/core.c:3604 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419 usb_disconnect.cold+0x278/0x6ec drivers/usb/core/hub.c:2228 hub_port_connect drivers/usb/core/hub.c:5190 [inline] hub_port_connect_change drivers/usb/core/hub.c:5490 [inline] port_event drivers/usb/core/hub.c:5646 [inline] hub_event+0x1e83/0x4690 drivers/usb/core/hub.c:5728 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 worker_thread+0x665/0x1080 kernel/workqueue.c:2436 kthread+0x2ef/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302 Second to last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0x9f/0xb0 mm/kasan/generic.c:348 kvfree_call_rcu+0x74/0x990 kernel/rcu/tree.c:3647 drop_sysctl_table+0x3c0/0x4e0 fs/proc/proc_sysctl.c:1716 unregister_sysctl_table fs/proc/proc_sysctl.c:1754 [inline] unregister_sysctl_table+0xc0/0x190 fs/proc/proc_sysctl.c:1729 neigh_sysctl_unregister+0x5b/0x80 net/core/neighbour.c:3812 devinet_sysctl_unregister net/ipv4/devinet.c:2638 [inline] inetdev_destroy net/ipv4/devinet.c:327 [inline] inetdev_event+0xd01/0x15d0 net/ipv4/devinet.c:1602 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1943 call_netdevice_notifiers_extack net/core/dev.c:1981 [inline] call_netdevice_notifiers net/core/dev.c:1995 [inline] unregister_netdevice_many+0x925/0x1830 net/core/dev.c:10834 unregister_netdevice_queue net/core/dev.c:10766 [inline] unregister_netdevice_queue+0x2dd/0x3c0 net/core/dev.c:10756 unregister_netdevice include/linux/netdevice.h:3018 [inline] unregister_netdev+0x18/0x20 net/core/dev.c:10893 r871xu_dev_remove+0x285/0x470 drivers/staging/rtl8712/usb_intf.c:597 usb_unbind_interface+0x1d8/0x8e0 drivers/usb/core/driver.c:458 device_remove drivers/base/dd.c:545 [inline] device_remove+0x11f/0x170 drivers/base/dd.c:537 __device_release_driver drivers/base/dd.c:1222 [inline] device_release_driver_internal+0x4a1/0x700 drivers/base/dd.c:1248 bus_remove_device+0x2eb/0x5a0 drivers/base/bus.c:529 device_del+0x4f3/0xc80 drivers/base/core.c:3604 usb_disable_device+0x35b/0x7b0 drivers/usb/core/message.c:1419 usb_disconnect.cold+0x278/0x6ec drivers/usb/core/hub.c:2228 hub_port_connect drivers/usb/core/hub.c:5190 [inline] hub_port_connect_change drivers/usb/core/hub.c:5490 [inline] port_event drivers/usb/core/hub.c:5646 [inline] hub_event+0x1e83/0x4690 drivers/usb/core/hub.c:5728 process_one_work+0x996/0x1610 kernel/workqueue.c:2289 process_scheduled_works kernel/workqueue.c:2352 [inline] worker_thread+0x854/0x1080 kernel/workqueue.c:2438 kthread+0x2ef/0x3a0 kernel/kthread.c:376 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:302 The buggy address belongs to the object at ffff88811941d400 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 200 bytes inside of 256-byte region [ffff88811941d400, ffff88811941d500) The buggy address belongs to the physical page: page:ffffea0004650700 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11941c head:ffffea0004650700 order:1 compound_mapcount:0 compound_pincount:0 flags: 0x200000000010200(slab|head|node=0|zone=2) raw: 0200000000010200 dead000000000100 dead000000000122 ffff888100041b40 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 1302, tgid 1302 (syz-executor.0), ts 38040678169, free_ts 37991303356 prep_new_page mm/page_alloc.c:2456 [inline] get_page_from_freelist+0x138c/0x27a0 mm/page_alloc.c:4198 __alloc_pages+0x1c7/0x510 mm/page_alloc.c:5426 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2272 alloc_slab_page mm/slub.c:1797 [inline] allocate_slab+0x26c/0x3c0 mm/slub.c:1942 new_slab mm/slub.c:2002 [inline] ___slab_alloc+0x995/0xe10 mm/slub.c:3002 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3089 slab_alloc_node mm/slub.c:3180 [inline] slab_alloc mm/slub.c:3222 [inline] __kmalloc+0x306/0x320 mm/slub.c:4413 kmalloc include/linux/slab.h:605 [inline] kzalloc include/linux/slab.h:733 [inline] fib_create_info+0xdbe/0x49f0 net/ipv4/fib_semantics.c:1448 fib_table_insert+0x19a/0x1bd0 net/ipv4/fib_trie.c:1233 fib_magic.isra.0+0x299/0x2f0 net/ipv4/fib_frontend.c:1098 fib_add_ifaddr+0x1d0/0x710 net/ipv4/fib_frontend.c:1120 fib_inetaddr_event+0x162/0x2a0 net/ipv4/fib_frontend.c:1434 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87 blocking_notifier_call_chain kernel/notifier.c:382 [inline] blocking_notifier_call_chain+0x67/0x90 kernel/notifier.c:370 __inet_insert_ifa+0x919/0xbd0 net/ipv4/devinet.c:554 inet_rtm_newaddr+0x54d/0x980 net/ipv4/devinet.c:960 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1371 [inline] free_pcp_prepare+0x537/0xb80 mm/page_alloc.c:1421 free_unref_page_prepare mm/page_alloc.c:3343 [inline] free_unref_page+0x19/0x5a0 mm/page_alloc.c:3438 qlink_free mm/kasan/quarantine.c:168 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:187 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:294 __kasan_slab_alloc+0x78/0x80 mm/kasan/common.c:446 kasan_slab_alloc include/linux/kasan.h:224 [inline] slab_post_alloc_hook mm/slab.h:750 [inline] slab_alloc_node mm/slub.c:3214 [inline] slab_alloc mm/slub.c:3222 [inline] __kmem_cache_alloc_lru mm/slub.c:3229 [inline] kmem_cache_alloc+0x241/0x480 mm/slub.c:3239 getname_flags.part.0+0x50/0x4f0 fs/namei.c:139 getname_flags include/linux/audit.h:323 [inline] getname+0x8e/0xd0 fs/namei.c:218 do_sys_openat2+0xf5/0x4c0 fs/open.c:1272 do_sys_open fs/open.c:1294 [inline] __do_sys_openat fs/open.c:1310 [inline] __se_sys_openat fs/open.c:1305 [inline] __x64_sys_openat+0x13f/0x1f0 fs/open.c:1305 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x46/0xb0 Memory state around the buggy address: ffff88811941d380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88811941d400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88811941d480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88811941d500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88811941d580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================