Commit a70c522520d967844c01fa01459edc698fc54544
1 parent
faae890883
Exists in
master
and in
39 other branches
crypto: ahash - Fix setkey crash
When the alignment check was made unconditional for ahash we may end up crashing on shash algorithms because we're always calling alg->setkey instead of tfm->setkey. This patch fixes it. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 1 changed file with 2 additions and 4 deletions Side-by-side Diff
crypto/ahash.c
... | ... | @@ -145,7 +145,6 @@ |
145 | 145 | static int ahash_setkey_unaligned(struct crypto_ahash *tfm, const u8 *key, |
146 | 146 | unsigned int keylen) |
147 | 147 | { |
148 | - struct ahash_alg *ahash = crypto_ahash_alg(tfm); | |
149 | 148 | unsigned long alignmask = crypto_ahash_alignmask(tfm); |
150 | 149 | int ret; |
151 | 150 | u8 *buffer, *alignbuffer; |
... | ... | @@ -158,7 +157,7 @@ |
158 | 157 | |
159 | 158 | alignbuffer = (u8 *)ALIGN((unsigned long)buffer, alignmask + 1); |
160 | 159 | memcpy(alignbuffer, key, keylen); |
161 | - ret = ahash->setkey(tfm, alignbuffer, keylen); | |
160 | + ret = tfm->setkey(tfm, alignbuffer, keylen); | |
162 | 161 | kzfree(buffer); |
163 | 162 | return ret; |
164 | 163 | } |
165 | 164 | |
... | ... | @@ -166,13 +165,12 @@ |
166 | 165 | int crypto_ahash_setkey(struct crypto_ahash *tfm, const u8 *key, |
167 | 166 | unsigned int keylen) |
168 | 167 | { |
169 | - struct ahash_alg *ahash = crypto_ahash_alg(tfm); | |
170 | 168 | unsigned long alignmask = crypto_ahash_alignmask(tfm); |
171 | 169 | |
172 | 170 | if ((unsigned long)key & alignmask) |
173 | 171 | return ahash_setkey_unaligned(tfm, key, keylen); |
174 | 172 | |
175 | - return ahash->setkey(tfm, key, keylen); | |
173 | + return tfm->setkey(tfm, key, keylen); | |
176 | 174 | } |
177 | 175 | EXPORT_SYMBOL_GPL(crypto_ahash_setkey); |
178 | 176 |