Commit 910ef70a authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC]: Do xfrm_state_check_space before encapsulation

While merging the IPsec output path I moved the encapsulation output
operation to the top of the loop so that it sits outside of the locked
section.  Unfortunately in doing so it now sits in front of the space
check as well which could be a fatal error.

This patch rearranges the calls so that the space check happens as
the thing on the output path.

This patch also fixes an incorrect goto should the encapsulation output
fail.

Thanks to Kazunori MIYAZAWA for finding this bug.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 33b8e776
...@@ -33,16 +33,6 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb) ...@@ -33,16 +33,6 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb)
return 0; return 0;
} }
static int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb)
{
int err = xfrm_state_check_expire(x);
if (err < 0)
goto err;
err = xfrm_state_check_space(x, skb);
err:
return err;
}
static int xfrm_output_one(struct sk_buff *skb, int err) static int xfrm_output_one(struct sk_buff *skb, int err)
{ {
struct dst_entry *dst = skb->dst; struct dst_entry *dst = skb->dst;
...@@ -52,12 +42,16 @@ static int xfrm_output_one(struct sk_buff *skb, int err) ...@@ -52,12 +42,16 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
goto resume; goto resume;
do { do {
err = xfrm_state_check_space(x, skb);
if (err)
goto error_nolock;
err = x->outer_mode->output(x, skb); err = x->outer_mode->output(x, skb);
if (err) if (err)
goto error; goto error_nolock;
spin_lock_bh(&x->lock); spin_lock_bh(&x->lock);
err = xfrm_state_check(x, skb); err = xfrm_state_check_expire(x);
if (err) if (err)
goto error; goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment