summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2017-05-03 10:57:57 -0400
committerSteffen Klassert <steffen.klassert@secunet.com>2017-05-19 08:30:50 -0400
commit67df58a3e5535d8ffeb48a41ec0b38859cc284b8 (patch)
treef3ab5c8e131711c9d12109200581cc59e895c8b7
parent24d472e4e497c29d2eb8fcbe6d9b373b66804e01 (diff)
ah: use crypto_memneq to check the ICV
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
-rw-r--r--net/ipv4/ah4.c5
-rw-r--r--net/ipv6/ah6.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 22377c8ff14b..207350b30f88 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -1,5 +1,6 @@
1#define pr_fmt(fmt) "IPsec: " fmt 1#define pr_fmt(fmt) "IPsec: " fmt
2 2
3#include <crypto/algapi.h>
3#include <crypto/hash.h> 4#include <crypto/hash.h>
4#include <linux/err.h> 5#include <linux/err.h>
5#include <linux/module.h> 6#include <linux/module.h>
@@ -277,7 +278,7 @@ static void ah_input_done(struct crypto_async_request *base, int err)
277 auth_data = ah_tmp_auth(work_iph, ihl); 278 auth_data = ah_tmp_auth(work_iph, ihl);
278 icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len); 279 icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len);
279 280
280 err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG: 0; 281 err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
281 if (err) 282 if (err)
282 goto out; 283 goto out;
283 284
@@ -413,7 +414,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
413 goto out_free; 414 goto out_free;
414 } 415 }
415 416
416 err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG: 0; 417 err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
417 if (err) 418 if (err)
418 goto out_free; 419 goto out_free;
419 420
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index dda6035e3b84..ac747b13a8dc 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -25,6 +25,7 @@
25 25
26#define pr_fmt(fmt) "IPv6: " fmt 26#define pr_fmt(fmt) "IPv6: " fmt
27 27
28#include <crypto/algapi.h>
28#include <crypto/hash.h> 29#include <crypto/hash.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <linux/slab.h> 31#include <linux/slab.h>
@@ -481,7 +482,7 @@ static void ah6_input_done(struct crypto_async_request *base, int err)
481 auth_data = ah_tmp_auth(work_iph, hdr_len); 482 auth_data = ah_tmp_auth(work_iph, hdr_len);
482 icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len); 483 icv = ah_tmp_icv(ahp->ahash, auth_data, ahp->icv_trunc_len);
483 484
484 err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0; 485 err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
485 if (err) 486 if (err)
486 goto out; 487 goto out;
487 488
@@ -627,7 +628,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb)
627 goto out_free; 628 goto out_free;
628 } 629 }
629 630
630 err = memcmp(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0; 631 err = crypto_memneq(icv, auth_data, ahp->icv_trunc_len) ? -EBADMSG : 0;
631 if (err) 632 if (err)
632 goto out_free; 633 goto out_free;
633 634