bisecting cause commit starting from 50aba46c234ea6ab3134cebb5ab27885f33a3e5d building syzkaller on 816e0689d7d9d8321f8bf360740f0e516aee15ca testing commit 50aba46c234ea6ab3134cebb5ab27885f33a3e5d with gcc (GCC) 8.1.0 kernel signature: fa2fe9ff132d78f786f839abebd9f84c059a5ce30f1260ded15a6af24ad91bf0 all runs: crashed: possible deadlock in __sock_release testing release v5.8 testing commit bcf876870b95592b52519ed4aafcf9d95999bc9c with gcc (GCC) 8.1.0 kernel signature: 1c168fc3a22494d9ff1f63fd08e95f123fbecb665755cfce98985004a0ce27ea all runs: OK # git bisect start 50aba46c234ea6ab3134cebb5ab27885f33a3e5d bcf876870b95592b52519ed4aafcf9d95999bc9c Bisecting: 6044 revisions left to test after this (roughly 13 steps) [47ec5303d73ea344e84f46660fff693c57641386] Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next testing commit 47ec5303d73ea344e84f46660fff693c57641386 with gcc (GCC) 8.1.0 kernel signature: 613811b7e918f4c59efc1cd091cc04ee29e984f876103e91c6b169fb744d533b all runs: OK # git bisect good 47ec5303d73ea344e84f46660fff693c57641386 Bisecting: 2914 revisions left to test after this (roughly 12 steps) [fa73e212318a3277ae1f304febbc617c75d4d2db] Merge tag 'media/v5.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media testing commit fa73e212318a3277ae1f304febbc617c75d4d2db with gcc (GCC) 8.1.0 kernel signature: 73875d0b84a86e223ce1b338eb8e6a2551717ac15bb6df1bfe79f0168bc5a388 all runs: OK # git bisect good fa73e212318a3277ae1f304febbc617c75d4d2db Bisecting: 1489 revisions left to test after this (roughly 11 steps) [9ad57f6dfc2345ed5d3a8bf4dabac0a34069c54c] Merge branch 'akpm' (patches from Andrew) testing commit 9ad57f6dfc2345ed5d3a8bf4dabac0a34069c54c with gcc (GCC) 8.1.0 kernel signature: ad4f09ea4624c59caf4575394ea651a29a4b231b9852bd8f23de3ba7057eeace all runs: boot failed: WARNING in mem_cgroup_css_alloc # git bisect skip 9ad57f6dfc2345ed5d3a8bf4dabac0a34069c54c Bisecting: 1489 revisions left to test after this (roughly 11 steps) [5d080b5064a1d2429071276dfc7588b2eecbc02f] devlink: Protect devlink port list traversal testing commit 5d080b5064a1d2429071276dfc7588b2eecbc02f with gcc (GCC) 8.1.0 kernel signature: 98b2d65609430165d323d3a9860478eba53ade75a01ec99bda3c89ac04728b7e all runs: OK # git bisect good 5d080b5064a1d2429071276dfc7588b2eecbc02f Bisecting: 53 revisions left to test after this (roughly 6 steps) [0ce779a9f50108c26541b54c12a0808ba1be103a] net: Avoid unnecessary inet_addr_type() call when addr is INADDR_ANY testing commit 0ce779a9f50108c26541b54c12a0808ba1be103a with gcc (GCC) 8.1.0 kernel signature: ddb9379a5be78c7e7443c5143da9ffd77121f7d9a4d0fd37ed6b6290124488c2 all runs: OK # git bisect good 0ce779a9f50108c26541b54c12a0808ba1be103a Bisecting: 26 revisions left to test after this (roughly 5 steps) [550f4d46aff6fe57c9b1c6719c3c9de2237d7ac2] ibmvnic: remove never executed if statement testing commit 550f4d46aff6fe57c9b1c6719c3c9de2237d7ac2 with gcc (GCC) 8.1.0 kernel signature: 4de623709158ddcd5847354c7d91904d6b024575769b22323d7b46d17a9e1fb7 all runs: OK # git bisect good 550f4d46aff6fe57c9b1c6719c3c9de2237d7ac2 Bisecting: 13 revisions left to test after this (roughly 4 steps) [232e15e1d7ddb191c28248cb681f4544c0ff1c54] net: xgene: Move shared header file into include/linux testing commit 232e15e1d7ddb191c28248cb681f4544c0ff1c54 with gcc (GCC) 8.1.0 kernel signature: 558ce22bc7c36840d4f89eebf3dc03bdeae4315efdf375bbbd20074f7f0a77a3 all runs: OK # git bisect good 232e15e1d7ddb191c28248cb681f4544c0ff1c54 Bisecting: 6 revisions left to test after this (roughly 3 steps) [a16684742f9421b61cee8d3f64db677a151ac027] s390/qeth: make queue lock a proper spinlock testing commit a16684742f9421b61cee8d3f64db677a151ac027 with gcc (GCC) 8.1.0 kernel signature: ba1675fe9dc642e226ab8b422bc3eae24b7c43da4e453a826d2aa54bbd3800ca all runs: crashed: possible deadlock in __sock_release # git bisect bad a16684742f9421b61cee8d3f64db677a151ac027 Bisecting: 3 revisions left to test after this (roughly 2 steps) [ef73476376444c7f891045ac5b1be3602355098c] Merge branch 'Move-MDIO-drivers-into-their-own-directory' testing commit ef73476376444c7f891045ac5b1be3602355098c with gcc (GCC) 8.1.0 kernel signature: 6a44b78587bdcd42cf9c323eb12b14360e559d3125544a51ffe181d440aff62c all runs: OK # git bisect good ef73476376444c7f891045ac5b1be3602355098c Bisecting: 1 revision left to test after this (roughly 1 step) [b14912eb4b897683d25b8473caebb014b5d36359] s390/qeth: clean up qeth_l3_send_setdelmc()'s declaration testing commit b14912eb4b897683d25b8473caebb014b5d36359 with gcc (GCC) 8.1.0 kernel signature: a425204e1207c479b43fad8f1adfa7ff88af7372468055099d21eb95d2517bfe all runs: crashed: possible deadlock in __sock_release # git bisect bad b14912eb4b897683d25b8473caebb014b5d36359 Bisecting: 0 revisions left to test after this (roughly 0 steps) [fdeba99b1e58ecd18c2940c453e19e4ef20ff591] tipc: fix use-after-free in tipc_bcast_get_mode testing commit fdeba99b1e58ecd18c2940c453e19e4ef20ff591 with gcc (GCC) 8.1.0 kernel signature: 8e09e69eecb0d43d1b2985b1c89ea27cb3155680e871779f4a6416c76cdd5088 all runs: crashed: possible deadlock in __sock_release # git bisect bad fdeba99b1e58ecd18c2940c453e19e4ef20ff591 fdeba99b1e58ecd18c2940c453e19e4ef20ff591 is the first bad commit commit fdeba99b1e58ecd18c2940c453e19e4ef20ff591 Author: Hoang Huu Le Date: Thu Aug 27 09:56:51 2020 +0700 tipc: fix use-after-free in tipc_bcast_get_mode Syzbot has reported those issues as: ================================================================== BUG: KASAN: use-after-free in tipc_bcast_get_mode+0x3ab/0x400 net/tipc/bcast.c:759 Read of size 1 at addr ffff88805e6b3571 by task kworker/0:6/3850 CPU: 0 PID: 3850 Comm: kworker/0:6 Not tainted 5.8.0-rc7-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events tipc_net_finalize_work Thread 1's call trace: [...] kfree+0x103/0x2c0 mm/slab.c:3757 <- bcbase releasing tipc_bcast_stop+0x1b0/0x2f0 net/tipc/bcast.c:721 tipc_exit_net+0x24/0x270 net/tipc/core.c:112 [...] Thread 2's call trace: [...] tipc_bcast_get_mode+0x3ab/0x400 net/tipc/bcast.c:759 <- bcbase has already been freed by Thread 1 tipc_node_broadcast+0x9e/0xcc0 net/tipc/node.c:1744 tipc_nametbl_publish+0x60b/0x970 net/tipc/name_table.c:752 tipc_net_finalize net/tipc/net.c:141 [inline] tipc_net_finalize+0x1fa/0x310 net/tipc/net.c:131 tipc_net_finalize_work+0x55/0x80 net/tipc/net.c:150 [...] ================================================================== BUG: KASAN: use-after-free in tipc_named_reinit+0xef/0x290 net/tipc/name_distr.c:344 Read of size 8 at addr ffff888052ab2000 by task kworker/0:13/30628 CPU: 0 PID: 30628 Comm: kworker/0:13 Not tainted 5.8.0-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events tipc_net_finalize_work Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1f0/0x31e lib/dump_stack.c:118 print_address_description+0x66/0x5a0 mm/kasan/report.c:383 __kasan_report mm/kasan/report.c:513 [inline] kasan_report+0x132/0x1d0 mm/kasan/report.c:530 tipc_named_reinit+0xef/0x290 net/tipc/name_distr.c:344 tipc_net_finalize+0x85/0xe0 net/tipc/net.c:138 tipc_net_finalize_work+0x50/0x70 net/tipc/net.c:150 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 [...] Freed by task 14058: save_stack mm/kasan/common.c:48 [inline] set_track mm/kasan/common.c:56 [inline] kasan_set_free_info mm/kasan/common.c:316 [inline] __kasan_slab_free+0x114/0x170 mm/kasan/common.c:455 __cache_free mm/slab.c:3426 [inline] kfree+0x10a/0x220 mm/slab.c:3757 tipc_exit_net+0x29/0x50 net/tipc/core.c:113 ops_exit_list net/core/net_namespace.c:186 [inline] cleanup_net+0x708/0xba0 net/core/net_namespace.c:603 process_one_work+0x789/0xfc0 kernel/workqueue.c:2269 worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415 kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293 Fix it by calling flush_scheduled_work() to make sure the tipc_net_finalize_work() stopped before releasing bcbase object. Reported-by: syzbot+6ea1f7a8df64596ef4d7@syzkaller.appspotmail.com Reported-by: syzbot+e9cc557752ab126c1b99@syzkaller.appspotmail.com Acked-by: Jon Maloy Signed-off-by: Hoang Huu Le Signed-off-by: David S. Miller net/tipc/core.c | 5 +++++ 1 file changed, 5 insertions(+) culprit signature: 8e09e69eecb0d43d1b2985b1c89ea27cb3155680e871779f4a6416c76cdd5088 parent signature: 6a44b78587bdcd42cf9c323eb12b14360e559d3125544a51ffe181d440aff62c revisions tested: 13, total time: 2h41m47.41534649s (build: 1h0m56.171771833s, test: 1h39m32.382556973s) first bad commit: fdeba99b1e58ecd18c2940c453e19e4ef20ff591 tipc: fix use-after-free in tipc_bcast_get_mode recipients (to): ["davem@davemloft.net" "hoang.h.le@dektech.com.au" "jmaloy@redhat.com"] recipients (cc): [] crash: possible deadlock in __sock_release ====================================================== WARNING: possible circular locking dependency detected 5.9.0-rc1-syzkaller #0 Not tainted ------------------------------------------------------ kworker/0:5/8441 is trying to acquire lock: ffff88811de48790 (&sb->s_type->i_mutex_key#13){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:779 [inline] ffff88811de48790 (&sb->s_type->i_mutex_key#13){+.+.}-{3:3}, at: __sock_release+0x28/0xa0 net/socket.c:595 but task is already holding lock: ffffc90001057e70 ((delayed_fput_work).work){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:615 [inline] ffffc90001057e70 ((delayed_fput_work).work){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:643 [inline] ffffc90001057e70 ((delayed_fput_work).work){+.+.}-{0:0}, at: process_one_work+0x1de/0x5f0 kernel/workqueue.c:2240 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 ((delayed_fput_work).work){+.+.}-{0:0}: process_one_work+0x23e/0x5f0 kernel/workqueue.c:2245 worker_thread+0x38/0x380 kernel/workqueue.c:2415 kthread+0x148/0x170 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 -> #2 ((wq_completion)events){+.+.}-{0:0}: flush_workqueue+0xa6/0x590 kernel/workqueue.c:2780 flush_scheduled_work include/linux/workqueue.h:597 [inline] tipc_exit_net+0x23/0x170 net/tipc/core.c:116 ops_exit_list.isra.9+0x31/0x60 net/core/net_namespace.c:186 cleanup_net+0x273/0x3d0 net/core/net_namespace.c:603 process_one_work+0x26a/0x5f0 kernel/workqueue.c:2269 worker_thread+0x38/0x380 kernel/workqueue.c:2415 kthread+0x148/0x170 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 -> #1 (pernet_ops_rwsem){++++}-{3:3}: down_write+0x33/0x70 kernel/locking/rwsem.c:1531 unregister_netdevice_notifier+0x17/0xb0 net/core/dev.c:1861 bcm_release+0x30/0x1c0 net/can/bcm.c:1474 __sock_release+0x32/0xa0 net/socket.c:596 sock_close+0xf/0x20 net/socket.c:1277 __fput+0xaa/0x250 fs/file_table.c:281 task_work_run+0x68/0xb0 kernel/task_work.c:141 tracehook_notify_resume include/linux/tracehook.h:188 [inline] exit_to_user_mode_loop kernel/entry/common.c:140 [inline] exit_to_user_mode_prepare+0x1e2/0x1f0 kernel/entry/common.c:167 syscall_exit_to_user_mode+0x59/0x2b0 kernel/entry/common.c:242 entry_SYSCALL_64_after_hwframe+0x44/0xa9 -> #0 (&sb->s_type->i_mutex_key#13){+.+.}-{3:3}: check_prev_add kernel/locking/lockdep.c:2496 [inline] check_prevs_add kernel/locking/lockdep.c:2601 [inline] validate_chain kernel/locking/lockdep.c:3218 [inline] __lock_acquire+0x1056/0x16c0 kernel/locking/lockdep.c:4426 lock_acquire+0xd0/0x3e0 kernel/locking/lockdep.c:5005 down_write+0x33/0x70 kernel/locking/rwsem.c:1531 inode_lock include/linux/fs.h:779 [inline] __sock_release+0x28/0xa0 net/socket.c:595 sock_close+0xf/0x20 net/socket.c:1277 __fput+0xaa/0x250 fs/file_table.c:281 delayed_fput+0x17/0x30 fs/file_table.c:309 process_one_work+0x26a/0x5f0 kernel/workqueue.c:2269 worker_thread+0x38/0x380 kernel/workqueue.c:2415 kthread+0x148/0x170 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 other info that might help us debug this: Chain exists of: &sb->s_type->i_mutex_key#13 --> (wq_completion)events --> (delayed_fput_work).work Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock((delayed_fput_work).work); lock((wq_completion)events); lock((delayed_fput_work).work); lock(&sb->s_type->i_mutex_key#13); *** DEADLOCK *** 2 locks held by kworker/0:5/8441: #0: ffff88812bc55738 ((wq_completion)events){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:615 [inline] #0: ffff88812bc55738 ((wq_completion)events){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:643 [inline] #0: ffff88812bc55738 ((wq_completion)events){+.+.}-{0:0}, at: process_one_work+0x1de/0x5f0 kernel/workqueue.c:2240 #1: ffffc90001057e70 ((delayed_fput_work).work){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:615 [inline] #1: ffffc90001057e70 ((delayed_fput_work).work){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:643 [inline] #1: ffffc90001057e70 ((delayed_fput_work).work){+.+.}-{0:0}, at: process_one_work+0x1de/0x5f0 kernel/workqueue.c:2240 stack backtrace: CPU: 0 PID: 8441 Comm: kworker/0:5 Not tainted 5.9.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events delayed_fput Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xb3/0xec lib/dump_stack.c:118 check_noncircular+0x165/0x180 kernel/locking/lockdep.c:1827 check_prev_add kernel/locking/lockdep.c:2496 [inline] check_prevs_add kernel/locking/lockdep.c:2601 [inline] validate_chain kernel/locking/lockdep.c:3218 [inline] __lock_acquire+0x1056/0x16c0 kernel/locking/lockdep.c:4426 lock_acquire+0xd0/0x3e0 kernel/locking/lockdep.c:5005 down_write+0x33/0x70 kernel/locking/rwsem.c:1531 inode_lock include/linux/fs.h:779 [inline] __sock_release+0x28/0xa0 net/socket.c:595 sock_close+0xf/0x20 net/socket.c:1277 __fput+0xaa/0x250 fs/file_table.c:281 delayed_fput+0x17/0x30 fs/file_table.c:309 process_one_work+0x26a/0x5f0 kernel/workqueue.c:2269 worker_thread+0x38/0x380 kernel/workqueue.c:2415 kthread+0x148/0x170 kernel/kthread.c:292 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294