diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-28 13:02:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-28 13:02:44 -0400 |
commit | 6e041ffcc2d0bf8792937e89480b2172a9dd2823 (patch) | |
tree | 60bc2ee16c276c10dcb28592a1bc58daf5c9655f | |
parent | cac264288abe0f54b91e51d97c949b706c9435c7 (diff) | |
parent | eea0d3ea7546961f69f55b26714ac8fd71c7c020 (diff) |
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu:
- crypto API regression that may cause sporadic alloc failures
- double-free bug in drbg
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: drbg - set freed buffers to NULL
crypto: api - fix finding algorithm currently being tested
-rw-r--r-- | crypto/api.c | 11 | ||||
-rw-r--r-- | crypto/drbg.c | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/crypto/api.c b/crypto/api.c index 1d5290c67108..0ee632bba064 100644 --- a/crypto/api.c +++ b/crypto/api.c | |||
@@ -204,9 +204,14 @@ static struct crypto_alg *crypto_alg_lookup(const char *name, u32 type, | |||
204 | 204 | ||
205 | down_read(&crypto_alg_sem); | 205 | down_read(&crypto_alg_sem); |
206 | alg = __crypto_alg_lookup(name, type | test, mask | test); | 206 | alg = __crypto_alg_lookup(name, type | test, mask | test); |
207 | if (!alg && test) | 207 | if (!alg && test) { |
208 | alg = __crypto_alg_lookup(name, type, mask) ? | 208 | alg = __crypto_alg_lookup(name, type, mask); |
209 | ERR_PTR(-ELIBBAD) : NULL; | 209 | if (alg && !crypto_is_larval(alg)) { |
210 | /* Test failed */ | ||
211 | crypto_mod_put(alg); | ||
212 | alg = ERR_PTR(-ELIBBAD); | ||
213 | } | ||
214 | } | ||
210 | up_read(&crypto_alg_sem); | 215 | up_read(&crypto_alg_sem); |
211 | 216 | ||
212 | return alg; | 217 | return alg; |
diff --git a/crypto/drbg.c b/crypto/drbg.c index 4faa2781c964..466a112a4446 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c | |||
@@ -1134,8 +1134,10 @@ static inline void drbg_dealloc_state(struct drbg_state *drbg) | |||
1134 | if (!drbg) | 1134 | if (!drbg) |
1135 | return; | 1135 | return; |
1136 | kzfree(drbg->Vbuf); | 1136 | kzfree(drbg->Vbuf); |
1137 | drbg->Vbuf = NULL; | ||
1137 | drbg->V = NULL; | 1138 | drbg->V = NULL; |
1138 | kzfree(drbg->Cbuf); | 1139 | kzfree(drbg->Cbuf); |
1140 | drbg->Cbuf = NULL; | ||
1139 | drbg->C = NULL; | 1141 | drbg->C = NULL; |
1140 | kzfree(drbg->scratchpadbuf); | 1142 | kzfree(drbg->scratchpadbuf); |
1141 | drbg->scratchpadbuf = NULL; | 1143 | drbg->scratchpadbuf = NULL; |