aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/aead.c
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2013-02-05 12:19:13 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2013-02-19 07:27:03 -0500
commit9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6 (patch)
tree321e685947c9d47ca369efabb061bf50e1921c1d /crypto/aead.c
parent7eb9c5df92361c55daab4d8d4e8468eb774e297b (diff)
crypto: user - fix info leaks in report API
Three errors resulting in kernel memory disclosure: 1/ The structures used for the netlink based crypto algorithm report API are located on the stack. As snprintf() does not fill the remainder of the buffer with null bytes, those stack bytes will be disclosed to users of the API. Switch to strncpy() to fix this. 2/ crypto_report_one() does not initialize all field of struct crypto_user_alg. Fix this to fix the heap info leak. 3/ For the module name we should copy only as many bytes as module_name() returns -- not as much as the destination buffer could hold. But the current code does not and therefore copies random data from behind the end of the module name, as the module name is always shorter than CRYPTO_MAX_ALG_NAME. Also switch to use strncpy() to copy the algorithm's name and driver_name. They are strings, after all. Signed-off-by: Mathias Krause <minipli@googlemail.com> Cc: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/aead.c')
-rw-r--r--crypto/aead.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/crypto/aead.c b/crypto/aead.c
index 4d04e12ffde8..547491e35c63 100644
--- a/crypto/aead.c
+++ b/crypto/aead.c
@@ -117,9 +117,8 @@ static int crypto_aead_report(struct sk_buff *skb, struct crypto_alg *alg)
117 struct crypto_report_aead raead; 117 struct crypto_report_aead raead;
118 struct aead_alg *aead = &alg->cra_aead; 118 struct aead_alg *aead = &alg->cra_aead;
119 119
120 snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "aead"); 120 strncpy(raead.type, "aead", sizeof(raead.type));
121 snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s", 121 strncpy(raead.geniv, aead->geniv ?: "<built-in>", sizeof(raead.geniv));
122 aead->geniv ?: "<built-in>");
123 122
124 raead.blocksize = alg->cra_blocksize; 123 raead.blocksize = alg->cra_blocksize;
125 raead.maxauthsize = aead->maxauthsize; 124 raead.maxauthsize = aead->maxauthsize;
@@ -203,8 +202,8 @@ static int crypto_nivaead_report(struct sk_buff *skb, struct crypto_alg *alg)
203 struct crypto_report_aead raead; 202 struct crypto_report_aead raead;
204 struct aead_alg *aead = &alg->cra_aead; 203 struct aead_alg *aead = &alg->cra_aead;
205 204
206 snprintf(raead.type, CRYPTO_MAX_ALG_NAME, "%s", "nivaead"); 205 strncpy(raead.type, "nivaead", sizeof(raead.type));
207 snprintf(raead.geniv, CRYPTO_MAX_ALG_NAME, "%s", aead->geniv); 206 strncpy(raead.geniv, aead->geniv, sizeof(raead.geniv));
208 207
209 raead.blocksize = alg->cra_blocksize; 208 raead.blocksize = alg->cra_blocksize;
210 raead.maxauthsize = aead->maxauthsize; 209 raead.maxauthsize = aead->maxauthsize;