bisecting cause commit starting from c11d28ab4a691736e30b49813fb801847bd44e83 building syzkaller on 9682898d6f14dd27f95c419d059fd867bb91b22b testing commit c11d28ab4a691736e30b49813fb801847bd44e83 with gcc (GCC) 8.1.0 kernel signature: 75de5707ba9f6d00b8152886ec8e7b3e8f226505e1a380b7fb87abe52aaec0bf all runs: crashed: KASAN: use-after-free Read in joydev_cleanup testing release v5.6 testing commit 7111951b8d4973bda27ff663f2cf18b663d15b48 with gcc (GCC) 8.1.0 kernel signature: 662b2864cf2124e975c084de2f57555b9fa5f1c1afc4cd33e03b3a2e1e0d3cd7 all runs: OK # git bisect start c11d28ab4a691736e30b49813fb801847bd44e83 7111951b8d4973bda27ff663f2cf18b663d15b48 Bisecting: 13326 revisions left to test after this (roughly 14 steps) [74cd3984f13381049627cfa260fd87e6fcd31add] media: imx: utils: Split find|enum_format into fourcc and mbus functions testing commit 74cd3984f13381049627cfa260fd87e6fcd31add with gcc (GCC) 8.1.0 kernel signature: 7379bb62f087c6e9275bdbb9619ea710e4f85902032b9c141f01d5f5fda68a70 all runs: OK # git bisect good 74cd3984f13381049627cfa260fd87e6fcd31add Bisecting: 6630 revisions left to test after this (roughly 13 steps) [8bf9e28a25c6bbff58513b8175620e096368ede4] Merge remote-tracking branch 'net-next/master' testing commit 8bf9e28a25c6bbff58513b8175620e096368ede4 with gcc (GCC) 8.1.0 kernel signature: cbee4f74f3e9133faa301c396373691e7ce1a8b9602d27cced51304ba6fd729c all runs: crashed: KASAN: use-after-free Read in joydev_cleanup # git bisect bad 8bf9e28a25c6bbff58513b8175620e096368ede4 Bisecting: 3347 revisions left to test after this (roughly 12 steps) [e0b0f9fd6d0a1f228f3c09958e25def4865454db] Merge remote-tracking branch 'sh/sh-next' testing commit e0b0f9fd6d0a1f228f3c09958e25def4865454db with gcc (GCC) 8.1.0 kernel signature: 66c88356d573bc582bfc679f998a40a14ac17f4fae7ffdab5e88cb8975025009 all runs: crashed: KASAN: use-after-free Read in joydev_cleanup # git bisect bad e0b0f9fd6d0a1f228f3c09958e25def4865454db Bisecting: 1671 revisions left to test after this (roughly 11 steps) [7e71515c910d8a1ce0a780982f41f921616a97d6] Merge remote-tracking branch 'drm-fixes/drm-fixes' testing commit 7e71515c910d8a1ce0a780982f41f921616a97d6 with gcc (GCC) 8.1.0 kernel signature: da6b81704c760f2ee1ed4a3092ab5f47a25dbf4096b7343ce646148f4a81cab8 all runs: crashed: KASAN: use-after-free Read in joydev_cleanup # git bisect bad 7e71515c910d8a1ce0a780982f41f921616a97d6 Bisecting: 837 revisions left to test after this (roughly 10 steps) [17e34526f0a8f81a214d1ee6f7d8ad2a9c9bae33] mm/vmscan: remove unnecessary argument description of isolate_lru_pages() testing commit 17e34526f0a8f81a214d1ee6f7d8ad2a9c9bae33 with gcc (GCC) 8.1.0 kernel signature: e51585b4cd2991eb2fedee6c943e7fb203fddec48a1fee992c56a46cacf8a2e0 all runs: OK # git bisect good 17e34526f0a8f81a214d1ee6f7d8ad2a9c9bae33 Bisecting: 419 revisions left to test after this (roughly 9 steps) [d69100b8eee27c2d60ee52df76e0b80a8d492d34] net: nlmsg_cancel() if put fails for nhmsg testing commit d69100b8eee27c2d60ee52df76e0b80a8d492d34 with gcc (GCC) 8.1.0 kernel signature: 32f2ff0617aaeeb4df48794331a58aef9d62258433f9d90ff0fafc1bc1f41bbd all runs: OK # git bisect good d69100b8eee27c2d60ee52df76e0b80a8d492d34 Bisecting: 213 revisions left to test after this (roughly 8 steps) [03fb3acae4be8a6b680ffedb220a8b6c07260b40] Merge branch 'i2c/for-current-fixed' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux testing commit 03fb3acae4be8a6b680ffedb220a8b6c07260b40 with gcc (GCC) 8.1.0 kernel signature: e3d13a24c2a0d0246d46a85daefa31a5c24219dc7ce9b6ae26e79d7b45f76bc3 all runs: OK # git bisect good 03fb3acae4be8a6b680ffedb220a8b6c07260b40 Bisecting: 105 revisions left to test after this (roughly 7 steps) [4aada7791fa2bd3e927502bc67ba604b95bb21bf] Merge remote-tracking branch 'sound-current/for-linus' testing commit 4aada7791fa2bd3e927502bc67ba604b95bb21bf with gcc (GCC) 8.1.0 kernel signature: 687f5707509ec1beacf19d28b9a9c4a39a40100954f96530a02b041d4366063f all runs: OK # git bisect good 4aada7791fa2bd3e927502bc67ba604b95bb21bf Bisecting: 53 revisions left to test after this (roughly 6 steps) [078c7b0d185f6c1065afa4e4ac3389beece7d503] Merge remote-tracking branch 'tty.current/tty-linus' testing commit 078c7b0d185f6c1065afa4e4ac3389beece7d503 with gcc (GCC) 8.1.0 kernel signature: 79f70aa18b32cdd24a29dea3d25efd0e11a48966f06cd2912fca6baa894a6716 all runs: crashed: KASAN: use-after-free Read in joydev_cleanup # git bisect bad 078c7b0d185f6c1065afa4e4ac3389beece7d503 Bisecting: 25 revisions left to test after this (roughly 5 steps) [e881587896db7a10902579c44350a01f7557a6d8] Merge remote-tracking branch 'asoc/for-5.7' into asoc-linus testing commit e881587896db7a10902579c44350a01f7557a6d8 with gcc (GCC) 8.1.0 kernel signature: 15c463ce6ee14e82218f778bd7670c67785dec877644bb6ee9ad4ca3a3d7f9fb all runs: OK # git bisect good e881587896db7a10902579c44350a01f7557a6d8 Bisecting: 13 revisions left to test after this (roughly 4 steps) [83c813e237b8edf0fe8184ccdf3dc9622202084c] Merge remote-tracking branch 'spi/for-5.7' into spi-linus testing commit 83c813e237b8edf0fe8184ccdf3dc9622202084c with gcc (GCC) 8.1.0 kernel signature: c67a775b6e8a82f4f22daee2f96437a2f63453a2b8c6127a9d1521d55e5e9c2c all runs: OK # git bisect good 83c813e237b8edf0fe8184ccdf3dc9622202084c Bisecting: 6 revisions left to test after this (roughly 3 steps) [66ac4422fa22def9ce0886d3a032c5c288799c87] Merge remote-tracking branch 'regulator-fixes/for-linus' testing commit 66ac4422fa22def9ce0886d3a032c5c288799c87 with gcc (GCC) 8.1.0 kernel signature: 78ac1ccd596f2a5c974411a36259479ef2068090ff9e1e199397a8e67fd79795 all runs: OK # git bisect good 66ac4422fa22def9ce0886d3a032c5c288799c87 Bisecting: 3 revisions left to test after this (roughly 2 steps) [4ef12f7198023c09ad6d25b652bd8748c965c7fa] kobject: Make sure the parent does not get released before its children testing commit 4ef12f7198023c09ad6d25b652bd8748c965c7fa with gcc (GCC) 8.1.0 kernel signature: 77d9d5ff9728e1f2f06a9c1d82cd05f007e070e86f88f9f06a3b83cd3e1a9e6c all runs: crashed: KASAN: use-after-free Read in joydev_cleanup # git bisect bad 4ef12f7198023c09ad6d25b652bd8748c965c7fa Bisecting: 0 revisions left to test after this (roughly 1 step) [44e960490ddf868fc9135151c4a658936e771dc2] driver core: Fix handling of SYNC_STATE_ONLY + STATELESS device links testing commit 44e960490ddf868fc9135151c4a658936e771dc2 with gcc (GCC) 8.1.0 kernel signature: 8e949739f3acdd127170d9f15d5f6b1188ad5a8d3b4ecad3bf1da1b6459b5ce2 all runs: OK # git bisect good 44e960490ddf868fc9135151c4a658936e771dc2 4ef12f7198023c09ad6d25b652bd8748c965c7fa is the first bad commit commit 4ef12f7198023c09ad6d25b652bd8748c965c7fa Author: Heikki Krogerus Date: Wed May 13 18:18:40 2020 +0300 kobject: Make sure the parent does not get released before its children In the function kobject_cleanup(), kobject_del(kobj) is called before the kobj->release(). That makes it possible to release the parent of the kobject before the kobject itself. To fix that, adding function __kboject_del() that does everything that kobject_del() does except release the parent reference. kobject_cleanup() then calls __kobject_del() instead of kobject_del(), and separately decrements the reference count of the parent kobject after kobj->release() has been called. Reported-by: Naresh Kamboju Reported-by: kernel test robot Fixes: 7589238a8cf3 ("Revert "software node: Simplify software_node_release() function"") Suggested-by: "Rafael J. Wysocki" Signed-off-by: Heikki Krogerus Reviewed-by: Rafael J. Wysocki Reviewed-by: Brendan Higgins Tested-by: Brendan Higgins Acked-by: Randy Dunlap Link: https://lore.kernel.org/r/20200513151840.36400-1-heikki.krogerus@linux.intel.com Cc: stable Signed-off-by: Greg Kroah-Hartman lib/kobject.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) culprit signature: 77d9d5ff9728e1f2f06a9c1d82cd05f007e070e86f88f9f06a3b83cd3e1a9e6c parent signature: 8e949739f3acdd127170d9f15d5f6b1188ad5a8d3b4ecad3bf1da1b6459b5ce2 revisions tested: 16, total time: 3h37m53.425721391s (build: 1h35m9.673622309s, test: 2h1m35.318627348s) first bad commit: 4ef12f7198023c09ad6d25b652bd8748c965c7fa kobject: Make sure the parent does not get released before its children cc: ["brendanhiggins@google.com" "gregkh@linuxfoundation.org" "heikki.krogerus@linux.intel.com" "rafael.j.wysocki@intel.com" "rdunlap@infradead.org"] crash: KASAN: use-after-free Read in joydev_cleanup ================================================================== BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:938 [inline] BUG: KASAN: use-after-free in __mutex_lock+0x105d/0x13e0 kernel/locking/mutex.c:1103 Read of size 8 at addr ffff88809e0cc150 by task kworker/1:0/17 CPU: 1 PID: 17 Comm: kworker/1:0 Not tainted 5.7.0-rc5-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: usb_hub_wq hub_event Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x128/0x182 lib/dump_stack.c:118 print_address_description.constprop.8.cold.10+0x9/0x317 mm/kasan/report.c:382 __kasan_report.cold.11+0x35/0x4d mm/kasan/report.c:511 kasan_report+0x32/0x50 mm/kasan/common.c:625 __mutex_lock_common kernel/locking/mutex.c:938 [inline] __mutex_lock+0x105d/0x13e0 kernel/locking/mutex.c:1103 joydev_mark_dead drivers/input/joydev.c:729 [inline] joydev_cleanup+0x1c/0x170 drivers/input/joydev.c:738 joydev_disconnect+0x40/0xb0 drivers/input/joydev.c:1010 __input_unregister_device+0x199/0x3f0 drivers/input/input.c:2091 input_unregister_device+0x7f/0xb0 drivers/input/input.c:2273 hidinput_disconnect+0x13f/0x3b0 drivers/hid/hid-input.c:1968 hid_disconnect+0xda/0x150 drivers/hid/hid-core.c:2008 hid_hw_stop+0xa/0x70 drivers/hid/hid-core.c:2055 hid_device_remove+0xbe/0x1f0 drivers/hid/hid-core.c:2296 __device_release_driver drivers/base/dd.c:1110 [inline] device_release_driver_internal+0x1d2/0x470 drivers/base/dd.c:1141 bus_remove_device+0x293/0x460 drivers/base/bus.c:533 device_del+0x421/0xc00 drivers/base/core.c:2734 hid_remove_device drivers/hid/hid-core.c:2467 [inline] hid_destroy_device+0xba/0x120 drivers/hid/hid-core.c:2486 usbhid_disconnect+0x8e/0xc0 drivers/hid/usbhid/hid-core.c:1434 usb_unbind_interface+0x15c/0x870 drivers/usb/core/driver.c:436 __device_release_driver drivers/base/dd.c:1110 [inline] device_release_driver_internal+0x1d2/0x470 drivers/base/dd.c:1141 bus_remove_device+0x293/0x460 drivers/base/bus.c:533 device_del+0x421/0xc00 drivers/base/core.c:2734 usb_disable_device+0x1ae/0x580 drivers/usb/core/message.c:1245 usb_disconnect+0x227/0x850 drivers/usb/core/hub.c:2216 hub_port_connect drivers/usb/core/hub.c:5058 [inline] hub_port_connect_change drivers/usb/core/hub.c:5347 [inline] port_event drivers/usb/core/hub.c:5493 [inline] hub_event+0x1048/0x2d60 drivers/usb/core/hub.c:5575 process_one_work+0x908/0x15d0 kernel/workqueue.c:2268 worker_thread+0x82/0xb50 kernel/workqueue.c:2414 kthread+0x340/0x410 kernel/kthread.c:268 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:351 Allocated by task 2689: save_stack+0x19/0x40 mm/kasan/common.c:49 set_track mm/kasan/common.c:57 [inline] __kasan_kmalloc.constprop.17+0xc1/0xd0 mm/kasan/common.c:495 kmem_cache_alloc_trace+0x156/0x780 mm/slab.c:3551 kmalloc include/linux/slab.h:555 [inline] kzalloc include/linux/slab.h:669 [inline] joydev_connect+0x6b/0xc10 drivers/input/joydev.c:913 input_attach_handler+0xfc/0x170 drivers/input/input.c:1031 input_register_device.cold.21+0xb4/0x1ea drivers/input/input.c:2229 hidinput_connect+0x4498/0xd620 drivers/hid/hid-input.c:1935 hid_connect+0x66c/0x950 drivers/hid/hid-core.c:1931 hid_hw_start+0x75/0x100 drivers/hid/hid-core.c:2035 sony_probe+0x1a4/0x250 drivers/hid/hid-sony.c:2868 hid_device_probe+0x260/0x350 drivers/hid/hid-core.c:2263 really_probe+0x1f9/0x5e0 drivers/base/dd.c:520 driver_probe_device+0xc9/0x1b0 drivers/base/dd.c:697 bus_for_each_drv+0x117/0x1a0 drivers/base/bus.c:431 __device_attach+0x1be/0x2c0 drivers/base/dd.c:870 bus_probe_device+0x19e/0x250 drivers/base/bus.c:491 device_add+0x1089/0x1a00 drivers/base/core.c:2557 hid_add_device+0x2da/0x8b0 drivers/hid/hid-core.c:2419 usbhid_probe+0x9da/0xe70 drivers/hid/usbhid/hid-core.c:1407 usb_probe_interface+0x268/0x6c0 drivers/usb/core/driver.c:374 really_probe+0x1f9/0x5e0 drivers/base/dd.c:520 driver_probe_device+0xc9/0x1b0 drivers/base/dd.c:697 bus_for_each_drv+0x117/0x1a0 drivers/base/bus.c:431 __device_attach+0x1be/0x2c0 drivers/base/dd.c:870 bus_probe_device+0x19e/0x250 drivers/base/bus.c:491 device_add+0x1089/0x1a00 drivers/base/core.c:2557 usb_set_configuration+0xcc8/0x1640 drivers/usb/core/message.c:2032 usb_generic_driver_probe+0x61/0x90 drivers/usb/core/generic.c:241 usb_probe_device+0x91/0x160 drivers/usb/core/driver.c:272 really_probe+0x1f9/0x5e0 drivers/base/dd.c:520 driver_probe_device+0xc9/0x1b0 drivers/base/dd.c:697 bus_for_each_drv+0x117/0x1a0 drivers/base/bus.c:431 __device_attach+0x1be/0x2c0 drivers/base/dd.c:870 bus_probe_device+0x19e/0x250 drivers/base/bus.c:491 device_add+0x1089/0x1a00 drivers/base/core.c:2557 usb_new_device.cold.66+0x679/0xe85 drivers/usb/core/hub.c:2553 hub_port_connect drivers/usb/core/hub.c:5207 [inline] hub_port_connect_change drivers/usb/core/hub.c:5347 [inline] port_event drivers/usb/core/hub.c:5493 [inline] hub_event+0x15fe/0x2d60 drivers/usb/core/hub.c:5575 process_one_work+0x908/0x15d0 kernel/workqueue.c:2268 worker_thread+0x82/0xb50 kernel/workqueue.c:2414 kthread+0x340/0x410 kernel/kthread.c:268 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:351 Freed by task 17: save_stack+0x19/0x40 mm/kasan/common.c:49 set_track mm/kasan/common.c:57 [inline] kasan_set_free_info mm/kasan/common.c:317 [inline] __kasan_slab_free+0xf7/0x140 mm/kasan/common.c:456 __cache_free mm/slab.c:3426 [inline] kfree+0x107/0x2b0 mm/slab.c:3757 device_release+0x65/0x1c0 drivers/base/core.c:1394 kobject_cleanup lib/kobject.c:701 [inline] kobject_release lib/kobject.c:732 [inline] kref_put include/linux/kref.h:65 [inline] kobject_put+0x12e/0x230 lib/kobject.c:749 joydev_disconnect+0x38/0xb0 drivers/input/joydev.c:1009 __input_unregister_device+0x199/0x3f0 drivers/input/input.c:2091 input_unregister_device+0x7f/0xb0 drivers/input/input.c:2273 hidinput_disconnect+0x13f/0x3b0 drivers/hid/hid-input.c:1968 hid_disconnect+0xda/0x150 drivers/hid/hid-core.c:2008 hid_hw_stop+0xa/0x70 drivers/hid/hid-core.c:2055 hid_device_remove+0xbe/0x1f0 drivers/hid/hid-core.c:2296 __device_release_driver drivers/base/dd.c:1110 [inline] device_release_driver_internal+0x1d2/0x470 drivers/base/dd.c:1141 bus_remove_device+0x293/0x460 drivers/base/bus.c:533 device_del+0x421/0xc00 drivers/base/core.c:2734 hid_remove_device drivers/hid/hid-core.c:2467 [inline] hid_destroy_device+0xba/0x120 drivers/hid/hid-core.c:2486 usbhid_disconnect+0x8e/0xc0 drivers/hid/usbhid/hid-core.c:1434 usb_unbind_interface+0x15c/0x870 drivers/usb/core/driver.c:436 __device_release_driver drivers/base/dd.c:1110 [inline] device_release_driver_internal+0x1d2/0x470 drivers/base/dd.c:1141 bus_remove_device+0x293/0x460 drivers/base/bus.c:533 device_del+0x421/0xc00 drivers/base/core.c:2734 usb_disable_device+0x1ae/0x580 drivers/usb/core/message.c:1245 usb_disconnect+0x227/0x850 drivers/usb/core/hub.c:2216 hub_port_connect drivers/usb/core/hub.c:5058 [inline] hub_port_connect_change drivers/usb/core/hub.c:5347 [inline] port_event drivers/usb/core/hub.c:5493 [inline] hub_event+0x1048/0x2d60 drivers/usb/core/hub.c:5575 process_one_work+0x908/0x15d0 kernel/workqueue.c:2268 worker_thread+0x82/0xb50 kernel/workqueue.c:2414 kthread+0x340/0x410 kernel/kthread.c:268 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:351 The buggy address belongs to the object at ffff88809e0cc000 which belongs to the cache kmalloc-8k of size 8192 The buggy address is located 336 bytes inside of 8192-byte region [ffff88809e0cc000, ffff88809e0ce000) The buggy address belongs to the page: page:ffffea0002783300 refcount:1 mapcount:0 mapping:000000000e62b8fe index:0x0 head:ffffea0002783300 order:2 compound_mapcount:0 compound_pincount:0 flags: 0xfffe0000010200(slab|head) raw: 00fffe0000010200 ffffea00027cfe08 ffffea00027a5408 ffff8880aa4021c0 raw: 0000000000000000 ffff88809e0cc000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809e0cc000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809e0cc080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88809e0cc100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88809e0cc180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809e0cc200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================