Skip to content

Commit

Permalink
xfrm: free skb if nlsk pointer is NULL
Browse files Browse the repository at this point in the history
nlmsg_multicast() always frees the skb, so in case we cannot call
it we must do that ourselves.

Fixes: 21ee543 ("xfrm: fix race between netns cleanup and state expire notification")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Florian Westphal authored and klassert committed Jun 25, 2018
1 parent 8cc8877 commit 86126b7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,12 @@ static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb,
{
struct sock *nlsk = rcu_dereference(net->xfrm.nlsk);

if (nlsk)
return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC);
else
return -1;
if (!nlsk) {
kfree_skb(skb);
return -EPIPE;
}

return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC);
}

static inline unsigned int xfrm_spdinfo_msgsize(void)
Expand Down

0 comments on commit 86126b7

Please sign in to comment.