[RFC PATCH] selftests/landlock: Support running the full fs test suite on another FS
Tingmao Wang
m at maowtm.org
Sat Aug 30 03:47:51 UTC 2025
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?
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