linux-fscrypt.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] generic/574: remove invalid test of read completely past EOF
@ 2021-11-08  4:36 Eric Biggers
  0 siblings, 0 replies; only message in thread
From: Eric Biggers @ 2021-11-08  4:36 UTC (permalink / raw)
  To: fstests; +Cc: linux-fscrypt, David Howells

From: Eric Biggers <ebiggers@google.com>

One of the test cases in generic/574 tests that if a file of length
130999 has fs-verity enabled, and if bytes 131000..131071 (i.e. some
bytes past EOF and in the same block as EOF) are corrupted with nonzero
values, then reads of the corrupted part should fail with EIO.

This isn't a valid test case, because reads that start at or past EOF
are allowed to simply return 0 without doing any I/O.

Therefore, don't run this test case.

This fixes a test failure caused by the kernel commit 8c8387ee3f55
("mm: stop filemap_read() from grabbing a superfluous page").

Note that the other test cases for this same corrupted file remain
valid, including testing that an error is reported during full file
reads and during mmap "reads".  This is because the fs-verity Merkle
tree is defined over full blocks, so the file's last block won't be
readable if it contains corrupted (nonzero) bytes past EOF.  This may
seem odd, but it's working as intended, especially considering that
bytes past EOF in a file's last block are exposed to userspace in mmaps.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 tests/generic/574     | 2 +-
 tests/generic/574.out | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/tests/generic/574 b/tests/generic/574
index df0ef95f..882baa21 100755
--- a/tests/generic/574
+++ b/tests/generic/574
@@ -106,7 +106,7 @@ corruption_test()
 	dd if=$fsv_file bs=$FSV_BLOCK_SIZE iflag=direct status=none \
 		of=/dev/null |& _filter_scratch
 
-	if ! $is_merkle_tree; then
+	if (( zap_offset < file_len )) && ! $is_merkle_tree; then
 		echo "Validating corruption (reading just corrupted part)..."
 		dd if=$fsv_file bs=1 skip=$zap_offset count=$zap_len \
 			of=/dev/null status=none |& _filter_scratch
diff --git a/tests/generic/574.out b/tests/generic/574.out
index d43474c5..3c08d3e8 100644
--- a/tests/generic/574.out
+++ b/tests/generic/574.out
@@ -63,8 +63,6 @@ Validating corruption (reading full file)...
 md5sum: SCRATCH_MNT/file.fsv: Input/output error
 Validating corruption (direct I/O)...
 dd: error reading 'SCRATCH_MNT/file.fsv': Input/output error
-Validating corruption (reading just corrupted part)...
-dd: error reading 'SCRATCH_MNT/file.fsv': Input/output error
 Validating corruption (reading full file via mmap)...
 Bus error
 Validating corruption (reading just corrupted part via mmap)...
-- 
2.33.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-08  4:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-08  4:36 [PATCH] generic/574: remove invalid test of read completely past EOF Eric Biggers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).