Skip to contentSkip to conversation

common/encrypt: Do not run _verify_ciphertext_for_encryption_policy on compressed FS

PATCH Superseded Jan Prusakowski 2 participants 3 messages Sep 4, 2025 – Sep 12, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/encrypt: Do not run _verify_ciphertext_for_encryption_policy on compressed FS

_verify_ciphertext_for_encryption_policy() checks if encryption works correctly by reading encrypted file's contents directly from a block device and comparing it to a known good ciphertext.

This, however, won't work if the file systems is also compressed. So this patch disables tests using this function when a compressed FS is used.

---
 common/config  | 1 +
 common/encrypt | 4 ++++
 common/f2fs    | 7 +++++++
 common/rc      | 3 +++
 4 files changed, 15 insertions(+)
common/config +1 -0
index 22b52432..1420e35d 100644
@@ -509,6 +509,7 @@ _source_specific_fs()
 		;;
 	f2fs)
 		[ "$MKFS_F2FS_PROG" = "" ] && _fatal "mkfs.f2fs not found"
+		. ./common/f2fs
 		;;
 	nfs)
 		. ./common/nfs
common/encrypt +4 -0
index d4f6e3dc..43ec349b 100644
@@ -989,6 +989,10 @@ _verify_ciphertext_for_encryption_policy()
 	fi
 	set_encpolicy_args=${set_encpolicy_args# }
 
+
+	# _verify_ciphertext_for_encryption_policy will fail if the FS is compressed.
+	_require_no_compress
+
 	_require_scratch_encryption $set_encpolicy_args -f $policy_flags
 	if $hw_wrapped_key; then
 		_require_hw_wrapped_key_support $SCRATCH_DEV
common/f2fs +7 -0
index 1b39d8ce..c46e2aa2 100644
@@ -25,3 +25,10 @@ _require_scratch_f2fs_compression()
 		_scratch_unmount
 	fi
 }
+
+_require_f2fs_no_compress()
+{
+	if _normalize_mount_options "$MOUNT_OPTIONS" | grep -q "compress"; then
+		_notrun "This test requires no compression enabled"
+	fi
+}
\ No newline at end of file
common/rc +3 -0
index 81587dad..882e0588 100644
@@ -2112,6 +2112,9 @@ _require_no_compress()
 	btrfs)
 		_require_btrfs_no_compress
 		;;
+	f2fs)
+		_require_f2fs_no_compress
+		;;
 	*)
 		;;
 	esac
Signature · 1 line
2.51.0.355.g5224444f11-goog
#1 lore raw
Quoted 6 lines · Jan Prusakowski

_verify_ciphertext_for_encryption_policy() checks if encryption works correctly by reading encrypted file's contents directly from a block device and comparing it to a known good ciphertext.

This, however, won't work if the file systems is also compressed. So this patch disables tests using this function when a compressed FS is used.

Apparently this is for f2fs. There isn't really any such thing as a "compressed filesystem" for f2fs. Rather, f2fs supports compression on a per-file basis: the filesystem can contain a mix of compressed and uncompressed files. Probably you used 'compression_extension=*', which caused f2fs to automatically enable compression on the files that xfstests created, which caused the test failure. But that behavior is specific to 'compress_extension=*', not to compression support per se.

Quoted 5 lines
common/f2fs +0 -0
index 1b39d8ce..c46e2aa2 100644

common/f2fs _require_scratch_f2fs_compression() · line 34

Quoted 10 lines
common/f2fs +7 -0
@@ -25,3 +25,10 @@ _require_scratch_f2fs_compression()
 		_scratch_unmount
 	fi
 }
+
+_require_f2fs_no_compress()
+{
+	if _normalize_mount_options "$MOUNT_OPTIONS" | grep -q "compress"; then
+		_notrun "This test requires no compression enabled"
+	fi
+}

That just checks for compression support, not whether the test file is actually compressed.

But also, we don't really need to skip these tests. Instead, how about using 'chattr +m' to explicitly set the test file to uncompressed?

- Eric

#2 lore raw
Quoted 8 lines · Eric Biggers

Apparently this is for f2fs. There isn't really any such thing as a "compressed filesystem" for f2fs. Rather, f2fs supports compression on a per-file basis: the filesystem can contain a mix of compressed and uncompressed files. Probably you used 'compression_extension=*', which caused f2fs to automatically enable compression on the files that xfstests created, which caused the test failure. But that behavior is specific to 'compress_extension=*', not to compression support per se.

Yes, I used "compression_extension=*" in my tests.

Quoted 2 lines

But also, we don't really need to skip these tests. Instead, how about using 'chattr +m' to explicitly set the test file to uncompressed?

I tried that and "chattr +m" does not work as it tries to simultaneously set 2 mutually exclusive compression flags (FS_COMPR_FL and FS_NOCOMP_FL). However, "chattr -c" on an empty file works, so let me post a v2 attempt shortly.

Thanks!
Jan