[RFC PATCH] selftests/landlock: Support running the full fs test suite on another FS

Mickaël Salaün mic at digikod.net
Thu Sep 4 15:11:35 UTC 2025


On Sat, Aug 30, 2025 at 11:47:51AM +0800, Tingmao Wang wrote:
> Adds a TMP_BIND_TO environment variable which the test binary will check,
> and if present, instead of mounting a tmpfs on ./tmp, it will bind mount
> that path to ./tmp instead.
> 
> Currently there is the layout3_fs tests which runs a few tests (but not
> the full set of Landlock tests) in separate filesystems, notably no file
> creation/write/rename etc.  This is necessary for certain special fs such
> as proc or sysfs, as the tests can only read a specific path.  However,
> for a more typical fs like v9fs, this is limitting.
> 
> This test makes it possible to run the full set on any filesystem (even
> though this is still not automated).  Note that there are some expected
> failures, such as v9fs not supporting RENAME_EXCHANGE, as well as the
> known issue of ephemeral inodes, which may be fixed by a later revision of
> [1].
> 
> Suggestions for alternatives welcome.  Maybe we need to also detect the
> fs, and disable known-unsupported tests like RENAME_EXCHANGE?

Extending layout3_fs tests with new ones that make sense (i.e. those you
listed) would make be more consistent whithout scaling issue.  We can
extend the fixture variants to skip some tests.

This patch should help:
https://lore.kernel.org/all/20250704171345.1393451-1-mic@digikod.net/
Feel free to take it with your 9pfs patch series and add a new patch
with extended checks.

> 
> Link: https://lore.kernel.org/v9fs/cover.1743971855.git.m@maowtm.org/ [1]
> Signed-off-by: Tingmao Wang <m at maowtm.org>
> ---
>  tools/testing/selftests/landlock/fs_test.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
> index fa0f18ec62c4..847be67fff9e 100644
> --- a/tools/testing/selftests/landlock/fs_test.c
> +++ b/tools/testing/selftests/landlock/fs_test.c
> @@ -285,6 +285,22 @@ static const struct mnt_opt mnt_tmp = {
>  	.data = MNT_TMP_DATA,
>  };
>  
> +static struct mnt_opt get_tmp_mnt_opt(void)
> +{
> +	const char *const tmp_bind_to = getenv("TMP_BIND_TO");
> +
> +	if (tmp_bind_to) {
> +		struct mnt_opt mnt = {
> +			.flags = MS_BIND,
> +			.source = tmp_bind_to
> +		};
> +
> +		return mnt;
> +	}
> +
> +	return mnt_tmp;
> +}
> +
>  static int mount_opt(const struct mnt_opt *const mnt, const char *const target)
>  {
>  	return mount(mnt->source ?: mnt->type, target, mnt->type, mnt->flags,
> @@ -322,7 +338,9 @@ static void prepare_layout_opt(struct __test_metadata *const _metadata,
>  
>  static void prepare_layout(struct __test_metadata *const _metadata)
>  {
> -	prepare_layout_opt(_metadata, &mnt_tmp);
> +	struct mnt_opt mnt = get_tmp_mnt_opt();
> +
> +	prepare_layout_opt(_metadata, &mnt);
>  }
>  
>  static void cleanup_layout(struct __test_metadata *const _metadata)
> 
> base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
> -- 
> 2.51.0
> 
> 



More information about the Linux-security-module-archive mailing list