bisecting cause commit starting from a5b647007e9d794956dbed9339a3354a9fc4d5c3 building syzkaller on 0d10349cf0b4a9f98490378709bd9a83bd0042d6 testing commit a5b647007e9d794956dbed9339a3354a9fc4d5c3 with gcc (GCC) 8.1.0 run #0: crashed: WARNING: held lock freed in nr_release run #1: crashed: WARNING: held lock freed in nr_release run #2: crashed: WARNING: held lock freed in nr_release run #3: crashed: WARNING: refcount bug in nr_insert_socket run #4: crashed: KASAN: use-after-free Read in nr_insert_socket run #5: OK run #6: OK run #7: OK 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 a5b647007e9d794956dbed9339a3354a9fc4d5c3 v5.2 Bisecting: 4942 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: 2482 revisions left to test after this (roughly 11 steps) [2c207985f354dfb549e5a543102a3e084eea81f6] mm/oom_kill.c: remove redundant OOM score normalization in select_bad_process() testing commit 2c207985f354dfb549e5a543102a3e084eea81f6 with gcc (GCC) 8.1.0 run #0: crashed: WARNING: held lock freed in nr_release run #1: crashed: KASAN: use-after-free Write in nr_insert_socket 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 2c207985f354dfb549e5a543102a3e084eea81f6 Bisecting: 1229 revisions left to test after this (roughly 10 steps) [7cf9c069430fce7142da7039cc453902df11259b] net: hns3: fix race conditions between reset and module loading & unloading testing commit 7cf9c069430fce7142da7039cc453902df11259b with gcc (GCC) 8.1.0 all runs: OK # git bisect good 7cf9c069430fce7142da7039cc453902df11259b Bisecting: 638 revisions left to test after this (roughly 9 steps) [9ce67c3235be71e8cf922a9b3d0b7359ed3f4ce5] Bluetooth: btusb: Add protocol support for MediaTek MT7663U USB devices testing commit 9ce67c3235be71e8cf922a9b3d0b7359ed3f4ce5 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 9ce67c3235be71e8cf922a9b3d0b7359ed3f4ce5 Bisecting: 370 revisions left to test after this (roughly 8 steps) [6413139dfc641aaaa30580b59696a5f7ea274194] skbuff: increase verbosity when dumping skb data testing commit 6413139dfc641aaaa30580b59696a5f7ea274194 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 6413139dfc641aaaa30580b59696a5f7ea274194 Bisecting: 184 revisions left to test after this (roughly 8 steps) [2bb295f3a5e612b36ccf5986b529a8d4b426cf4f] Merge branch 'net-hisilicon-Add-support-for-HI13X1-to-hip04_eth' testing commit 2bb295f3a5e612b36ccf5986b529a8d4b426cf4f with gcc (GCC) 8.1.0 run #0: crashed: WARNING: held lock freed in nr_release run #1: crashed: WARNING: held lock freed in nr_release run #2: crashed: WARNING: held lock freed in nr_release run #3: crashed: WARNING: held lock freed in nr_release run #4: crashed: WARNING: held lock freed in nr_release run #5: crashed: WARNING: refcount bug in nr_insert_socket run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad 2bb295f3a5e612b36ccf5986b529a8d4b426cf4f Bisecting: 96 revisions left to test after this (roughly 7 steps) [9d1bc24b52fb8c5d859f9a47084bf1179470e04c] bonding: validate ip header before check IPPROTO_IGMP testing commit 9d1bc24b52fb8c5d859f9a47084bf1179470e04c with gcc (GCC) 8.1.0 run #0: crashed: WARNING: held lock freed in nr_release run #1: crashed: WARNING: held lock freed in nr_release run #2: crashed: WARNING: held lock freed in nr_release run #3: crashed: WARNING: held lock freed in nr_release run #4: crashed: KASAN: use-after-free Read in nr_insert_socket run #5: crashed: WARNING: refcount bug in nr_insert_socket run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad 9d1bc24b52fb8c5d859f9a47084bf1179470e04c Bisecting: 44 revisions left to test after this (roughly 6 steps) [c8c8218ec5af5d2598381883acbefbf604e56b5e] netrom: fix a memory leak in nr_rx_frame() testing commit c8c8218ec5af5d2598381883acbefbf604e56b5e with gcc (GCC) 8.1.0 run #0: crashed: WARNING: held lock freed in nr_release run #1: crashed: WARNING: held lock freed in nr_release run #2: crashed: WARNING: held lock freed in nr_release run #3: OK run #4: OK run #5: OK run #6: OK run #7: OK run #8: OK run #9: OK # git bisect bad c8c8218ec5af5d2598381883acbefbf604e56b5e Bisecting: 21 revisions left to test after this (roughly 5 steps) [32e454efbb2279b0fa5874abb0944a9d42080ad1] net: phylink: further documentation clarifications testing commit 32e454efbb2279b0fa5874abb0944a9d42080ad1 with gcc (GCC) 8.1.0 all runs: OK # git bisect good 32e454efbb2279b0fa5874abb0944a9d42080ad1 Bisecting: 10 revisions left to test after this (roughly 4 steps) [c20dc142dd7b2884b8570eeab323bcd4a84294fa] bnxt_en: Disable bus master during PCI shutdown and driver unload. testing commit c20dc142dd7b2884b8570eeab323bcd4a84294fa with gcc (GCC) 8.1.0 all runs: OK # git bisect good c20dc142dd7b2884b8570eeab323bcd4a84294fa Bisecting: 5 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: 2 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: 0 revisions 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 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: 15, total time: 4h6m13.202386374s (build: 1h24m58.554256552s, test: 2h36m23.66401186s) 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.5/7367 is freeing memory ffff88809a810100-ffff88809a8108ff, with a lock still held there! 000000001e8c2f3e (sk_lock-AF_NETROM){+.+.}, at: lock_sock include/net/sock.h:1522 [inline] 000000001e8c2f3e (sk_lock-AF_NETROM){+.+.}, at: nr_release+0x102/0x360 net/netrom/af_netrom.c:522 2 locks held by syz-executor.5/7367: #0: 00000000e4e3066a (&sb->s_type->i_mutex_key#11){+.+.}, at: inode_lock include/linux/fs.h:778 [inline] #0: 00000000e4e3066a (&sb->s_type->i_mutex_key#11){+.+.}, at: __sock_release+0x7d/0x290 net/socket.c:600 #1: 000000001e8c2f3e (sk_lock-AF_NETROM){+.+.}, at: lock_sock include/net/sock.h:1522 [inline] #1: 000000001e8c2f3e (sk_lock-AF_NETROM){+.+.}, at: nr_release+0x102/0x360 net/netrom/af_netrom.c:522 stack backtrace: CPU: 1 PID: 7367 Comm: syz-executor.5 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 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop+0x1a9/0x200 arch/x86/entry/common.c:168 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:0x413501 Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007fff07f307a0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000007 RCX: 0000000000413501 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006 RBP: 0000000000000001 R08: ffffffffffffffff R09: ffffffffffffffff R10: 00007fff07f30880 R11: 0000000000000293 R12: 000000000075c9a0 R13: 000000000075c9a0 R14: 0000000000761050 R15: ffffffffffffffff ================================================================== 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 ffff88809a81018c by task syz-executor.5/7367 CPU: 1 PID: 7367 Comm: syz-executor.5 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 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop+0x1a9/0x200 arch/x86/entry/common.c:168 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:0x413501 Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 04 1b 00 00 c3 48 83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48 89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01 RSP: 002b:00007fff07f307a0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003 RAX: 0000000000000000 RBX: 0000000000000007 RCX: 0000000000413501 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000006 RBP: 0000000000000001 R08: ffffffffffffffff R09: ffffffffffffffff R10: 00007fff07f30880 R11: 0000000000000293 R12: 000000000075c9a0 R13: 000000000075c9a0 R14: 0000000000761050 R15: ffffffffffffffff Allocated by task 7351: 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 7367: 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 tracehook_notify_resume include/linux/tracehook.h:185 [inline] exit_to_usermode_loop+0x1a9/0x200 arch/x86/entry/common.c:168 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 ffff88809a810100 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 140 bytes inside of 2048-byte region [ffff88809a810100, ffff88809a810900) The buggy address belongs to the page: page:ffffea00026a0400 refcount:1 mapcount:0 mapping:ffff8880aa400c40 index:0x0 compound_mapcount: 0 flags: 0x1fffc0000010200(slab|head) raw: 01fffc0000010200 ffffea0002584888 ffffea0002652788 ffff8880aa400c40 raw: 0000000000000000 ffff88809a810100 0000000100000003 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88809a810080: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88809a810100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88809a810180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88809a810200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88809a810280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================