WARNING: suspicious RCU usage in xfrm_set_default
Subsystems (3)
syzbot
syzbotHello,
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 <[email protected]> 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:
=============================
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 [email protected].
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
PATCH 1/1 xfrm: fix rcu lock in xfrm_notify_userpolicy()
As stated in the comment above xfrm_nlmsg_multicast(), rcu read lock must be held before calling this function.
--- net/xfrm/xfrm_user.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +6 -1
@@ -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,
Signature · 1 line
2.33.0
Re: [PATCH ipsec] xfrm: fix rcu lock in xfrm_notify_userpolicy()
Quoted 6 lines · Nicolas Dichtel
As stated in the comment above
xfrm_nlmsg_multicast(), rcu read lock must be held before calling this function.Reported-by [email protected]Fixes 703b94b93c19 ("xfrm: notify default policy on update")Signed-off-by Nicolas Dichtel <[email protected]>
Applied, thanks Nicolas!