Skip to contentSkip to conversation

statx09: Set fs-verity blocksize to FS blocksize

PATCH In review Martin Doucha 2 participants 3 messages Jul 14, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 statx09: Set fs-verity blocksize to FS blocksize

The kernel requires that fs-verity blocksize must be at most equal to the filesystem blocksize. Testing on small loop device means that mkfs.ext4 will very likely default to blocksize of 1024. Set fs-verity blocksize to the filesystem blocksize to avoid errors.

---

Setting filesystem blocksize to pagesize would require moving the mkfs command to setup(). We can do that later to fix support for kernels before v6.3 but let's fix the failure on latest kernel version first.

 testcases/kernel/syscalls/statx/statx09.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx09.c +3 -1
index c03d2c91e..7211d8393 100644
@@ -80,8 +80,10 @@ static void flag_setup(void)
 {
 	int fd, attr, ret;
 	struct fsverity_enable_arg enable;
+	struct stat statbuf;
 
 	fd = SAFE_OPEN(TESTFILE_FLAGGED, O_RDONLY, 0664);
+	SAFE_FSTAT(fd, &statbuf);
 
 	ret = ioctl(fd, FS_IOC_GETFLAGS, &attr);
 	if (ret < 0) {
@@ -94,7 +96,7 @@ static void flag_setup(void)
 	memset(&enable, 0, sizeof(enable));
 	enable.version = 1;
 	enable.hash_algorithm = hash_algorithms[0];
-	enable.block_size = 4096;
+	enable.block_size = statbuf.st_blksize;
 	enable.salt_size = 0;
 	enable.salt_ptr = (intptr_t)NULL;
 	enable.sig_size = 0;
Signature · 5 lines
2.41.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by Tested-by on v2 1/1
#1 lore raw

Hi Martin,

Quoted 11 lines

The kernel requires that fs-verity blocksize must be at most equal to the filesystem blocksize. Testing on small loop device means that mkfs.ext4 will very likely default to blocksize of 1024. Set fs-verity blocksize to the filesystem blocksize to avoid errors.

---

Setting filesystem blocksize to pagesize would require moving the mkfs command to setup(). We can do that later to fix support for kernels before v6.3 but let's fix the failure on latest kernel version first.

Makes sense.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Martin,

thanks, merged!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp