Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: api - Fix larval relookup type and mask

When the lookup is retried after instance construction, it uses
the type and mask from the larval, which may not match the values
used by the caller. For example, if the caller is requesting for
a !NEEDS_FALLBACK algorithm, it may end up getting an algorithm
that needs fallbacks.

Fix this by making the caller supply the type/mask and using that
for the lookup.

Reported-by: Coiby Xu <coxu@redhat.com>
Fixes: 96ad59552059 ("crypto: api - Remove instance larval fulfilment")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+7 -10
+7 -10
crypto/api.c
··· 36 36 DEFINE_STATIC_KEY_FALSE(__crypto_boot_test_finished); 37 37 #endif 38 38 39 - static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg); 39 + static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg, 40 + u32 type, u32 mask); 40 41 static struct crypto_alg *crypto_alg_lookup(const char *name, u32 type, 41 42 u32 mask); 42 43 ··· 146 145 if (alg != &larval->alg) { 147 146 kfree(larval); 148 147 if (crypto_is_larval(alg)) 149 - alg = crypto_larval_wait(alg); 148 + alg = crypto_larval_wait(alg, type, mask); 150 149 } 151 150 152 151 return alg; ··· 198 197 crypto_schedule_test(larval); 199 198 } 200 199 201 - static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg) 200 + static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg, 201 + u32 type, u32 mask) 202 202 { 203 203 struct crypto_larval *larval; 204 204 long time_left; ··· 221 219 crypto_larval_kill(larval); 222 220 alg = ERR_PTR(-ETIMEDOUT); 223 221 } else if (!alg) { 224 - u32 type; 225 - u32 mask; 226 - 227 222 alg = &larval->alg; 228 - type = alg->cra_flags & ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD); 229 - mask = larval->mask; 230 223 alg = crypto_alg_lookup(alg->cra_name, type, mask) ?: 231 224 ERR_PTR(-EAGAIN); 232 225 } else if (IS_ERR(alg)) ··· 301 304 } 302 305 303 306 if (!IS_ERR_OR_NULL(alg) && crypto_is_larval(alg)) 304 - alg = crypto_larval_wait(alg); 307 + alg = crypto_larval_wait(alg, type, mask); 305 308 else if (alg) 306 309 ; 307 310 else if (!(mask & CRYPTO_ALG_TESTED)) ··· 349 352 ok = crypto_probing_notify(CRYPTO_MSG_ALG_REQUEST, larval); 350 353 351 354 if (ok == NOTIFY_STOP) 352 - alg = crypto_larval_wait(larval); 355 + alg = crypto_larval_wait(larval, type, mask); 353 356 else { 354 357 crypto_mod_put(larval); 355 358 alg = ERR_PTR(-ENOENT);