fsverity: explicitly check that there is no algorithm 0
JIRA: https://issues.redhat.com/browse/RHEL-29914 commit 5d37a1198068b099de47073411efc087d1b555ca Author: Eric Biggers <ebiggers@google.com> Date: Wed Jul 5 14:17:19 2023 -0700 fsverity: explicitly check that there is no algorithm 0 Since libfsverity and some other code would break if 0 is ever allocated as an FS_VERITY_HASH_ALG_* value, make fsverity_check_hash_algs() explicitly check that there is no algorithm 0. Link: https://lore.kernel.org/r/20230705211719.37713-1-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
This commit is contained in:
parent
6e1a76bb7b
commit
45439212db
|
@ -226,6 +226,14 @@ void __init fsverity_check_hash_algs(void)
|
|||
if (!alg->name)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* 0 must never be allocated as an FS_VERITY_HASH_ALG_* value,
|
||||
* as it is reserved for users that use 0 to mean unspecified or
|
||||
* a default value. fs/verity/ itself doesn't care and doesn't
|
||||
* have a default algorithm, but some users make use of this.
|
||||
*/
|
||||
BUG_ON(i == 0);
|
||||
|
||||
BUG_ON(alg->digest_size > FS_VERITY_MAX_DIGEST_SIZE);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue