* [LTP] [PATCH] statx09: Reduce fs-verity blocksize to 1024 @ 2023-07-13 13:28 Martin Doucha 2023-07-14 3:40 ` Eric Biggers 0 siblings, 1 reply; 5+ messages in thread From: Martin Doucha @ 2023-07-13 13:28 UTC (permalink / raw) To: Dai Shili, ltp 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 minimum possible value (1024) to avoid blocksize mismatch. Signed-off-by: Martin Doucha <mdoucha@suse.cz> --- Alternatively, we could add "-b 4096" to .dev_fs_opts. testcases/kernel/syscalls/statx/statx09.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testcases/kernel/syscalls/statx/statx09.c b/testcases/kernel/syscalls/statx/statx09.c index c03d2c91e..dc9786c76 100644 --- a/testcases/kernel/syscalls/statx/statx09.c +++ b/testcases/kernel/syscalls/statx/statx09.c @@ -94,7 +94,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 = 1024; enable.salt_size = 0; enable.salt_ptr = (intptr_t)NULL; enable.sig_size = 0; -- 2.41.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] statx09: Reduce fs-verity blocksize to 1024 2023-07-13 13:28 [LTP] [PATCH] statx09: Reduce fs-verity blocksize to 1024 Martin Doucha @ 2023-07-14 3:40 ` Eric Biggers 2023-07-14 11:47 ` Petr Vorel 0 siblings, 1 reply; 5+ messages in thread From: Eric Biggers @ 2023-07-14 3:40 UTC (permalink / raw) To: Martin Doucha; +Cc: ltp Hi Martin, On Thu, Jul 13, 2023 at 03:28:52PM +0200, Martin Doucha wrote: > 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 minimum possible value (1024) to avoid blocksize > mismatch. > > Signed-off-by: Martin Doucha <mdoucha@suse.cz> > --- > > Alternatively, we could add "-b 4096" to .dev_fs_opts. > > testcases/kernel/syscalls/statx/statx09.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/testcases/kernel/syscalls/statx/statx09.c b/testcases/kernel/syscalls/statx/statx09.c > index c03d2c91e..dc9786c76 100644 > --- a/testcases/kernel/syscalls/statx/statx09.c > +++ b/testcases/kernel/syscalls/statx/statx09.c > @@ -94,7 +94,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 = 1024; > enable.salt_size = 0; > enable.salt_ptr = (intptr_t)NULL; > enable.sig_size = 0; > -- Support for Merkle tree block sizes less than the page size didn't exist until kernel version 6.3. Please see the documentation for FS_IOC_ENABLE_VERITY (https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#fs-ioc-enable-verity): "block_size is the Merkle tree block size, in bytes. In Linux v6.3 and later, this can be any power of 2 between (inclusively) 1024 and the minimum of the system page size and the filesystem block size. In earlier versions, the page size was the only allowed value." There are a few different approaches you could take. One would be the one you mentioned: just add "-b 4096". Though, note that systems with non-4K pages and kernel older than v6.3 can't mount an "-O verity -b 4096" filesystem. Or you could query the filesystem block size (that resulted from mkfs.ext4 with unspecified block size) and use that as the Merkle tree block size. Or you could simply make the test depend on kernel v6.3, I suppose. - Eric -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] statx09: Reduce fs-verity blocksize to 1024 2023-07-14 3:40 ` Eric Biggers @ 2023-07-14 11:47 ` Petr Vorel 2023-07-14 11:49 ` Petr Vorel 2023-07-14 12:32 ` Martin Doucha 0 siblings, 2 replies; 5+ messages in thread From: Petr Vorel @ 2023-07-14 11:47 UTC (permalink / raw) To: Eric Biggers; +Cc: ltp Hi Eric, Martin, Eric, thanks for your input, Martin, thanks for working on this. > Hi Martin, > On Thu, Jul 13, 2023 at 03:28:52PM +0200, Martin Doucha wrote: > > 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 minimum possible value (1024) to avoid blocksize > > mismatch. Yes kernels < 6.3 TCONF on current master: statx09.c:124: TCONF: fs-verity not supported on loopdev And 6.3 fails: statx09.c:109: TBROK: ioctl(3, FS_IOC_ENABLE_VERITY) failed: EINVAL (22) > > Signed-off-by: Martin Doucha <mdoucha@suse.cz> > > --- > > Alternatively, we could add "-b 4096" to .dev_fs_opts. > > testcases/kernel/syscalls/statx/statx09.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/testcases/kernel/syscalls/statx/statx09.c b/testcases/kernel/syscalls/statx/statx09.c > > index c03d2c91e..dc9786c76 100644 > > --- a/testcases/kernel/syscalls/statx/statx09.c > > +++ b/testcases/kernel/syscalls/statx/statx09.c > > @@ -94,7 +94,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 = 1024; > > enable.salt_size = 0; > > enable.salt_ptr = (intptr_t)NULL; > > enable.sig_size = 0; > > -- > Support for Merkle tree block sizes less than the page size didn't exist until > kernel version 6.3. Please see the documentation for FS_IOC_ENABLE_VERITY > (https://www.kernel.org/doc/html/latest/filesystems/fsverity.html#fs-ioc-enable-verity): > "block_size is the Merkle tree block size, in bytes. In Linux v6.3 and > later, this can be any power of 2 between (inclusively) 1024 and the minimum > of the system page size and the filesystem block size. In earlier versions, > the page size was the only allowed value." > There are a few different approaches you could take. One would be the one you > mentioned: just add "-b 4096". Though, note that systems with non-4K pages and > kernel older than v6.3 can't mount an "-O verity -b 4096" filesystem. I suppose the problem would be with e.g. ppc64le. Because otherwise it works with this setup (untested on ppc64le, I believe it'd fail): .dev_fs_opts = (const char *const []){"-O verity", "-b 4096", NULL}, and kept enable.block_size = 4096 the test passes on older kernels 6.2.12-1-default (openSUSE), 5.10.0-8-amd64 (Debian) as well as on 6.3 kernel. > Or you could query the filesystem block size (that resulted from mkfs.ext4 with > unspecified block size) and use that as the Merkle tree block size. Unless it's not too complicated, it looks to me the best, as it'd support both >= 6.3 and older kernels. > Or you could simply make the test depend on kernel v6.3, I suppose. If possible I'd prefer to keep functionality also for older kernels. Another (IMHO not really good option) would be to acquire device big enough via .dev_min_size (it'd probably have to be too big device). Kind regards, Petr > - Eric -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] statx09: Reduce fs-verity blocksize to 1024 2023-07-14 11:47 ` Petr Vorel @ 2023-07-14 11:49 ` Petr Vorel 2023-07-14 12:32 ` Martin Doucha 1 sibling, 0 replies; 5+ messages in thread From: Petr Vorel @ 2023-07-14 11:49 UTC (permalink / raw) To: Eric Biggers, ltp Hi Eric, Martin, > Yes kernels < 6.3 TCONF on current master: > statx09.c:124: TCONF: fs-verity not supported on loopdev I forget to write the behavior is the same on older kernels with Martin's patch. Kind regards, Petr > And 6.3 fails: > statx09.c:109: TBROK: ioctl(3, FS_IOC_ENABLE_VERITY) failed: EINVAL (22) -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [LTP] [PATCH] statx09: Reduce fs-verity blocksize to 1024 2023-07-14 11:47 ` Petr Vorel 2023-07-14 11:49 ` Petr Vorel @ 2023-07-14 12:32 ` Martin Doucha 1 sibling, 0 replies; 5+ messages in thread From: Martin Doucha @ 2023-07-14 12:32 UTC (permalink / raw) To: Petr Vorel, Eric Biggers; +Cc: ltp On 14. 07. 23 13:47, Petr Vorel wrote: >> There are a few different approaches you could take. One would be the one you >> mentioned: just add "-b 4096". Though, note that systems with non-4K pages and >> kernel older than v6.3 can't mount an "-O verity -b 4096" filesystem. > > I suppose the problem would be with e.g. ppc64le. Because otherwise > it works with this setup (untested on ppc64le, I believe it'd fail): > .dev_fs_opts = (const char *const []){"-O verity", "-b 4096", NULL}, > and kept enable.block_size = 4096 > the test passes on older kernels 6.2.12-1-default (openSUSE), 5.10.0-8-amd64 > (Debian) as well as on 6.3 kernel. > >> Or you could query the filesystem block size (that resulted from mkfs.ext4 with >> unspecified block size) and use that as the Merkle tree block size. > > Unless it's not too complicated, it looks to me the best, as it'd support both > >= 6.3 and older kernels. Querying the filesystem size doesn't help on older kernels because mkfs.ext4 still creates the filesystem with small blocksize and setup() exits with TCONF because it can't mount the loop device, as you've seen in your own experiments. But it'll work on kernels v6.3+ so I've submitted that as v2. For the older kernels, we'll have to run mkfs.ext4 in setup() with dynamically constructed command line arguments and set blocksize explicitly to pagesize. -- Martin Doucha mdoucha@suse.cz SW Quality Engineer SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-14 12:32 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-07-13 13:28 [LTP] [PATCH] statx09: Reduce fs-verity blocksize to 1024 Martin Doucha 2023-07-14 3:40 ` Eric Biggers 2023-07-14 11:47 ` Petr Vorel 2023-07-14 11:49 ` Petr Vorel 2023-07-14 12:32 ` Martin Doucha
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox