Skip to contentSkip to conversation

tests for btrfs fsverity

PATCH Superseded Boris Burkov 2 participants 10 messages Feb 15, 2022 – Mar 15, 2022

Subsystems (2)

v6 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#0 lore raw

v6 cover tests for btrfs fsverity

This patchset provides tests for fsverity support in btrfs.

It includes modifications for generic tests to pass with btrfs as well as new tests.

--
v6:
- refactor "requires" for verity corruption tests so that other verity tests can run on btrfs even without the corruption command available. Also, explictly require xfs_io fiemap for all corruption tests.
- simplify and clarify "non-trivial EFBIG" calculation and documentation per suggestions by Eric Biggers.
- remove unnecessary adjustment to max file size in the new EFBIG test; the bug it worked around has been fixed.
v5:
- more idiomatic requires structure for making efbig test generic
- make efbig test use truncate instead of pwrite for making a big file
- improve documentation for efbig test approximation
- fix underscores vs dashes in btrfs_requires_corrupt_block
- improvements in missing/redundant requires invocations
- move orphan test image file to $TEST_DIR
- make orphan test replay/snapshot device size depend on log device instead of hard-coding it.
- rebase (signicant: no more "groups" file; use preamble) v4:
- mark local variables
- get rid of redundant mounts and syncs
- use '_' in function names correctly
- add a test for the EFBIG case
- reduce usage of requires_btrfs_corrupt_block
- handle variable input when corrupting merkle tree
v3: rebase onto xfstests master branch
v2: pass generic tests, add logwrites test

Boris Burkov (4):
btrfs: test btrfs specific fsverity corruption
generic/574: corrupt btrfs merkle tree data
btrfs: test verity orphans with dmlogwrites
generic: test fs-verity EFBIG scenarios

 common/btrfs          |   5 ++
 common/config         |   1 +
 common/verity         |  43 +++++++++++
 tests/btrfs/290       | 166 ++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/290.out   |  25 +++++++
 tests/btrfs/291       | 161 ++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/291.out   |   2 +
 tests/generic/574     |   1 +
 tests/generic/690     |  66 +++++++++++++++++
 tests/generic/690.out |   7 ++
 10 files changed, 477 insertions(+)
 create mode 100755 tests/btrfs/290
 create mode 100644 tests/btrfs/290.out
 create mode 100755 tests/btrfs/291
 create mode 100644 tests/btrfs/291.out
 create mode 100755 tests/generic/690
 create mode 100644 tests/generic/690.out
Signature · 1 line
2.34.0
#1 lore raw

PATCH v6 1/4 btrfs: test btrfs specific fsverity corruption

There are some btrfs specific fsverity scenarios that don't map neatly onto the tests in generic/574 like holes, inline extents, and preallocated extents. Cover those in a btrfs specific test.

This test relies on the btrfs implementation of fsverity in the patch:
btrfs: initial fsverity support

and on btrfs-corrupt-block for corruption in the patches titled:
btrfs-progs: corrupt generic item data with btrfs-corrupt-block
btrfs-progs: expand corrupt_file_extent in btrfs-corrupt-block

---
 common/btrfs        |   5 ++
 common/config       |   1 +
 common/verity       |  14 ++++
 tests/btrfs/290     | 166 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/290.out |  25 +++++++
 5 files changed, 211 insertions(+)
 create mode 100755 tests/btrfs/290
 create mode 100644 tests/btrfs/290.out
common/btrfs +5 -0
index 5de926dd..6eb574be 100644
@@ -496,3 +496,8 @@ _require_btrfs_support_sectorsize()
 	grep -wq $sectorsize /sys/fs/btrfs/features/supported_sectorsizes || \
 		_notrun "sectorsize $sectorsize is not supported"
 }
+
+_require_btrfs_corrupt_block()
+{
+	_require_command "$BTRFS_CORRUPT_BLOCK_PROG" btrfs-corrupt-block
+}
common/config +1 -0
index 0566ab4a..8cda36be 100644
@@ -295,6 +295,7 @@ export BTRFS_UTIL_PROG=$(type -P btrfs)
 export BTRFS_SHOW_SUPER_PROG=$(type -P btrfs-show-super)
 export BTRFS_CONVERT_PROG=$(type -P btrfs-convert)
 export BTRFS_TUNE_PROG=$(type -P btrfstune)
+export BTRFS_CORRUPT_BLOCK_PROG=$(type -P btrfs-corrupt-block)
 export XFS_FSR_PROG=$(type -P xfs_fsr)
 export MKFS_NFS_PROG="false"
 export MKFS_CIFS_PROG="false"
common/verity +14 -0
index 38eea157..eec8ae72 100644
@@ -3,6 +3,8 @@
 #
 # Functions for setting up and testing fs-verity
 
+. common/btrfs
+
 _require_scratch_verity()
 {
 	_require_scratch
@@ -48,6 +50,15 @@ _require_scratch_verity()
 	FSV_BLOCK_SIZE=$(get_page_size)
 }
 
+# Check for userspace tools needed to corrupt verity data or metadata.
+_require_fsverity_corruption()
+{
+	_require_xfs_io_command "fiemap"
+	if [ $FSTYP == "btrfs" ]; then
+		_require_btrfs_corrupt_block
+	fi
+}
+
 # Check for CONFIG_FS_VERITY_BUILTIN_SIGNATURES=y, as well as the userspace
 # commands needed to generate certificates and add them to the kernel.
 _require_fsverity_builtin_signatures()
@@ -147,6 +158,9 @@ _scratch_mkfs_verity()
 	ext4|f2fs)
 		_scratch_mkfs -O verity
 		;;
+	btrfs)
+		_scratch_mkfs
+		;;
 	*)
 		_notrun "No verity support for $FSTYP"
 		;;
tests/btrfs/290 new file +166 -0

166 lines not on this page · raw message

tests/btrfs/290.out new file +25 -0
new file mode 100644
index 00000000..056b114b
@@ -0,0 +1,25 @@
+QA output created by 290
+inl
+pread: Input/output error
+pread: Input/output error
+prealloc
+pread: Input/output error
+pread: Input/output error
+reg
+pread: Input/output error
+pread: Input/output error
+punch
+pread: Input/output error
+pread: Input/output error
+plug
+pread: Input/output error
+pread: Input/output error
+desc
+SCRATCH_MNT/desc: Invalid argument
+SCRATCH_MNT/desc: Invalid argument
+roothash
+pread: Input/output error
+pread: Input/output error
+merkle
+pread: Input/output error
+pread: Input/output error
Signature · 1 line
2.34.0
maintainer
#2 lore raw

Re: [PATCH v6 1/4] btrfs: test btrfs specific fsverity corruption

common/verity line 6

Quoted 9 lines · Boris Burkov
common/verity +1 -0
index 38eea157..eec8ae72 100644
@@ -3,6 +3,8 @@
 #
 # Functions for setting up and testing fs-verity
 
+. common/btrfs

Why does common/btrfs need to be included here?

common/verity _require_scratch_verity() · line 60

Quoted 8 lines
common/verity +8 -0
+# Check for userspace tools needed to corrupt verity data or metadata.
+_require_fsverity_corruption()
+{
+	_require_xfs_io_command "fiemap"
+	if [ $FSTYP == "btrfs" ]; then
+		_require_btrfs_corrupt_block
+	fi
+}

Which function(s), specifically, is this function a prerequisite for? Based on the name, it sounds like it would be a prerequisite for calling _fsv_scratch_corrupt_bytes() and _fsv_scratch_corrupt_merkle_tree(). But that's apparently not the case, seeing as generic/576 calls _fsv_scratch_corrupt_bytes() but doesn't call _require_fsverity_corruption(), and your new test btrfs/290 calls _require_fsverity_corruption() but doesn't call either _fsv_scratch_corrupt_bytes() or _fsv_scratch_corrupt_merkle_tree().

So, the purpose of this function is unclear.

Perhaps it should be a prerequisite for all _fsv_scratch_corrupt*() functions, and btrfs/290 should check for btrfs-corrupt-block directly?

- Eric

#3 lore raw

Re: [PATCH v6 1/4] btrfs: test btrfs specific fsverity corruption

Quoted 9 lines · Eric Biggers
Quoted 8 lines · Boris Burkov
common/verity +0 -0
index 38eea157..eec8ae72 100644
@@ -3,6 +3,8 @@
 #
 # Functions for setting up and testing fs-verity
 
Quoted 3 lines

common/verity line 6

Quoted 1 line
common/verity +1 -0
+. common/btrfs

Why does common/btrfs need to be included here?

To get _require_btrfs_corrupt_block. I can move that in here, as it doesn't have any non-verity use case in btrfs tests yet. But it should probably stay a named function rather than get rolled into require_fsverity_corruption if I make btrfs/290 use it directly (which I think is a good suggestion).

Quoted 18 lines

common/verity _require_scratch_verity() · line 60

Quoted 9 lines
common/verity +8 -0
+# Check for userspace tools needed to corrupt verity data or metadata.
+_require_fsverity_corruption()
+{
+	_require_xfs_io_command "fiemap"
+	if [ $FSTYP == "btrfs" ]; then
+		_require_btrfs_corrupt_block
+	fi
+}

Which function(s), specifically, is this function a prerequisite for? Based on the name, it sounds like it would be a prerequisite for calling _fsv_scratch_corrupt_bytes() and _fsv_scratch_corrupt_merkle_tree(). But that's apparently not the case, seeing as generic/576 calls _fsv_scratch_corrupt_bytes() but doesn't call _require_fsverity_corruption(), and your new test btrfs/290 calls _require_fsverity_corruption() but doesn't call either _fsv_scratch_corrupt_bytes() or _fsv_scratch_corrupt_merkle_tree().

Quoted 4 lines

So, the purpose of this function is unclear.

Perhaps it should be a prerequisite for all _fsv_scratch_corrupt*() functions, and btrfs/290 should check for btrfs-corrupt-block directly?

My intent was for it to be a requirement for _fsv_scratch_corrupt_bytes and _fsv_scratch_corrupt_merkle_tree, but I missed 576, since I was testing with btrfs and that doesn't have transparent encryption. Apologies for missing that test. I'll make _require_fsverity_corruption 1:1 with _fsv_scratch_corrupt_bytes. However, I believe I still need btrfs_corrupt_block here, since that is part of the "generic" corruption for btrfs.

Quoted 2 lines

- Eric

#4 lore raw

PATCH v6 2/4 generic/574: corrupt btrfs merkle tree data

In reply to Boris Burkov

generic/574 has tests for corrupting the merkle tree data stored by the filesystem. Since btrfs uses a different scheme for storing this data, the existing logic for corrupting it doesn't work out of the box. Adapt it to properly corrupt btrfs merkle items.

This test relies on the btrfs implementation of fsverity in the patch:
btrfs: initial fsverity support

and on btrfs-corrupt-block for corruption in the patches titled:
btrfs-progs: corrupt generic item data with btrfs-corrupt-block
btrfs-progs: expand corrupt_file_extent in btrfs-corrupt-block

---
 common/verity     | 18 ++++++++++++++++++
 tests/generic/574 |  1 +
 2 files changed, 19 insertions(+)
common/verity +18 -0
index eec8ae72..07d9d3fe 100644
@@ -322,6 +322,24 @@ _fsv_scratch_corrupt_merkle_tree()
 		(( offset += ($(_get_filesize $file) + 65535) & ~65535 ))
 		_fsv_scratch_corrupt_bytes $file $offset
 		;;
