Skip to content

Commit

Permalink
xfrm: Force a dst refcount before entering the xfrm type handlers
Browse files Browse the repository at this point in the history
Crypto requests might return asynchronous. In this case we leave
the rcu protected region, so force a refcount on the skb's
destination entry before we enter the xfrm type input/output
handlers.

This fixes a crash when a route is deleted whilst sending IPsec
data that is transformed by an asynchronous algorithm.

Signed-off-by: Steffen Klassert <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
klassert authored and davem330 committed Mar 28, 2011
1 parent 1fbc784 commit 3bc0732
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/xfrm/xfrm_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
XFRM_SKB_CB(skb)->seq.input.low = seq;
XFRM_SKB_CB(skb)->seq.input.hi = seq_hi;

skb_dst_force(skb);

nexthdr = x->type->input(x, skb);

if (nexthdr == -EINPROGRESS)
Expand Down
2 changes: 2 additions & 0 deletions net/xfrm/xfrm_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static int xfrm_output_one(struct sk_buff *skb, int err)

spin_unlock_bh(&x->lock);

skb_dst_force(skb);

err = x->type->output(x, skb);
if (err == -EINPROGRESS)
goto out_exit;
Expand Down

0 comments on commit 3bc0732

Please sign in to comment.