fsverity: use unsigned long for level_start
authorEric Biggers <ebiggers@google.com>
Fri, 23 Dec 2022 20:36:28 +0000 (12:36 -0800)
committerEric Biggers <ebiggers@google.com>
Tue, 10 Jan 2023 03:05:47 +0000 (19:05 -0800)
commit284d5db5f99efa9e3549eb3cba39379d48879db1
tree992acc4d74a9accc0bdbb1f73b0b4ac2d311346e
parent86f66569baca98478b7ff2f49c8ee54cf3b108cd
fsverity: use unsigned long for level_start

fs/verity/ isn't consistent with whether Merkle tree block indices are
'unsigned long' or 'u64'.  There's no real point to using u64 for them,
though, since (a) a Merkle tree with over ULONG_MAX blocks would only be
needed for a file larger than MAX_LFS_FILESIZE, and (b) for reads, the
status of all Merkle tree blocks has to be tracked in memory.

Therefore, let's make things a bit more efficient on 32-bit systems by
using 'unsigned long[]' for merkle_tree_params::level_start, instead of
'u64[]'.  Also, to be extra safe, explicitly check that there aren't
more than ULONG_MAX Merkle tree blocks.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com>
Tested-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://lore.kernel.org/r/20221223203638.41293-2-ebiggers@kernel.org
fs/verity/fsverity_private.h
fs/verity/open.c