diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-10-09 15:43:38 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-10-14 10:23:17 -0400 |
commit | 9f5594c91e7cf5952ce39aff8b88c95a19a27e06 (patch) | |
tree | 0e12730e589ac63e0a054779cb21a51fac5a5def | |
parent | c4d007bcb42b3898df5ad65a513f9120ab0eccfc (diff) |
crypto: marvell/cesa - fix stack smashing in marvell/hash.c
Several of the algorithms in marvell/hash.c have a statesize of zero.
When an AF_ALG accept() on an already-accepted file descriptor to
calls into hash_accept(), this causes:
char state[crypto_ahash_statesize(crypto_ahash_reqtfm(req))];
to be zero-sized, but we still pass this to:
err = crypto_ahash_export(req, state);
which proceeds to write to 'state' as if it was a "struct md5_state",
"struct sha1_state" etc. Add the necessary initialisers for the
.statesize member.
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | drivers/crypto/marvell/hash.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c index ae9272eb9c1a..aa18324d09e3 100644 --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c | |||
@@ -872,6 +872,7 @@ struct ahash_alg mv_md5_alg = { | |||
872 | .import = mv_cesa_md5_import, | 872 | .import = mv_cesa_md5_import, |
873 | .halg = { | 873 | .halg = { |
874 | .digestsize = MD5_DIGEST_SIZE, | 874 | .digestsize = MD5_DIGEST_SIZE, |
875 | .statesize = sizeof(struct md5_state), | ||
875 | .base = { | 876 | .base = { |
876 | .cra_name = "md5", | 877 | .cra_name = "md5", |
877 | .cra_driver_name = "mv-md5", | 878 | .cra_driver_name = "mv-md5", |
@@ -961,6 +962,7 @@ struct ahash_alg mv_sha1_alg = { | |||
961 | .import = mv_cesa_sha1_import, | 962 | .import = mv_cesa_sha1_import, |
962 | .halg = { | 963 | .halg = { |
963 | .digestsize = SHA1_DIGEST_SIZE, | 964 | .digestsize = SHA1_DIGEST_SIZE, |
965 | .statesize = sizeof(struct sha1_state), | ||
964 | .base = { | 966 | .base = { |
965 | .cra_name = "sha1", | 967 | .cra_name = "sha1", |
966 | .cra_driver_name = "mv-sha1", | 968 | .cra_driver_name = "mv-sha1", |
@@ -1050,6 +1052,7 @@ struct ahash_alg mv_sha256_alg = { | |||
1050 | .import = mv_cesa_sha256_import, | 1052 | .import = mv_cesa_sha256_import, |
1051 | .halg = { | 1053 | .halg = { |
1052 | .digestsize = SHA256_DIGEST_SIZE, | 1054 | .digestsize = SHA256_DIGEST_SIZE, |
1055 | .statesize = sizeof(struct sha256_state), | ||
1053 | .base = { | 1056 | .base = { |
1054 | .cra_name = "sha256", | 1057 | .cra_name = "sha256", |
1055 | .cra_driver_name = "mv-sha256", | 1058 | .cra_driver_name = "mv-sha256", |