general protection fault in requeue_rx_msgs

19 views
Skip to first unread message

syzbot

unread,
May 31, 2018, 4:16:03 AM5/31/18
to da...@davemloft.net, ebig...@google.com, edum...@google.com, ktk...@virtuozzo.com, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, t...@quantonium.net, vi...@zeniv.linux.org.uk
Hello,

syzbot found the following crash on:

HEAD commit: 0044cdeb7313 Merge branch 'for-linus' of git://git.kernel...
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15aeff0f800000
kernel config: https://syzkaller.appspot.com/x/.config?x=968b0b23c7854c0b
dashboard link: https://syzkaller.appspot.com/bug?extid=554266c04a41d1f9754d
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=131a208f800000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+554266...@syzkaller.appspotmail.com

kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 4788 Comm: kworker/u4:3 Not tainted 4.17.0-rc7+ #74
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: kstrp strp_work
RIP: 0010:__skb_unlink include/linux/skbuff.h:1844 [inline]
RIP: 0010:__skb_dequeue include/linux/skbuff.h:1861 [inline]
RIP: 0010:requeue_rx_msgs+0x14d/0x620 net/kcm/kcmsock.c:226
RSP: 0018:ffff8801aa97f0b8 EFLAGS: 00010202
RAX: 0000000000000000 RBX: dffffc0000000000 RCX: ffffffff86d54ed3
RDX: 0000000000000001 RSI: ffffffff86d531e2 RDI: 0000000000000008
RBP: ffff8801aa97f1b8 R08: ffff8801aaa8e3c0 R09: ffffed0035f0a0e8
R10: ffffed0035f0a0e8 R11: ffff8801af850743 R12: ffff8801d4407000
R13: ffffed003552fe22 R14: 0000000000000000 R15: ffff8801a6bb06c0
FS: 0000000000000000(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fba7c5099a0 CR3: 00000001af6f6000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
unreserve_rx_kcm+0x471/0x520 net/kcm/kcmsock.c:334
kcm_rcv_strparser+0x109/0x8d0 net/kcm/kcmsock.c:375
__strp_recv+0x34b/0x2130 net/strparser/strparser.c:328
strp_recv+0xcf/0x110 net/strparser/strparser.c:362
tcp_read_sock+0x2aa/0x810 net/ipv4/tcp.c:1652
strp_read_sock+0x1a1/0x2d0 net/strparser/strparser.c:385
do_strp_work net/strparser/strparser.c:440 [inline]
strp_work+0xcd/0x120 net/strparser/strparser.c:449
process_one_work+0xc1e/0x1b50 kernel/workqueue.c:2145
worker_thread+0x1cc/0x1440 kernel/workqueue.c:2279
kthread+0x345/0x410 kernel/kthread.c:240
ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:412
Code: 80 3c 1a 00 0f 85 70 04 00 00 48 8d 78 08 4d 8b 74 24 08 49 c7 04 24
00 00 00 00 49 c7 44 24 08 00 00 00 00 48 89 fa 48 c1 ea 03 <80> 3c 1a 00
0f 85 a7 04 00 00 4c 89 f2 4c 89 70 08 48 c1 ea 03
RIP: __skb_unlink include/linux/skbuff.h:1844 [inline] RSP: ffff8801aa97f0b8
RIP: __skb_dequeue include/linux/skbuff.h:1861 [inline] RSP:
ffff8801aa97f0b8
RIP: requeue_rx_msgs+0x14d/0x620 net/kcm/kcmsock.c:226 RSP: ffff8801aa97f0b8
---[ end trace e4c0e45094907eaa ]---


---
This bug 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 syzk...@googlegroups.com.

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

Kirill Tkhai

unread,
May 31, 2018, 7:34:39 AM5/31/18
to syzbot, da...@davemloft.net, ebig...@google.com, edum...@google.com, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, t...@quantonium.net, vi...@zeniv.linux.org.uk
This looks like the same as syzbot+5f1a04...@syzkaller.appspotmail.com:
"WARNING in kcm_exit_net (3)". This may confirm the theory. It looks like after async
pernet_operations the race window became bigger, and now the work has more chances
to have no a time to complete.

I'm not close to this code. Tom, could you please to say, whether kcm_done_work()
can be called for in-kernel kcm sockets (created via kcm_clone())?

Also, is there a possibility to create !kernel socket in kcm_clone()? I forgot
the reasons, why we can't do that in some places.

Thanks,
Kirill

Paolo Abeni

unread,
Jun 5, 2018, 1:23:34 PM6/5/18
to syzbot, syzkall...@googlegroups.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git master

should still fail...
---
diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c
index d3601d421571..8bca14d20ec2 100644
--- a/net/kcm/kcmsock.c
+++ b/net/kcm/kcmsock.c
@@ -130,7 +130,7 @@ static void kcm_rcv_ready(struct kcm_sock *kcm)
if (unlikely(kcm->rx_wait || kcm->rx_psock || kcm->rx_disabled))
return;

- while (unlikely((skb = __skb_dequeue(&mux->rx_hold_queue)))) {
+ while (unlikely((skb = skb_dequeue(&mux->rx_hold_queue)))) {
if (kcm_queue_rcv_skb(&kcm->sk, skb)) {
/* Assuming buffer limit has been reached */
skb_queue_head(&mux->rx_hold_queue, skb);
@@ -223,7 +223,7 @@ static void requeue_rx_msgs(struct kcm_mux *mux, struct sk_buff_head *head)
struct sk_buff *skb;
struct kcm_sock *kcm;

- while ((skb = __skb_dequeue(head))) {
+ while ((skb = skb_dequeue(head))) {
/* Reset destructor to avoid calling kcm_rcv_ready */
skb->destructor = sock_rfree;
skb_orphan(skb);

syzbot

unread,
Jun 5, 2018, 1:37:03 PM6/5/18
to pab...@redhat.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer still triggered
crash:
general protection fault in skb_unlink

IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
8021q: adding VLAN 0 to HW filter on device team0
8021q: adding VLAN 0 to HW filter on device team0
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 0 PID: 7101 Comm: syz-executor7 Not tainted 4.17.0-rc7+ #1
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
RIP: 0010:__skb_unlink include/linux/skbuff.h:1844 [inline]
RIP: 0010:skb_unlink+0xc1/0x160 net/core/skbuff.c:2921
RSP: 0018:ffff8801acae76f0 EFLAGS: 00010002
RAX: 0000000000000286 RBX: ffff8801d9010140 RCX: 0000000000000001
RDX: dffffc0000000000 RSI: 0000000000000004 RDI: 0000000000000008
RBP: ffff8801acae7718 R08: ffffed003692a0f5 R09: ffffed003692a0f4
R10: ffffed003692a0f4 R11: ffff8801b49507a3 R12: 0000000000000000
R13: 0000000000000000 R14: ffff8801b49507a0 R15: ffff8801acae7ce0
FS: 00007feaeeead700(0000) GS:ffff8801dae00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000706254 CR3: 00000001b4d30000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
kcm_recvmsg+0x48d/0x590 net/kcm/kcmsock.c:1160
sock_recvmsg_nosec+0x8c/0xb0 net/socket.c:802
___sys_recvmsg+0x2b6/0x680 net/socket.c:2279
__sys_recvmmsg+0x2f9/0xb80 net/socket.c:2391
do_sys_recvmmsg+0xe4/0x190 net/socket.c:2472
__do_sys_recvmmsg net/socket.c:2485 [inline]
__se_sys_recvmmsg net/socket.c:2481 [inline]
__x64_sys_recvmmsg+0xbe/0x150 net/socket.c:2481
do_syscall_64+0x1b1/0x800 arch/x86/entry/common.c:287
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x455a09
RSP: 002b:00007feaeeeacc68 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
RAX: ffffffffffffffda RBX: 00007feaeeead6d4 RCX: 0000000000455a09
RDX: 00000000040000f7 RSI: 00000000200002c0 RDI: 0000000000000006
RBP: 000000000072bea0 R08: 0000000020000200 R09: 0000000000000000
R10: 0000000000000060 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000574 R14: 00000000006fd380 R15: 0000000000000000
Code: 00 00 00 49 8d 7d 08 4c 8b 63 08 48 ba 00 00 00 00 00 fc ff df 48 c7
43 08 00 00 00 00 48 89 f9 48 c7 03 00 00 00 00 48 c1 e9 03 <80> 3c 11 00
75 5b 4c 89 e1 4d 89 65 08 48 ba 00 00 00 00 00 fc
RIP: __skb_unlink include/linux/skbuff.h:1844 [inline] RSP: ffff8801acae76f0
RIP: skb_unlink+0xc1/0x160 net/core/skbuff.c:2921 RSP: ffff8801acae76f0
---[ end trace bb156cb822091f25 ]---


Tested on:

commit: 885892fb378d mlx4_core: restore optimal ICM memory allocat..
git tree: net
console output: https://syzkaller.appspot.com/x/log.txt?x=14139bb7800000
kernel config: https://syzkaller.appspot.com/x/.config?x=968b0b23c7854c0b
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
patch: https://syzkaller.appspot.com/x/patch.diff?x=113700af800000

syzbot

unread,
Apr 13, 2019, 5:39:01 AM4/13/19
to alan....@intel.com, andrewx...@intel.com, da...@davemloft.net, ebig...@google.com, edum...@google.com, intel-w...@lists.osuosl.org, jeffrey....@intel.com, ktk...@virtuozzo.com, linux-...@vger.kernel.org, net...@vger.kernel.org, syzkall...@googlegroups.com, t...@quantonium.net, vi...@zeniv.linux.org.uk
syzbot has bisected this bug to:

commit 11a350c965cc5ac2f5d0ed1fb336735a0c1a6344
Author: Alan Brady <alan....@intel.com>
Date: Fri Dec 29 13:48:33 2017 +0000

i40e: fix typo in function description

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1534b397200000
start commit: 0044cdeb Merge branch 'for-linus' of git://git.kernel.org/..
git tree: upstream
final crash: https://syzkaller.appspot.com/x/report.txt?x=1734b397200000
console output: https://syzkaller.appspot.com/x/log.txt?x=1334b397200000
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=131a208f800000

Reported-by: syzbot+554266...@syzkaller.appspotmail.com
Fixes: 11a350c965cc ("i40e: fix typo in function description")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Eric Biggers

unread,
Oct 4, 2019, 3:48:47 AM10/4/19
to syzbot, syzkall...@googlegroups.com
#syz fix: kcm: Fix use-after-free caused by clonned sockets
Reply all
Reply to author
Forward
0 new messages