mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
[IPSEC]: Fix bogus usage of u64 on input sequence number
Al Viro spotted a bogus use of u64 on the input sequence number which is big-endian. This patch fixes it by giving the input sequence number its own member in the xfrm_skb_cb structure. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
45b5035482
commit
b318e0e4ef
7 changed files with 15 additions and 10 deletions
|
@ -508,7 +508,10 @@ struct xfrm_skb_cb {
|
||||||
} header;
|
} header;
|
||||||
|
|
||||||
/* Sequence number for replay protection. */
|
/* Sequence number for replay protection. */
|
||||||
u64 seq;
|
union {
|
||||||
|
u64 output;
|
||||||
|
__be32 input;
|
||||||
|
} seq;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0]))
|
#define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0]))
|
||||||
|
|
|
@ -96,7 +96,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
|
|
||||||
ah->reserved = 0;
|
ah->reserved = 0;
|
||||||
ah->spi = x->id.spi;
|
ah->spi = x->id.spi;
|
||||||
ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq);
|
ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
|
||||||
|
|
||||||
spin_lock_bh(&x->lock);
|
spin_lock_bh(&x->lock);
|
||||||
err = ah_mac_digest(ahp, skb, ah->auth_data);
|
err = ah_mac_digest(ahp, skb, ah->auth_data);
|
||||||
|
|
|
@ -199,7 +199,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
}
|
}
|
||||||
|
|
||||||
esph->spi = x->id.spi;
|
esph->spi = x->id.spi;
|
||||||
esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq);
|
esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
|
||||||
|
|
||||||
sg_init_table(sg, nfrags);
|
sg_init_table(sg, nfrags);
|
||||||
skb_to_sgvec(skb, sg,
|
skb_to_sgvec(skb, sg,
|
||||||
|
@ -210,7 +210,8 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
|
aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
|
||||||
aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
|
aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
|
||||||
aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
|
aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
|
||||||
aead_givcrypt_set_giv(req, esph->enc_data, XFRM_SKB_CB(skb)->seq);
|
aead_givcrypt_set_giv(req, esph->enc_data,
|
||||||
|
XFRM_SKB_CB(skb)->seq.output);
|
||||||
|
|
||||||
ESP_SKB_CB(skb)->tmp = tmp;
|
ESP_SKB_CB(skb)->tmp = tmp;
|
||||||
err = crypto_aead_givencrypt(req);
|
err = crypto_aead_givencrypt(req);
|
||||||
|
|
|
@ -283,7 +283,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
|
|
||||||
ah->reserved = 0;
|
ah->reserved = 0;
|
||||||
ah->spi = x->id.spi;
|
ah->spi = x->id.spi;
|
||||||
ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq);
|
ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
|
||||||
|
|
||||||
spin_lock_bh(&x->lock);
|
spin_lock_bh(&x->lock);
|
||||||
err = ah_mac_digest(ahp, skb, ah->auth_data);
|
err = ah_mac_digest(ahp, skb, ah->auth_data);
|
||||||
|
|
|
@ -188,7 +188,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
*skb_mac_header(skb) = IPPROTO_ESP;
|
*skb_mac_header(skb) = IPPROTO_ESP;
|
||||||
|
|
||||||
esph->spi = x->id.spi;
|
esph->spi = x->id.spi;
|
||||||
esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq);
|
esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
|
||||||
|
|
||||||
sg_init_table(sg, nfrags);
|
sg_init_table(sg, nfrags);
|
||||||
skb_to_sgvec(skb, sg,
|
skb_to_sgvec(skb, sg,
|
||||||
|
@ -199,7 +199,8 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
|
||||||
aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
|
aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
|
||||||
aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
|
aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
|
||||||
aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
|
aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
|
||||||
aead_givcrypt_set_giv(req, esph->enc_data, XFRM_SKB_CB(skb)->seq);
|
aead_givcrypt_set_giv(req, esph->enc_data,
|
||||||
|
XFRM_SKB_CB(skb)->seq.output);
|
||||||
|
|
||||||
ESP_SKB_CB(skb)->tmp = tmp;
|
ESP_SKB_CB(skb)->tmp = tmp;
|
||||||
err = crypto_aead_givencrypt(req);
|
err = crypto_aead_givencrypt(req);
|
||||||
|
|
|
@ -109,7 +109,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
|
||||||
if (encap_type < 0) {
|
if (encap_type < 0) {
|
||||||
async = 1;
|
async = 1;
|
||||||
x = xfrm_input_state(skb);
|
x = xfrm_input_state(skb);
|
||||||
seq = XFRM_SKB_CB(skb)->seq;
|
seq = XFRM_SKB_CB(skb)->seq.input;
|
||||||
goto resume;
|
goto resume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
|
||||||
|
|
||||||
spin_unlock(&x->lock);
|
spin_unlock(&x->lock);
|
||||||
|
|
||||||
XFRM_SKB_CB(skb)->seq = seq;
|
XFRM_SKB_CB(skb)->seq.input = seq;
|
||||||
|
|
||||||
nexthdr = x->type->input(x, skb);
|
nexthdr = x->type->input(x, skb);
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
|
if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
|
||||||
XFRM_SKB_CB(skb)->seq = ++x->replay.oseq;
|
XFRM_SKB_CB(skb)->seq.output = ++x->replay.oseq;
|
||||||
if (unlikely(x->replay.oseq == 0)) {
|
if (unlikely(x->replay.oseq == 0)) {
|
||||||
XFRM_INC_STATS(LINUX_MIB_XFRMOUTSTATESEQERROR);
|
XFRM_INC_STATS(LINUX_MIB_XFRMOUTSTATESEQERROR);
|
||||||
x->replay.oseq--;
|
x->replay.oseq--;
|
||||||
|
|
Loading…
Reference in a new issue