Skip to content

Commit 0ec1387

Browse files
committed
crypto: api - Fix larval relookup type and mask
jira LE-3460 Rebuild_History Non-Buildable kernel-6.12.0-55.11.1.el10_0 commit-author Herbert Xu <[email protected]> commit 7505436 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 <[email protected]> Fixes: 96ad595 ("crypto: api - Remove instance larval fulfilment") Signed-off-by: Herbert Xu <[email protected]> (cherry picked from commit 7505436) Signed-off-by: Jonathan Maple <[email protected]>
1 parent eb46070 commit 0ec1387

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

crypto/api.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ EXPORT_SYMBOL_GPL(crypto_chain);
3636
DEFINE_STATIC_KEY_FALSE(__crypto_boot_test_finished);
3737
#endif
3838

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);
4041
static struct crypto_alg *crypto_alg_lookup(const char *name, u32 type,
4142
u32 mask);
4243

@@ -145,7 +146,7 @@ static struct crypto_alg *crypto_larval_add(const char *name, u32 type,
145146
if (alg != &larval->alg) {
146147
kfree(larval);
147148
if (crypto_is_larval(alg))
148-
alg = crypto_larval_wait(alg);
149+
alg = crypto_larval_wait(alg, type, mask);
149150
}
150151

151152
return alg;
@@ -197,7 +198,8 @@ static void crypto_start_test(struct crypto_larval *larval)
197198
crypto_schedule_test(larval);
198199
}
199200

200-
static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
201+
static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg,
202+
u32 type, u32 mask)
201203
{
202204
struct crypto_larval *larval;
203205
long time_left;
@@ -219,12 +221,7 @@ static struct crypto_alg *crypto_larval_wait(struct crypto_alg *alg)
219221
crypto_larval_kill(larval);
220222
alg = ERR_PTR(-ETIMEDOUT);
221223
} else if (!alg) {
222-
u32 type;
223-
u32 mask;
224-
225224
alg = &larval->alg;
226-
type = alg->cra_flags & ~(CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD);
227-
mask = larval->mask;
228225
alg = crypto_alg_lookup(alg->cra_name, type, mask) ?:
229226
ERR_PTR(-EAGAIN);
230227
} else if (IS_ERR(alg))
@@ -304,7 +301,7 @@ static struct crypto_alg *crypto_larval_lookup(const char *name, u32 type,
304301
}
305302

306303
if (!IS_ERR_OR_NULL(alg) && crypto_is_larval(alg))
307-
alg = crypto_larval_wait(alg);
304+
alg = crypto_larval_wait(alg, type, mask);
308305
else if (alg)
309306
;
310307
else if (!(mask & CRYPTO_ALG_TESTED))
@@ -352,7 +349,7 @@ struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask)
352349
ok = crypto_probing_notify(CRYPTO_MSG_ALG_REQUEST, larval);
353350

354351
if (ok == NOTIFY_STOP)
355-
alg = crypto_larval_wait(larval);
352+
alg = crypto_larval_wait(larval, type, mask);
356353
else {
357354
crypto_mod_put(larval);
358355
alg = ERR_PTR(-ENOENT);

0 commit comments

Comments
 (0)