Skip to content

Commit 3bc0732

Browse files
klassertdavem330
authored andcommitted
xfrm: Force a dst refcount before entering the xfrm type handlers
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]>
1 parent 1fbc784 commit 3bc0732

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

net/xfrm/xfrm_input.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
190190
XFRM_SKB_CB(skb)->seq.input.low = seq;
191191
XFRM_SKB_CB(skb)->seq.input.hi = seq_hi;
192192

193+
skb_dst_force(skb);
194+
193195
nexthdr = x->type->input(x, skb);
194196

195197
if (nexthdr == -EINPROGRESS)

net/xfrm/xfrm_output.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
7878

7979
spin_unlock_bh(&x->lock);
8080

81+
skb_dst_force(skb);
82+
8183
err = x->type->output(x, skb);
8284
if (err == -EINPROGRESS)
8385
goto out_exit;

0 commit comments

Comments
 (0)