+	btrfs)
+		local ino=$(stat -c '%i' $file)
+		_scratch_unmount
+		local byte=""
+		while read -n 1 byte; do
+			if [ -z $byte ]; then
+				break
+			fi
+			local ascii=$(printf "%d" "'$byte'")
+			# This command will find a Merkle tree item for the inode (-I $ino,37,0)
+			# in the default filesystem tree (-r 5) and corrupt one byte (-b 1) at
+			# $offset (-o $offset) with the ascii representation of the byte we read
+			# (-v $ascii)
+			$BTRFS_CORRUPT_BLOCK_PROG -r 5 -I $ino,37,0 -v $ascii -o $offset -b 1 $SCRATCH_DEV
+			(( offset += 1 ))
+		done
+		_scratch_mount
+		;;
 	*)
 		_fail "_fsv_scratch_corrupt_merkle_tree() unimplemented on $FSTYP"
 		;;
tests/generic/574 +1 -0
index 882baa21..6cb7eff6 100755
@@ -27,6 +27,7 @@ _cleanup()
 # real QA test starts here
 _supported_fs generic
 _require_scratch_verity
+_require_fsverity_corruption
 _disable_fsverity_signatures
 
 _scratch_mkfs_verity &>> $seqres.full
Signature · 1 line
2.34.0
maintainer
#5 lore raw

Re: [PATCH v6 2/4] generic/574: corrupt btrfs merkle tree data

Quoted 24 lines · Boris Burkov

generic/574 has tests for corrupting the merkle tree data stored by the filesystem. Since btrfs uses a different scheme for storing this data, the existing logic for corrupting it doesn't work out of the box. Adapt it to properly corrupt btrfs merkle items.

This test relies on the btrfs implementation of fsverity in the patch:
btrfs: initial fsverity support

and on btrfs-corrupt-block for corruption in the patches titled:
btrfs-progs: corrupt generic item data with btrfs-corrupt-block
btrfs-progs: expand corrupt_file_extent in btrfs-corrupt-block

---
 common/verity     | 18 ++++++++++++++++++
 tests/generic/574 |  1 +
 2 files changed, 19 insertions(+)
common/verity +0 -0
index eec8ae72..07d9d3fe 100644
@@ -322,6 +322,24 @@ _fsv_scratch_corrupt_merkle_tree()
 		(( offset += ($(_get_filesize $file) + 65535) & ~65535 ))

common/verity _fsv_scratch_corrupt_merkle_tree() · line 332

Quoted 10 lines
common/verity +8 -0
 		_fsv_scratch_corrupt_bytes $file $offset
 		;;
+	btrfs)
+		local ino=$(stat -c '%i' $file)
+		_scratch_unmount
+		local byte=""
+		while read -n 1 byte; do
+			if [ -z $byte ]; then
+				break
+			fi

'[ -z $byte ]' could use quotes around $byte. But isn't that check unneeded at all, given that 'read' will fail when EOF is reached?

- Eric

#6 lore raw

PATCH v6 3/4 btrfs: test verity orphans with dmlogwrites

In reply to Boris Burkov

The behavior of orphans is most interesting across mounts, interrupted at arbitrary points during fsverity enable. To cover as many such cases as possible, use dmlogwrites and dmsnapshot as in log-writes/replay-individual.sh. At each log entry, we want to assert a somewhat complicated invariant:

If verity has not yet started: an orphan indicates that verity has started.
If verity has started: mount should handle the orphan and blow away verity data: expect 0 merkle items after mounting the snapshot dev. If we can measure the file, verity has finished.
If verity has finished: the orphan should be gone, so mount should not blow away merkle items. Expect the same number of merkle items before and after mounting the snapshot dev.

Note that this relies on grepping btrfs inspect-internal dump-tree. Until btrfs-progs has the ability to print the new Merkle items, they will show up as UNKNOWN.36/37.

---
 tests/btrfs/291     | 161 ++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/291.out |   2 +
 2 files changed, 163 insertions(+)
 create mode 100755 tests/btrfs/291
 create mode 100644 tests/btrfs/291.out
