Skip to content

Commit

Permalink
xfrm: fix rcu lock in xfrm_notify_userpolicy()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
NicolasDichtel authored and klassert committed Sep 23, 2021
1 parent 047a749 commit 93ec132
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit 93ec132

Please sign in to comment.