linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] WARNING: suspicious RCU usage in xfrm_set_default
@ 2021-09-22  0:13 syzbot
  2021-09-22  8:50 ` [PATCH ipsec] xfrm: fix rcu lock in xfrm_notify_userpolicy() Nicolas Dichtel
  0 siblings, 1 reply; 3+ messages in thread
From: syzbot @ 2021-09-22  0:13 UTC (permalink / raw)
  To: davem, herbert, kuba, linux-kernel, netdev, nicolas.dichtel,
	steffen.klassert, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    1f77990c4b79 Add linux-next specific files for 20210920
git tree:       linux-next
console output: https://syzkaller.appspot.com/x/log.txt?x=1581be9b300000
kernel config:  https://syzkaller.appspot.com/x/.config?x=ab1346371f2e6884
dashboard link: https://syzkaller.appspot.com/bug?extid=3d9866419b4aa8f985d6
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=13122c4b300000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12c511f3300000

The issue was bisected to:

commit 88d0adb5f13b1c52fbb7d755f6f79db18c2f0c2c
Author: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Date:   Tue Sep 14 14:46:34 2021 +0000

    xfrm: notify default policy on update

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1075f527300000
final oops:     https://syzkaller.appspot.com/x/report.txt?x=1275f527300000
console output: https://syzkaller.appspot.com/x/log.txt?x=1475f527300000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+3d9866419b4aa8f985d6@syzkaller.appspotmail.com
Fixes: 88d0adb5f13b ("xfrm: notify default policy on update")

=============================
WARNING: suspicious RCU usage
5.15.0-rc2-next-20210920-syzkaller #0 Not tainted
-----------------------------
net/xfrm/xfrm_user.c:1157 suspicious rcu_dereference_check() usage!

other info that might help us debug this:


rcu_scheduler_active = 2, debug_locks = 1
1 lock held by syz-executor917/6560:
 #0: ffffffff8d0d4818 (&net->xfrm.xfrm_cfg_mutex){+.+.}-{3:3}, at: xfrm_netlink_rcv+0x5c/0x90 net/xfrm/xfrm_user.c:2928

stack backtrace:
CPU: 0 PID: 6560 Comm: syz-executor917 Not tainted 5.15.0-rc2-next-20210920-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 xfrm_nlmsg_multicast net/xfrm/xfrm_user.c:1157 [inline]
 xfrm_notify_userpolicy net/xfrm/xfrm_user.c:1991 [inline]
 xfrm_set_default+0x789/0x8b0 net/xfrm/xfrm_user.c:2017
 xfrm_user_rcv_msg+0x430/0xa20 net/xfrm/xfrm_user.c:2907
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2504
 xfrm_netlink_rcv+0x6b/0x90 net/xfrm/xfrm_user.c:2929
 netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1340
 netlink_sendmsg+0x86d/0xdb0 net/netlink/af_netlink.c:1929
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 ____sys_sendmsg+0x6e8/0x810 net/socket.c:2409
 ___sys_sendmsg+0xf3/0x170 net/socket.c:2463
 __sys_sendmsg+0xe5/0x1b0 net/socket.c:2492
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7fe115dcd079
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffedbf3ee68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe115dcd079
RDX: 0000000000000000 RSI: 0000000020000280 RDI: 0000000000000003
RBP: 00007fe115d91060 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe115d910f0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
unsupported nlmsg_t


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

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH ipsec] xfrm: fix rcu lock in xfrm_notify_userpolicy()
  2021-09-22  0:13 [syzbot] WARNING: suspicious RCU usage in xfrm_set_default syzbot
@ 2021-09-22  8:50 ` Nicolas Dichtel
  2021-09-25  8:06   ` Steffen Klassert
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Dichtel @ 2021-09-22  8:50 UTC (permalink / raw)
  To: steffen.klassert, syzbot+3d9866419b4aa8f985d6
  Cc: davem, herbert, kuba, linux-kernel, syzkaller-bugs, netdev,
	Nicolas Dichtel

As stated in the comment above xfrm_nlmsg_multicast(), rcu read lock must
be held before calling this function.

Reported-by: syzbot+3d9866419b4aa8f985d6@syzkaller.appspotmail.com
Fixes: 703b94b93c19 ("xfrm: notify default policy on update")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
 net/xfrm/xfrm_user.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 0eba0c27c665..3a3cb09eec12 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1967,6 +1967,7 @@ static int xfrm_notify_userpolicy(struct net *net)
 	int len = NLMSG_ALIGN(sizeof(*up));
 	struct nlmsghdr *nlh;
 	struct sk_buff *skb;
+	int err;
 
 	skb = nlmsg_new(len, GFP_ATOMIC);
 	if (skb == NULL)
@@ -1988,7 +1989,11 @@ static int xfrm_notify_userpolicy(struct net *net)
 
 	nlmsg_end(skb, nlh);
 
-	return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY);
+	rcu_read_lock();
+	err = xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY);
+	rcu_read_unlock();
+
+	return err;
 }
 
 static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh,
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH ipsec] xfrm: fix rcu lock in xfrm_notify_userpolicy()
  2021-09-22  8:50 ` [PATCH ipsec] xfrm: fix rcu lock in xfrm_notify_userpolicy() Nicolas Dichtel
@ 2021-09-25  8:06   ` Steffen Klassert
  0 siblings, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2021-09-25  8:06 UTC (permalink / raw)
  To: Nicolas Dichtel
  Cc: syzbot+3d9866419b4aa8f985d6, davem, herbert, kuba, linux-kernel,
	syzkaller-bugs, netdev

On Wed, Sep 22, 2021 at 10:50:06AM +0200, Nicolas Dichtel wrote:
> As stated in the comment above xfrm_nlmsg_multicast(), rcu read lock must
> be held before calling this function.
> 
> Reported-by: syzbot+3d9866419b4aa8f985d6@syzkaller.appspotmail.com
> Fixes: 703b94b93c19 ("xfrm: notify default policy on update")
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>

Applied, thanks Nicolas!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-25  8:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22  0:13 [syzbot] WARNING: suspicious RCU usage in xfrm_set_default syzbot
2021-09-22  8:50 ` [PATCH ipsec] xfrm: fix rcu lock in xfrm_notify_userpolicy() Nicolas Dichtel
2021-09-25  8:06   ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).