mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 22:09:30 +02:00
crypto: af_alg - Stop after finding name in allowlist
If the algorithm name is found in the allowlist and the privilege check doesn't pass, there's no need to consider remaining entries since the list contains (and is intended to contain) at most one entry per name. Signed-off-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
+7
-4
@@ -145,10 +145,13 @@ int af_alg_check_restriction(const char *name,
|
||||
if (level == 1) {
|
||||
for (const struct af_alg_allowlist_entry *ent = allowlist;
|
||||
ent->name; ent++) {
|
||||
if (strcmp(name, ent->name) == 0 &&
|
||||
((ent->flags & AF_ALG_UNPRIVILEGED) ||
|
||||
af_alg_capable()))
|
||||
return 0;
|
||||
if (strcmp(name, ent->name) == 0) {
|
||||
if ((ent->flags & AF_ALG_UNPRIVILEGED) ||
|
||||
af_alg_capable())
|
||||
return 0;
|
||||
/* List contains at most one entry per name. */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user