]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
generic/574: test corruption at more offsets
authorEric Biggers <ebiggers@google.com>
Wed, 12 Jun 2024 03:53:34 +0000 (20:53 -0700)
committerZorro Lang <zlang@kernel.org>
Fri, 21 Jun 2024 16:38:24 +0000 (00:38 +0800)
Expand generic/574 to test for corruption in more different parts of the
file to try to exercise any hashing optimizations that might be used.

There is no existing bug that this finds.  This is just to prevent
future bugs, considering optimizations along the lines of
https://lore.kernel.org/fsverity/20240611034822.36603-7-ebiggers@kernel.org/

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/generic/574

index d44c23e5abc273c85d2d42aace253c18e979e544..bc0b17a0cde91707f523e1a52a354f188af2a2d6 100755 (executable)
@@ -168,6 +168,21 @@ test_block_size()
        corruption_test $block_size 131072 65536 65536
        corruption_test $block_size 131072 131067 5
 
+       # Test corrupting a block in files of length 1..4 blocks, and test
+       # corrupting each block of a 4-block file.  This ensures that all code
+       # paths that might exist due to multi-block hashing optimizations the
+       # fsverity implementation may use get covered, assuming no more than 4
+       # blocks are hashed at once.  E.g., consider an fsverity implementation
+       # that verifies sets of blocks but has a bug when given a single block,
+       # or that has a bug that makes it not verify all the blocks of each set.
+       local i
+       for i in $(seq 1 4); do
+               corruption_test $block_size $((i*block_size)) $((block_size/2)) 5
+       done
+       for i in $(seq 0 3); do
+               corruption_test $block_size $((4*block_size)) $((i*block_size)) 5
+       done
+
        corrupt_eof_block_test $block_size 130999 72
 
        # Merkle tree corruption.