Re: general protection fault in strlen

From: Xin Long
Date: Thu Jan 18 2018 - 12:54:12 EST


On Thu, Jan 18, 2018 at 11:58 PM, syzbot
<syzbot+6e1398cbaa90b7432d38@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> Hello,
>
> syzbot hit the following crash on upstream commit
> 8cbab92dff778e516064c13113ca15d4869ec883
>
> So far this crash happened 19 times on linux-next, net-next, upstream.
> C reproducer is attached.
> syzkaller reproducer is attached.
> Raw console output is attached.
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached.
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+6e1398cbaa90b7432d38@xxxxxxxxxxxxxxxxxxxxxxxxx
> It will help syzbot understand when the bug is fixed. See footer for
> details.
> If you forward the report, please keep this part and the footer.
>
> 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: 1 PID: 28718 Comm: syzkaller365228 Not tainted 4.15.0-rc8+ #265
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> RIP: 0010:strlen+0x1f/0xa0 lib/string.c:479
> RSP: 0018:ffff8801c062f760 EFLAGS: 00010286
> RAX: 0000000000000004 RBX: ffff8801cc392800 RCX: 0000000000000000
> RDX: dffffc0000000000 RSI: ffff8801d57d7680 RDI: 0000000000000004
> RBP: ffff8801c062f778 R08: ffffffff84adf590 R09: 0000000000000004
> R10: ffff8801c062f920 R11: 0000000000000004 R12: ffff8801c062f898
> R13: 0000000000000004 R14: 0000000000000040 R15: 1ffff100380c5ef7
> FS: 00007f11d32d8700(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007ffeee3b49d4 CR3: 00000001caead001 CR4: 00000000001606e0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> strlen include/linux/string.h:266 [inline]
> netlink_ack+0x120/0xa10 net/netlink/af_netlink.c:2324
> netlink_rcv_skb+0x2d1/0x400 net/netlink/af_netlink.c:2415
> xfrm_netlink_rcv+0x6f/0x90 net/xfrm/xfrm_user.c:2599
> netlink_unicast_kernel net/netlink/af_netlink.c:1275 [inline]
> netlink_unicast+0x4ee/0x700 net/netlink/af_netlink.c:1301
> netlink_sendmsg+0xa4a/0xe60 net/netlink/af_netlink.c:1864
> sock_sendmsg_nosec net/socket.c:638 [inline]
> sock_sendmsg+0xca/0x110 net/socket.c:648
> ___sys_sendmsg+0x767/0x8b0 net/socket.c:2028
> __sys_sendmsg+0xe5/0x210 net/socket.c:2062
> SYSC_sendmsg net/socket.c:2073 [inline]
> SyS_sendmsg+0x2d/0x50 net/socket.c:2069
> entry_SYSCALL_64_fastpath+0x29/0xa0
> RIP: 0033:0x44c569
> RSP: 002b:00007f11d32d7ce8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
> RAX: ffffffffffffffda RBX: 00000000006dec24 RCX: 000000000044c569
> RDX: 0000000000000000 RSI: 0000000020f1efc8 RDI: 0000000000000004
> RBP: 00000000006dec20 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: 00007ffeee3b48af R14: 00007f11d32d89c0 R15: 0000000000000004
> Code: 37 ff ff ff 0f 1f 84 00 00 00 00 00 55 48 89 f9 48 ba 00 00 00 00 00
> fc ff df 48 c1 e9 03 48 89 f8 48 89 e5 41 54 53 48 83 ec 08 <0f> b6 14 11 48
> 89 f9 83 e1 07 38 ca 7f 04 84 d2 75 4b 80 38 00
> RIP: strlen+0x1f/0xa0 lib/string.c:479 RSP: ffff8801c062f760
> ---[ end trace ecfeb6e4224e1ee8 ]---
> Kernel panic - not syncing: Fatal exception
> Dumping ftrace buffer:
> (ftrace buffer empty)
> Kernel Offset: disabled
> Rebooting in 86400 seconds..
>
>
> ---
> This bug is generated by a dumb bot. It may contain errors.
> See https://goo.gl/tpsmEJ for details.
> Direct all questions to syzkaller@xxxxxxxxxxxxxxxxx
>
> syzbot will keep track of this bug report.
> If you forgot to add the Reported-by tag, once the fix for this bug is
> merged
> into any tree, please reply to this email with:
> #syz fix: exact-commit-title
> If you want to test a patch for this bug, please reply with:
> #syz test: git://repo/address.git branch
> and provide the patch inline or as an attachment.
> To mark this as a duplicate of another syzbot report, please reply with:
> #syz dup: exact-subject-of-another-report
> If it's a one-off invalid bug report, please reply with:
> #syz invalid
> Note: if the crash happens again, it will cause creation of a new bug
> report.
> Note: all commands must start from beginning of the line in the email body.
This patch will also fix it:
https://patchwork.ozlabs.org/patch/862778/