tests/btrfs/291 new file +161 -0
new file mode 100755
index 00000000..1bb3f1b3
@@ -0,0 +1,161 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2021 Facebook, Inc. All Rights Reserved.
+#
+# FS QA Test 291
+#
+# Test btrfs consistency after each FUA while enabling verity on a file
+# This test works by following the pattern in log-writes/replay-individual.sh:
+# 1. run a workload (verity + sync) while logging to the log device
+# 2. replay an entry to the replay device
+# 3. snapshot the replay device to the snapshot device
+# 4. run destructive tests on the snapshot device (e.g. mount with orphans)
+# 5. goto 2
+#
+. ./common/preamble
+_begin_fstest auto verity
+
+# Override the default cleanup function.
+_cleanup()
+{
+	cd /
+	_log_writes_cleanup &> /dev/null
+	rm -f $img
+	$LVM_PROG vgremove -f -y $vgname >>$seqres.full 2>&1
+	losetup -d $loop_dev >>$seqres.full 2>&1
+}
+
+# Import common functions.
+. ./common/filter
+. ./common/attr
+. ./common/dmlogwrites
+. ./common/verity
+
+# real QA test starts here
+_supported_fs btrfs
+
+_require_scratch
+_require_test
+_require_log_writes
+_require_dm_target snapshot
+_require_command $LVM_PROG lvm
+_require_scratch_verity
+_require_btrfs_command inspect-internal dump-tree
+_require_test_program "log-writes/replay-log"
+
+sync_loop() {
+	i=$1
+	[ -z "$i" ] && _fail "sync loop needs a number of iterations"
+	while [ $i -gt 0 ]
+	do
+		$XFS_IO_PROG -c sync $SCRATCH_MNT
+		let i-=1
+	done
+}
+
+dump_tree() {
+	local dev=$1
+	$BTRFS_UTIL_PROG inspect-internal dump-tree $dev
+}
+
+count_item() {
+	local dev=$1
+	local item=$2
+	dump_tree $dev | grep -c $item
+}
+
+_log_writes_init $SCRATCH_DEV
+_log_writes_mkfs
+_log_writes_mount
+
+f=$SCRATCH_MNT/fsv
+MB=$((1024 * 1024))
+img=$TEST_DIR/$$.img
+$XFS_IO_PROG -fc "pwrite -q 0 $((10 * $MB))" $f
+$XFS_IO_PROG -c sync $SCRATCH_MNT
+sync_loop 10 &
+sync_proc=$!
+_fsv_enable $f
+$XFS_IO_PROG -c sync $SCRATCH_MNT
+wait $sync_proc
+
+_log_writes_unmount
+_log_writes_remove
+
+# the snapshot and the replay will each be the size of the log writes dev
+# so we create a loop device of size 2 * logwrites and then split it into
+# replay and snapshot with lvm.
+log_writes_blocks=$(blockdev --getsz $LOGWRITES_DEV)
+replay_bytes=$((512 * $log_writes_blocks))
+img_bytes=$((2 * $replay_bytes))
+
+$XFS_IO_PROG -fc "pwrite -q -S 0 $img_bytes $MB" $img >>$seqres.full 2>&1 || \
+	_fail "failed to create image for loop device"
+loop_dev=$(losetup -f --show $img)
+vgname=vg_replay
+lvname=lv_replay
+replay_dev=/dev/mapper/vg_replay-lv_replay
+snapname=lv_snap
+snap_dev=/dev/mapper/vg_replay-$snapname
+
+$LVM_PROG vgcreate -f $vgname $loop_dev >>$seqres.full 2>&1 || _fail "failed to vgcreate $vgname"
+$LVM_PROG lvcreate -L "$replay_bytes"B -n $lvname $vgname -y >>$seqres.full 2>&1 || \
+	_fail "failed to lvcreate $lvname"
+$UDEV_SETTLE_PROG >>$seqres.full 2>&1
+
+replay_log_prog=$here/src/log-writes/replay-log
+num_entries=$($replay_log_prog --log $LOGWRITES_DEV --num-entries)
+entry=$($replay_log_prog --log $LOGWRITES_DEV --replay $replay_dev --find --end-mark mkfs | cut -d@ -f1)
+$replay_log_prog --log $LOGWRITES_DEV --replay $replay_dev --limit $entry || \
+	_fail "failed to replay to start entry $entry"
+let entry+=1
+
+# state = 0: verity hasn't started
+# state = 1: verity underway
+# state = 2: verity done
+state=0
+while [ $entry -lt $num_entries ];
+do
+	$replay_log_prog --limit 1 --log $LOGWRITES_DEV --replay $replay_dev --start $entry || \
+		_fail "failed to take replay step at entry: $entry"
+
+	$LVM_PROG lvcreate -s -L 4M -n $snapname $vgname/$lvname >>$seqres.full 2>&1 || \
+		_fail "Failed to create snapshot"
+	$UDEV_SETTLE_PROG >>$seqres.full 2>&1
+
+	orphan=$(count_item $snap_dev ORPHAN)
+	if [ $state -eq 0 ]; then
+		[ $orphan -gt 0 ] && state=1
+	fi
+
+	pre_mount=$(count_item $snap_dev UNKNOWN.3[67])
+	_mount $snap_dev $SCRATCH_MNT || _fail "mount failed at entry $entry"
+	fsverity measure $SCRATCH_MNT/fsv >>$seqres.full 2>&1
+	measured=$?
+	umount $SCRATCH_MNT
+	[ $state -eq 1 ] && [ $measured -eq 0 ] && state=2
+	[ $state -eq 2 ] && ([ $measured -eq 0 ] || _fail "verity done, but measurement failed at entry $entry")
+	post_mount=$(count_item $snap_dev UNKNOWN.3[67])
+
+	echo "entry: $entry, state: $state, orphan: $orphan, pre_mount: $pre_mount, post_mount: $post_mount" >> $seqres.full
+
+	if [ $state -eq 1 ]; then
+		[ $post_mount -eq 0 ] || \
+			_fail "mount failed to clear under-construction merkle items pre: $pre_mount, post: $post_mount at entry $entry";
+	fi
+	if [ $state -eq 2 ]; then
+		[ $pre_mount -gt 0 ] || \
+			_fail "expected to have verity items before mount at entry $entry"
+		[ $pre_mount -eq $post_mount ] || \
+			_fail "mount cleared merkle items after verity was enabled $pre_mount vs $post_mount at entry $entry";
+	fi
+
+	let entry+=1
+	$LVM_PROG lvremove $vgname/$snapname -y >>$seqres.full
+done
+
+echo "Silence is golden"
+
+# success, all done
+status=0
+exit
tests/btrfs/291.out new file +2 -0
new file mode 100644
index 00000000..04605c70
@@ -0,0 +1,2 @@
+QA output created by 291
+Silence is golden
Signature · 1 line
2.34.0
#7 lore raw

