projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
06c2afb
)
fsverity: explicitly check that there is no algorithm 0
author
Eric Biggers
<ebiggers@google.com>
Wed, 5 Jul 2023 21:17:19 +0000
(14:17 -0700)
committer
Eric Biggers
<ebiggers@google.com>
Wed, 12 Jul 2023 05:49:18 +0000
(22:49 -0700)
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>
fs/verity/hash_algs.c
patch
|
blob
|
history
diff --git
a/fs/verity/hash_algs.c
b/fs/verity/hash_algs.c
index c598d20354763156b6dfaee044a69fca385697bc..6b08b1d9a7d7c49baf287a402ad1ac105fbb5614 100644
(file)
--- a/
fs/verity/hash_algs.c
+++ b/
fs/verity/hash_algs.c
@@
-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);
/*