aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dichtel <[email protected]>2021-09-22 10:50:06 +0200
committerSteffen Klassert <[email protected]>2021-09-23 10:11:12 +0200
commit93ec1320b0170d7a207eda2d119c669b673401ed (patch)
treeac03e9c7e839e7aca5e7a0e6f658978d79c08dc3
parent047a749d231e4faccaf5f473cf73dc5732425f81 (diff)
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. Reported-by: [email protected] Fixes: 703b94b93c19 ("xfrm: notify default policy on update") Signed-off-by: Nicolas Dichtel <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
-rw-r--r--net/xfrm/xfrm_user.c7
1 files changed, 6 insertions, 1 deletions
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,