bisecting cause commit starting from 629f8205a6cc63d2e8e30956bad958a3507d018f building syzkaller on 7c7ded697e6322b0975f061b7e268fe44f585dab testing commit 629f8205a6cc63d2e8e30956bad958a3507d018f with gcc (GCC) 8.1.0 run #0: crashed: KASAN: use-after-free Read in release_sock run #1: crashed: KASAN: use-after-free Read in release_sock run #2: crashed: KASAN: use-after-free Read in release_sock run #3: crashed: KASAN: use-after-free Read in release_sock run #4: crashed: KASAN: use-after-free Read in release_sock run #5: crashed: KASAN: use-after-free Read in release_sock run #6: crashed: KASAN: use-after-free Read in release_sock run #7: crashed: KASAN: use-after-free Read in release_sock run #8: OK run #9: OK testing release v5.2 testing commit 0ecfebd2b52404ae0c54a878c872bb93363ada36 with gcc (GCC) 8.1.0 all runs: OK # git bisect start 629f8205a6cc63d2e8e30956bad958a3507d018f v5.2 Bisecting: 6901 revisions left to test after this (roughly 13 steps) [17a20acaf171124017f43bc70bb4d7ca88070659] Merge tag 'usb-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb testing commit 17a20acaf171124017f43bc70bb4d7ca88070659 with gcc (GCC) 8.1.0 run #0: basic kernel testing failed: failed to copy test binary to VM: failed to run ["scp" "-P" "22" "-F" "/dev/null" "-o" "UserKnownHostsFile=/dev/null" "-o" "BatchMode=yes" "-o" "IdentitiesOnly=yes" "-o" "StrictHostKeyChecking=no" "-o" "ConnectTimeout=10" "-i" "/syzkaller/jobs/linux/workdir/image/key" "/tmp/syz-executor483817485" "root@10.128.15.215:./syz-executor483817485"]: exit status 1 ssh: connect to host 10.128.15.215 port 22: Connection timed out lost connection run #1: crashed: general protection fault in send_hsr_supervision_frame run #2: crashed: general protection fault in send_hsr_supervision_frame run #3: crashed: general protection fault in send_hsr_supervision_frame run #4: crashed: general protection fault in send_hsr_supervision_frame run #5: OK run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad 17a20acaf171124017f43bc70bb4d7ca88070659 Bisecting: 3621 revisions left to test after this (roughly 12 steps) [8f6ccf6159aed1f04c6d179f61f6fb2691261e84] Merge tag 'clone3-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux testing commit 8f6ccf6159aed1f04c6d179f61f6fb2691261e84 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 8f6ccf6159aed1f04c6d179f61f6fb2691261e84 Bisecting: 1810 revisions left to test after this (roughly 11 steps) [28261da8a26f4915aa257d12d506c6ba179d961f] Bluetooth: Check state in l2cap_disconnect_rsp testing commit 28261da8a26f4915aa257d12d506c6ba179d961f with gcc (GCC) 8.1.0 all runs: OK # git bisect good 28261da8a26f4915aa257d12d506c6ba179d961f Bisecting: 838 revisions left to test after this (roughly 10 steps) [97ff4ca46d3279134cec49752de8c5a62dc68460] Merge tag 'char-misc-5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc testing commit 97ff4ca46d3279134cec49752de8c5a62dc68460 with gcc (GCC) 8.1.0 run #0: crashed: KASAN: use-after-free Read in release_sock run #1: crashed: general protection fault in send_hsr_supervision_frame run #2: crashed: general protection fault in send_hsr_supervision_frame run #3: crashed: general protection fault in send_hsr_supervision_frame run #4: crashed: general protection fault in send_hsr_supervision_frame run #5: crashed: general protection fault in send_hsr_supervision_frame run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad 97ff4ca46d3279134cec49752de8c5a62dc68460 Bisecting: 485 revisions left to test after this (roughly 9 steps) [a131c2bf165684315f606fdd88cf80be22ba32f3] Merge tag 'acpi-5.3-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm testing commit a131c2bf165684315f606fdd88cf80be22ba32f3 with gcc (GCC) 8.1.0 run #0: crashed: KASAN: use-after-free Read in release_sock run #1: crashed: general protection fault in send_hsr_supervision_frame run #2: OK run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad a131c2bf165684315f606fdd88cf80be22ba32f3 Bisecting: 249 revisions left to test after this (roughly 8 steps) [7650b1a9bd693d133a3ec0548ba63e828f34e3ec] Merge branch 'mp-inner-L3' testing commit 7650b1a9bd693d133a3ec0548ba63e828f34e3ec with gcc (GCC) 8.1.0 all runs: OK # git bisect good 7650b1a9bd693d133a3ec0548ba63e828f34e3ec Bisecting: 129 revisions left to test after this (roughly 7 steps) [e858faf556d4e14c750ba1e8852783c6f9520a0e] tcp: Reset bytes_acked and bytes_received when disconnecting testing commit e858faf556d4e14c750ba1e8852783c6f9520a0e with gcc (GCC) 8.1.0 all runs: crashed: WARNING: held lock freed in nr_release # git bisect bad e858faf556d4e14c750ba1e8852783c6f9520a0e Bisecting: 59 revisions left to test after this (roughly 6 steps) [3d26eb8ad1e9b906433903ce05f775cf038e747f] net: bridge: don't cache ether dest pointer on input testing commit 3d26eb8ad1e9b906433903ce05f775cf038e747f with gcc (GCC) 8.1.0 all runs: crashed: WARNING: held lock freed in nr_release # git bisect bad 3d26eb8ad1e9b906433903ce05f775cf038e747f Bisecting: 29 revisions left to test after this (roughly 5 steps) [e5b1c6c6277d5a283290a8c033c72544746f9b5b] igmp: fix memory leak in igmpv3_del_delrec() testing commit e5b1c6c6277d5a283290a8c033c72544746f9b5b with gcc (GCC) 8.1.0 all runs: OK # git bisect good e5b1c6c6277d5a283290a8c033c72544746f9b5b Bisecting: 14 revisions left to test after this (roughly 4 steps) [4d1415811e492d9a8238f8a92dd0d51612c788e9] sctp: fix error handling on stream scheduler initialization testing commit 4d1415811e492d9a8238f8a92dd0d51612c788e9 with gcc (GCC) 8.1.0 all runs: crashed: WARNING: held lock freed in nr_release # git bisect bad 4d1415811e492d9a8238f8a92dd0d51612c788e9 Bisecting: 6 revisions left to test after this (roughly 3 steps) [22506f488e6b7adf14b008ed241c69e3918886e6] Merge branch 'bnxt_en-Bug-fixes' testing commit 22506f488e6b7adf14b008ed241c69e3918886e6 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 22506f488e6b7adf14b008ed241c69e3918886e6 Bisecting: 3 revisions left to test after this (roughly 2 steps) [40f6a2cb9cfc5da713f745b23bcc2c6761e5eb5e] net: dst.h: Fix shifting signed 32-bit value by 31 bits problem testing commit 40f6a2cb9cfc5da713f745b23bcc2c6761e5eb5e with gcc (GCC) 8.1.0 all runs: OK # git bisect good 40f6a2cb9cfc5da713f745b23bcc2c6761e5eb5e Bisecting: 1 revision left to test after this (roughly 1 step) [2e60546368165c2449564d71f6005dda9205b5fb] ipv4: don't set IPv6 only flags to IPv4 addresses testing commit 2e60546368165c2449564d71f6005dda9205b5fb with gcc (GCC) 8.1.0 all runs: OK # git bisect good 2e60546368165c2449564d71f6005dda9205b5fb Bisecting: 0 revisions left to test after this (roughly 0 steps) [c8c8218ec5af5d2598381883acbefbf604e56b5e] netrom: fix a memory leak in nr_rx_frame() testing commit c8c8218ec5af5d2598381883acbefbf604e56b5e with gcc (GCC) 8.1.0 all runs: crashed: WARNING: held lock freed in nr_release # git bisect bad c8c8218ec5af5d2598381883acbefbf604e56b5e c8c8218ec5af5d2598381883acbefbf604e56b5e is the first bad commit commit c8c8218ec5af5d2598381883acbefbf604e56b5e Author: Cong Wang Date: Thu Jun 27 14:30:58 2019 -0700 netrom: fix a memory leak in nr_rx_frame() When the skb is associated with a new sock, just assigning it to skb->sk is not sufficient, we have to set its destructor to free the sock properly too. Reported-by: syzbot+d6636a36d3c34bd88938@syzkaller.appspotmail.com Signed-off-by: Cong Wang Signed-off-by: David S. Miller :040000 040000 4c07dae2c063172c527c8acf843b916a275a70ce 1c43141d5e0b704990d869e2ed626126f1596f0b M net revisions tested: 16, total time: 4h9m42.745491994s (build: 1h33m38.008376108s, test: 2h30m48.010520233s) first bad commit: c8c8218ec5af5d2598381883acbefbf604e56b5e netrom: fix a memory leak in nr_rx_frame() cc: ["davem@davemloft.net" "linux-hams@vger.kernel.org" "linux-kernel@vger.kernel.org" "netdev@vger.kernel.org" "ralf@linux-mips.org" "xiyou.wangcong@gmail.com"] crash: WARNING: held lock freed in nr_release ========================= WARNING: held lock freed! 5.2.0-rc6+ #1 Not tainted ------------------------- syz-executor.3/7675 is freeing memory ffff888079256e80-ffff88807925767f, with a lock still held there! 0000000033702ed4 (sk_lock-AF_NETROM){+.+.}, at: lock_sock include/net/sock.h:1522 [inline] 0000000033702ed4 (sk_lock-AF_NETROM){+.+.}, at: nr_release+0x102/0x360 net/netrom/af_netrom.c:522 2 locks held by syz-executor.3/7675: #0: 0000000052cb167e (&sb->s_type->i_mutex_key#11){+.+.}, at: inode_lock include/linux/fs.h:778 [inline] #0: 0000000052cb167e (&sb->s_type->i_mutex_key#11){+.+.}, at: __sock_release+0x7d/0x290 net/socket.c:600 #1: 0000000033702ed4 (sk_lock-AF_NETROM){+.+.}, at: lock_sock include/net/sock.h:1522 [inline] #1: 0000000033702ed4 (sk_lock-AF_NETROM){+.+.}, at: nr_release+0x102/0x360 net/netrom/af_netrom.c:522 stack backtrace: CPU: 0 PID: 7675 Comm: syz-executor.3 Not tainted 5.2.0-rc6+ #1 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x113/0x167 lib/dump_stack.c:113 print_freed_lock_bug kernel/locking/lockdep.c:5077 [inline] debug_check_no_locks_freed.cold.56+0x9e/0xaa kernel/locking/lockdep.c:5110 kfree+0xb1/0x220 mm/slab.c:3752 sk_prot_free net/core/sock.c:1636 [inline] __sk_destruct+0x3f1/0x580 net/core/sock.c:1722 sk_destruct+0x49/0x60 net/core/sock.c:1730 __sk_free+0x9e/0x230 net/core/sock.c:1741 sk_free+0x23/0x30 net/core/sock.c:1752 sock_put include/net/sock.h:1725 [inline] nr_destroy_socket+0x362/0x420 net/netrom/af_netrom.c:288 nr_release+0x2c9/0x360 net/netrom/af_netrom.c:530 __sock_release+0xc2/0x290 net/socket.c:601 sock_close+0x10/0x20 net/socket.c:1273 __fput+0x25a/0x770 fs/file_table.c:280 ____fput+0x9/0x10 fs/file_table.c:313 task_work_run+0x108/0x180 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x9ca/0x2e80 kernel/exit.c:877 do_group_exit+0xf4/0x2f0 kernel/exit.c:981 get_signal+0x362/0x1cf0 kernel/signal.c:2640 do_signal+0x87/0x1940 arch/x86/kernel/signal.c:815 exit_to_usermode_loop+0x114/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:279 [inline] do_syscall_64+0x447/0x530 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x459829 Code: Bad RIP value. RSP: 002b:00007f502b76ec78 EFLAGS: 00000246 ORIG_RAX: 0000000000000110 RAX: fffffffffffffffc RBX: 0000000000000001 RCX: 0000000000459829 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000040000000 RBP: 000000000075c118 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f502b76f6d4 R13: 00000000004c8f3a R14: 00000000004dfff0 R15: 00000000ffffffff ================================================================== BUG: KASAN: use-after-free in debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline] BUG: KASAN: use-after-free in do_raw_spin_lock+0x282/0x2d0 kernel/locking/spinlock_debug.c:112 Read of size 4 at addr ffff888079256f0c by task syz-executor.3/7675 CPU: 0 PID: 7675 Comm: syz-executor.3 Not tainted 5.2.0-rc6+ #1 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x113/0x167 lib/dump_stack.c:113 print_address_description.cold.5+0x9/0x1ff mm/kasan/report.c:188 __kasan_report.cold.6+0x1b/0x39 mm/kasan/report.c:317 kasan_report+0x12/0x20 mm/kasan/common.c:614 __asan_report_load4_noabort+0x14/0x20 mm/kasan/generic_report.c:131 debug_spin_lock_before kernel/locking/spinlock_debug.c:83 [inline] do_raw_spin_lock+0x282/0x2d0 kernel/locking/spinlock_debug.c:112 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:136 [inline] _raw_spin_lock_bh+0x39/0x40 kernel/locking/spinlock.c:175 spin_lock_bh include/linux/spinlock.h:343 [inline] release_sock+0x1b/0x180 net/core/sock.c:2928 nr_release+0x168/0x360 net/netrom/af_netrom.c:553 __sock_release+0xc2/0x290 net/socket.c:601 sock_close+0x10/0x20 net/socket.c:1273 __fput+0x25a/0x770 fs/file_table.c:280 ____fput+0x9/0x10 fs/file_table.c:313 task_work_run+0x108/0x180 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x9ca/0x2e80 kernel/exit.c:877 do_group_exit+0xf4/0x2f0 kernel/exit.c:981 get_signal+0x362/0x1cf0 kernel/signal.c:2640 do_signal+0x87/0x1940 arch/x86/kernel/signal.c:815 exit_to_usermode_loop+0x114/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:279 [inline] do_syscall_64+0x447/0x530 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x459829 Code: Bad RIP value. RSP: 002b:00007f502b76ec78 EFLAGS: 00000246 ORIG_RAX: 0000000000000110 RAX: fffffffffffffffc RBX: 0000000000000001 RCX: 0000000000459829 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000040000000 RBP: 000000000075c118 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f502b76f6d4 R13: 00000000004c8f3a R14: 00000000004dfff0 R15: 00000000ffffffff Allocated by task 7656: save_stack+0x21/0x90 mm/kasan/common.c:71 set_track mm/kasan/common.c:79 [inline] __kasan_kmalloc.constprop.8+0xc7/0xd0 mm/kasan/common.c:489 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:503 __do_kmalloc mm/slab.c:3660 [inline] __kmalloc+0x15d/0x760 mm/slab.c:3669 kmalloc include/linux/slab.h:552 [inline] sk_prot_alloc+0x148/0x240 net/core/sock.c:1599 sk_alloc+0x30/0xc70 net/core/sock.c:1653 nr_make_new net/netrom/af_netrom.c:476 [inline] nr_rx_frame+0x645/0x1f00 net/netrom/af_netrom.c:959 nr_loopback_timer+0x64/0x120 net/netrom/nr_loopback.c:59 call_timer_fn+0x14d/0x510 kernel/time/timer.c:1322 expire_timers kernel/time/timer.c:1366 [inline] __run_timers kernel/time/timer.c:1685 [inline] run_timer_softirq+0xc6f/0x1330 kernel/time/timer.c:1698 __do_softirq+0x260/0x958 kernel/softirq.c:292 Freed by task 7675: save_stack+0x21/0x90 mm/kasan/common.c:71 set_track mm/kasan/common.c:79 [inline] __kasan_slab_free+0x102/0x150 mm/kasan/common.c:451 kasan_slab_free+0xe/0x10 mm/kasan/common.c:459 __cache_free mm/slab.c:3432 [inline] kfree+0xcf/0x220 mm/slab.c:3755 sk_prot_free net/core/sock.c:1636 [inline] __sk_destruct+0x3f1/0x580 net/core/sock.c:1722 sk_destruct+0x49/0x60 net/core/sock.c:1730 __sk_free+0x9e/0x230 net/core/sock.c:1741 sk_free+0x23/0x30 net/core/sock.c:1752 sock_put include/net/sock.h:1725 [inline] nr_destroy_socket+0x362/0x420 net/netrom/af_netrom.c:288 nr_release+0x2c9/0x360 net/netrom/af_netrom.c:530 __sock_release+0xc2/0x290 net/socket.c:601 sock_close+0x10/0x20 net/socket.c:1273 __fput+0x25a/0x770 fs/file_table.c:280 ____fput+0x9/0x10 fs/file_table.c:313 task_work_run+0x108/0x180 kernel/task_work.c:113 exit_task_work include/linux/task_work.h:22 [inline] do_exit+0x9ca/0x2e80 kernel/exit.c:877 do_group_exit+0xf4/0x2f0 kernel/exit.c:981 get_signal+0x362/0x1cf0 kernel/signal.c:2640 do_signal+0x87/0x1940 arch/x86/kernel/signal.c:815 exit_to_usermode_loop+0x114/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:279 [inline] do_syscall_64+0x447/0x530 arch/x86/entry/common.c:304 entry_SYSCALL_64_after_hwframe+0x49/0xbe The buggy address belongs to the object at ffff888079256e80 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 140 bytes inside of 2048-byte region [ffff888079256e80, ffff888079257680) The buggy address belongs to the page: page:ffffea0001e49580 refcount:1 mapcount:0 mapping:ffff8880aa400c40 index:0x0 compound_mapcount: 0 flags: 0x1fffc0000010200(slab|head) raw: 01fffc0000010200 ffffea0001e49188 ffffea0001e49708 ffff8880aa400c40 raw: 0000000000000000 ffff888079256600 0000000100000003 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff888079256e00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff888079256e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888079256f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888079256f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888079257000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================