PATCH v6 4/4 generic: test fs-verity EFBIG scenarios

In reply to Boris Burkov

btrfs, ext4, and f2fs cache the Merkle tree past EOF, which restricts the maximum file size beneath the normal maximum. Test the logic in those filesystems against files with sizes near the maximum.

To work properly, this does require some understanding of the practical but not standardized layout of the Merkle tree. This is a bit unpleasant and could make the test incorrect in the future, if the implementation changes. On the other hand, it feels quite useful to test this tricky edge case. It could perhaps be made more generic by adding some ioctls to let the file system communicate the maximum file size for a verity file or some information about the storage of the Merkle tree.

---
 common/verity         | 11 ++++++++
 tests/generic/690     | 66 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/690.out |  7 +++++
 3 files changed, 84 insertions(+)
 create mode 100755 tests/generic/690
 create mode 100644 tests/generic/690.out
common/verity +11 -0
index 07d9d3fe..8be86ef7 100644
@@ -345,3 +345,14 @@ _fsv_scratch_corrupt_merkle_tree()
 		;;
 	esac
 }
+
+_require_fsverity_max_file_size_limit()
+{
+	case $FSTYP in
+	btrfs|ext4|f2fs)
+		;;
+	*)
+		_notrun "$FSTYP does not store verity data past EOF; no special file size limit"
+		;;
+	esac
+}
tests/generic/690 new file +66 -0

66 lines not on this page · raw message

