Skip to content

Commit 93ec132

Browse files
NicolasDichtelklassert
authored andcommitted
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]>
1 parent 047a749 commit 93ec132

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

net/xfrm/xfrm_user.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1967,6 +1967,7 @@ static int xfrm_notify_userpolicy(struct net *net)
19671967
int len = NLMSG_ALIGN(sizeof(*up));
19681968
struct nlmsghdr *nlh;
19691969
struct sk_buff *skb;
1970+
int err;
19701971

19711972
skb = nlmsg_new(len, GFP_ATOMIC);
19721973
if (skb == NULL)
@@ -1988,7 +1989,11 @@ static int xfrm_notify_userpolicy(struct net *net)
19881989

19891990
nlmsg_end(skb, nlh);
19901991

1991-
return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY);
1992+
rcu_read_lock();
1993+
err = xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_POLICY);
1994+
rcu_read_unlock();
1995+
1996+
return err;
19921997
}
19931998

19941999
static int xfrm_set_default(struct sk_buff *skb, struct nlmsghdr *nlh,

0 commit comments

Comments
 (0)