[syzbot] kernel BUG in inet_sock_destruct

From: syzbot
Date: Tue Jan 03 2023 - 14:27:18 EST


Hello,

syzbot found the following issue on:

HEAD commit: d039535850ee net: phy: xgmiitorgmii: Fix refcount leak in ..
git tree: net
console output: https://syzkaller.appspot.com/x/log.txt?x=10985f5c480000
kernel config: https://syzkaller.appspot.com/x/.config?x=8ca07260bb631fb4
dashboard link: https://syzkaller.appspot.com/bug?extid=bebc6f1acdf4cbb79b03
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=169b492a480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10eab934480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/083b3aeb8e8a/disk-d0395358.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/eeb552a151bd/vmlinux-d0395358.xz
kernel image: https://storage.googleapis.com/syzbot-assets/4ea1ac5916aa/bzImage-d0395358.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+bebc6f1acdf4cbb79b03@xxxxxxxxxxxxxxxxxxxxxxxxx

kfree_skb include/linux/skbuff.h:1218 [inline]
__skb_queue_purge include/linux/skbuff.h:3112 [inline]
inet_sock_destruct+0x10f/0x890 net/ipv4/af_inet.c:136
__sk_destruct+0x4d/0x750 net/core/sock.c:2133
rcu_do_batch kernel/rcu/tree.c:2246 [inline]
rcu_core+0x81f/0x1980 kernel/rcu/tree.c:2506
__do_softirq+0x1fb/0xadc kernel/softirq.c:571
------------[ cut here ]------------
kernel BUG at include/linux/mm.h:760!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 5072 Comm: syz-executor406 Not tainted 6.1.0-syzkaller-04343-gd039535850ee #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
RIP: 0010:put_page_testzero include/linux/mm.h:760 [inline]
RIP: 0010:folio_put_testzero include/linux/mm.h:766 [inline]
RIP: 0010:folio_put include/linux/mm.h:1249 [inline]
RIP: 0010:put_page include/linux/mm.h:1319 [inline]
RIP: 0010:__skb_frag_unref include/linux/skbuff.h:3388 [inline]
RIP: 0010:skb_release_data+0x73c/0x870 net/core/skbuff.c:845
Code: fd ff ff e8 b6 42 bf f9 48 8b 6c 24 10 48 83 ed 01 e9 62 fd ff ff e8 a3 42 bf f9 48 c7 c6 20 e0 5a 8b 48 89 ef e8 54 ed f6 f9 <0f> 0b 4c 89 e7 e8 ea 43 0d fa e9 29 f9 ff ff 48 8b 7c 24 08 e8 3b
RSP: 0018:ffffc900001e0d30 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff88807d4adb40 RCX: 0000000000000100
RDX: ffff888021990000 RSI: ffffffff87c20f4c RDI: 0000000000000000
RBP: ffffea0000810600 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: ffffea0000810634
R13: ffff88807023b4f0 R14: 0000000000000000 R15: dffffc0000000000
FS: 00005555568ca300(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007feda96e73a0 CR3: 00000000205ab000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<IRQ>
skb_release_all net/core/skbuff.c:916 [inline]
__kfree_skb net/core/skbuff.c:930 [inline]
kfree_skb_reason+0x1ab/0x4f0 net/core/skbuff.c:956
kfree_skb include/linux/skbuff.h:1218 [inline]
__skb_queue_purge include/linux/skbuff.h:3112 [inline]
inet_sock_destruct+0x10f/0x890 net/ipv4/af_inet.c:136
__sk_destruct+0x4d/0x750 net/core/sock.c:2133
rcu_do_batch kernel/rcu/tree.c:2246 [inline]
rcu_core+0x81f/0x1980 kernel/rcu/tree.c:2506
__do_softirq+0x1fb/0xadc kernel/softirq.c:571
invoke_softirq kernel/softirq.c:445 [inline]
__irq_exit_rcu+0x123/0x180 kernel/softirq.c:650
irq_exit_rcu+0x9/0x20 kernel/softirq.c:662
sysvec_apic_timer_interrupt+0x97/0xc0 arch/x86/kernel/apic/apic.c:1107
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:649
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0x3c/0x70 kernel/locking/spinlock.c:194
Code: 74 24 10 e8 46 e6 5a f7 48 89 ef e8 ee 52 5b f7 81 e3 00 02 00 00 75 25 9c 58 f6 c4 02 75 2d 48 85 db 74 01 fb bf 01 00 00 00 <e8> 2f b6 4d f7 65 8b 05 e0 a2 fa 75 85 c0 74 0a 5b 5d c3 e8 ec ca
RSP: 0018:ffffc90003adfc78 EFLAGS: 00000206
RAX: 0000000000000006 RBX: 0000000000000200 RCX: 1ffffffff1ce5581
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: ffff888020b921e0 R08: 0000000000000001 R09: 0000000000000001
R10: ffffed100417243c R11: 0000000000000000 R12: dffffc0000000000
R13: 00007ffea9da3db4 R14: 0000000000000004 R15: 0000000000000000
do_wait+0x17f/0xd70 kernel/exit.c:1579
kernel_wait4+0x150/0x260 kernel/exit.c:1766
__do_sys_wait4+0x13f/0x150 kernel/exit.c:1794
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7feda969c0e6
Code: 0f 1f 40 00 31 c9 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 49 89 ca 64 8b 04 25 18 00 00 00 85 c0 75 11 b8 3d 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 90 48 83 ec 28 89 54 24 14 48 89 74 24
RSP: 002b:00007ffea9da3da8 EFLAGS: 00000246 ORIG_RAX: 000000000000003d
RAX: ffffffffffffffda RBX: 00007ffea9da3dd0 RCX: 00007feda969c0e6
RDX: 0000000040000001 RSI: 00007ffea9da3db4 RDI: 00000000ffffffff
RBP: 000000000000032b R08: 0000000000000070 R09: 00007ffea9dee080
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffea9da3dc0
R13: 00000000000f4240 R14: 000000000001b5dc R15: 00007ffea9da3db4
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:put_page_testzero include/linux/mm.h:760 [inline]
RIP: 0010:folio_put_testzero include/linux/mm.h:766 [inline]
RIP: 0010:folio_put include/linux/mm.h:1249 [inline]
RIP: 0010:put_page include/linux/mm.h:1319 [inline]
RIP: 0010:__skb_frag_unref include/linux/skbuff.h:3388 [inline]
RIP: 0010:skb_release_data+0x73c/0x870 net/core/skbuff.c:845
Code: fd ff ff e8 b6 42 bf f9 48 8b 6c 24 10 48 83 ed 01 e9 62 fd ff ff e8 a3 42 bf f9 48 c7 c6 20 e0 5a 8b 48 89 ef e8 54 ed f6 f9 <0f> 0b 4c 89 e7 e8 ea 43 0d fa e9 29 f9 ff ff 48 8b 7c 24 08 e8 3b
RSP: 0018:ffffc900001e0d30 EFLAGS: 00010246
RAX: 0000000000000000 RBX: ffff88807d4adb40 RCX: 0000000000000100
RDX: ffff888021990000 RSI: ffffffff87c20f4c RDI: 0000000000000000
RBP: ffffea0000810600 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000001 R12: ffffea0000810634
R13: ffff88807023b4f0 R14: 0000000000000000 R15: dffffc0000000000
FS: 00005555568ca300(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007feda96e73a0 CR3: 00000000205ab000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 74 24 je 0x26
2: 10 e8 adc %ch,%al
4: 46 e6 5a rex.RX out %al,$0x5a
7: f7 48 89 ef e8 ee 52 testl $0x52eee8ef,-0x77(%rax)
e: 5b pop %rbx
f: f7 81 e3 00 02 00 00 testl $0x9c257500,0x200e3(%rcx)
16: 75 25 9c
19: 58 pop %rax
1a: f6 c4 02 test $0x2,%ah
1d: 75 2d jne 0x4c
1f: 48 85 db test %rbx,%rbx
22: 74 01 je 0x25
24: fb sti
25: bf 01 00 00 00 mov $0x1,%edi
* 2a: e8 2f b6 4d f7 callq 0xf74db65e <-- trapping instruction
2f: 65 8b 05 e0 a2 fa 75 mov %gs:0x75faa2e0(%rip),%eax # 0x75faa316
36: 85 c0 test %eax,%eax
38: 74 0a je 0x44
3a: 5b pop %rbx
3b: 5d pop %rbp
3c: c3 retq
3d: e8 .byte 0xe8
3e: ec in (%dx),%al
3f: ca .byte 0xca


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@xxxxxxxxxxxxxxxx.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches