diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-04-03 00:37:15 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-04-04 09:45:51 -0400 |
commit | ef609c238a8ea163cb0af759cc73c9e2555c89da (patch) | |
tree | 99fc4f1518315e72c089626567a07dfd964c78ef /net | |
parent | 9735a22799b9214d17d3c231fe377fc852f042e9 (diff) |
sunrpc: Fix skcipher/shash conversion
The skcpiher/shash conversion introduced a number of bugs in the
sunrpc code:
1) Missing calls to skcipher_request_set_tfm lead to crashes.
2) The allocation size of shash_desc is too small which leads to
memory corruption.
Fixes: 3b5cf20cf439 ("sunrpc: Use skcipher and ahash/shash")
Reported-by: J. Bruce Fields <bfields@fieldses.org>
Tested-by: J. Bruce Fields <bfields@fieldses.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_crypto.c | 8 | ||||
-rw-r--r-- | net/sunrpc/auth_gss/gss_krb5_mech.c | 3 |
2 files changed, 8 insertions, 3 deletions
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c index d94a8e1e9f05..da26455cf86c 100644 --- a/net/sunrpc/auth_gss/gss_krb5_crypto.c +++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c | |||
@@ -78,6 +78,7 @@ krb5_encrypt( | |||
78 | memcpy(out, in, length); | 78 | memcpy(out, in, length); |
79 | sg_init_one(sg, out, length); | 79 | sg_init_one(sg, out, length); |
80 | 80 | ||
81 | skcipher_request_set_tfm(req, tfm); | ||
81 | skcipher_request_set_callback(req, 0, NULL, NULL); | 82 | skcipher_request_set_callback(req, 0, NULL, NULL); |
82 | skcipher_request_set_crypt(req, sg, sg, length, local_iv); | 83 | skcipher_request_set_crypt(req, sg, sg, length, local_iv); |
83 | 84 | ||
@@ -115,6 +116,7 @@ krb5_decrypt( | |||
115 | memcpy(out, in, length); | 116 | memcpy(out, in, length); |
116 | sg_init_one(sg, out, length); | 117 | sg_init_one(sg, out, length); |
117 | 118 | ||
119 | skcipher_request_set_tfm(req, tfm); | ||
118 | skcipher_request_set_callback(req, 0, NULL, NULL); | 120 | skcipher_request_set_callback(req, 0, NULL, NULL); |
119 | skcipher_request_set_crypt(req, sg, sg, length, local_iv); | 121 | skcipher_request_set_crypt(req, sg, sg, length, local_iv); |
120 | 122 | ||
@@ -946,7 +948,8 @@ krb5_rc4_setup_seq_key(struct krb5_ctx *kctx, struct crypto_skcipher *cipher, | |||
946 | return PTR_ERR(hmac); | 948 | return PTR_ERR(hmac); |
947 | } | 949 | } |
948 | 950 | ||
949 | desc = kmalloc(sizeof(*desc), GFP_KERNEL); | 951 | desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac), |
952 | GFP_KERNEL); | ||
950 | if (!desc) { | 953 | if (!desc) { |
951 | dprintk("%s: failed to allocate shash descriptor for '%s'\n", | 954 | dprintk("%s: failed to allocate shash descriptor for '%s'\n", |
952 | __func__, kctx->gk5e->cksum_name); | 955 | __func__, kctx->gk5e->cksum_name); |
@@ -1012,7 +1015,8 @@ krb5_rc4_setup_enc_key(struct krb5_ctx *kctx, struct crypto_skcipher *cipher, | |||
1012 | return PTR_ERR(hmac); | 1015 | return PTR_ERR(hmac); |
1013 | } | 1016 | } |
1014 | 1017 | ||
1015 | desc = kmalloc(sizeof(*desc), GFP_KERNEL); | 1018 | desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac), |
1019 | GFP_KERNEL); | ||
1016 | if (!desc) { | 1020 | if (!desc) { |
1017 | dprintk("%s: failed to allocate shash descriptor for '%s'\n", | 1021 | dprintk("%s: failed to allocate shash descriptor for '%s'\n", |
1018 | __func__, kctx->gk5e->cksum_name); | 1022 | __func__, kctx->gk5e->cksum_name); |
diff --git a/net/sunrpc/auth_gss/gss_krb5_mech.c b/net/sunrpc/auth_gss/gss_krb5_mech.c index 71341ccb9890..65427492b1c9 100644 --- a/net/sunrpc/auth_gss/gss_krb5_mech.c +++ b/net/sunrpc/auth_gss/gss_krb5_mech.c | |||
@@ -451,7 +451,8 @@ context_derive_keys_rc4(struct krb5_ctx *ctx) | |||
451 | goto out_err_free_hmac; | 451 | goto out_err_free_hmac; |
452 | 452 | ||
453 | 453 | ||
454 | desc = kmalloc(sizeof(*desc), GFP_KERNEL); | 454 | desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(hmac), |
455 | GFP_KERNEL); | ||
455 | if (!desc) { | 456 | if (!desc) { |
456 | dprintk("%s: failed to allocate hash descriptor for '%s'\n", | 457 | dprintk("%s: failed to allocate hash descriptor for '%s'\n", |
457 | __func__, ctx->gk5e->cksum_name); | 458 | __func__, ctx->gk5e->cksum_name); |