tests/generic/690.out new file +7 -0
new file mode 100644
index 00000000..a3e2b9b9
@@ -0,0 +1,7 @@
+QA output created by 690
+
+# way too big: fail on first merkle block
+ERROR: FS_IOC_ENABLE_VERITY failed on 'SCRATCH_MNT/file.fsv': File too large
+
+# still too big: fail on first invalid merkle block
+ERROR: FS_IOC_ENABLE_VERITY failed on 'SCRATCH_MNT/file.fsv': File too large
Signature · 1 line
2.34.0
maintainer
#8 lore raw

Re: [PATCH v6 4/4] generic: test fs-verity EFBIG scenarios

Quoted 25 lines · Boris Burkov
tests/generic/690 new file +19 -0
new file mode 100755
index 00000000..77906dd8
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Facebook, Inc.  All Rights Reserved.
+#
+# FS QA Test 690
+#
+# fs-verity requires the filesystem to decide how it stores the Merkle tree,
+# which can be quite large.
+# It is convenient to treat the Merkle tree as past EOF, and ext4, f2fs, and
+# btrfs do so in at least some fashion. This leads to an edge case where a
+# large file can be under the file system file size limit, but trigger EFBIG
+# on enabling fs-verity. Test enabling verity on some large files to exercise
+# EFBIG logic for filesystems with fs-verity specific limits.
+#
+. ./common/preamble
+_begin_fstest auto quick verity
+
+
+# Import common functions.

tests/generic/690 line 29

Quoted 10 lines
tests/generic/690 new file +10 -0
+. ./common/filter
+. ./common/verity
+
+# real QA test starts here
+_supported_fs generic
+_require_test
+_require_math
+_require_scratch_verity
+_require_fsverity_max_file_size_limit
+_require_scratch_nocheck

Why is _require_scratch_nocheck() needed? _require_scratch_verity() already does _require_scratch(), and I don't see why skipping fsck would be needed.

tests/generic/690 line 39

Quoted 2 lines
tests/generic/690 new file +2 -0
+# have to go back by 4096 from max to not hit the fsverity MAX_LEVELS check.
+truncate -s $max_sz $fsv_file

The above comment should be removed.

- Eric

#9 lore raw

Re: [PATCH v6 4/4] generic: test fs-verity EFBIG scenarios

Quoted 40 lines · Eric Biggers
Quoted 25 lines · Boris Burkov
tests/generic/690 new file +19 -0
new file mode 100755
index 00000000..77906dd8
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Facebook, Inc.  All Rights Reserved.
+#
+# FS QA Test 690
+#
+# fs-verity requires the filesystem to decide how it stores the Merkle tree,
+# which can be quite large.
+# It is convenient to treat the Merkle tree as past EOF, and ext4, f2fs, and
+# btrfs do so in at least some fashion. This leads to an edge case where a
+# large file can be under the file system file size limit, but trigger EFBIG
+# on enabling fs-verity. Test enabling verity on some large files to exercise
+# EFBIG logic for filesystems with fs-verity specific limits.
+#
+. ./common/preamble
+_begin_fstest auto quick verity
+
+
+# Import common functions.

tests/generic/690 line 29

Quoted 10 lines
tests/generic/690 new file +10 -0
+. ./common/filter
+. ./common/verity
+
+# real QA test starts here
+_supported_fs generic
+_require_test
+_require_math
+_require_scratch_verity
+_require_fsverity_max_file_size_limit
+_require_scratch_nocheck

Why is _require_scratch_nocheck() needed? _require_scratch_verity() already does _require_scratch(), and I don't see why skipping fsck would be needed.

Quoted 5 lines

tests/generic/690 line 39

Quoted 2 lines
tests/generic/690 new file +2 -0
+# have to go back by 4096 from max to not hit the fsverity MAX_LEVELS check.
+truncate -s $max_sz $fsv_file

The above comment should be removed.

Thanks for catching these oversights, will fix them. The nocheck thing was left over from mixing/copy-pasting with btrfs/290 during this test's evolution. Works fine without it on ext4 and btrfs.

Quoted 1 line

- Eric