[PATCH RFC v3 34/44] selftests/ovl: test data-only layers on pseudo filesystems
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Mon Nov 16 03:28:27 PST 2026
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] selftests/ovl: missing prerequisite skips in setup_tmp() and
tests
- [Low] selftests/ovl: duplicated setup_tmp() and datadir test cases
--
commit 9dfbd53c60eeeb8dceed3a46417fda9ee76bb58b
Author: Christian Brauner <brauner at kernel.org>
selftests/ovl: test data-only layers on pseudo filesystems
This commit adds an overlayfs selftest verifying that data-only layers on
pseudo filesystems (sysfs and procfs) are rejected while tmpfs data-only
layers and sysfs lower layers remain allowed.
> diff --git a/tools/testing/selftests/filesystems/overlayfs/pseudo_datadir.c b/tools/testing/selftests/filesystems/overlayfs/pseudo_datadir.c
> new file mode 100644
> index 0000000000000..3b59fd3e9f5c2
> --- /dev/null
> +++ b/tools/testing/selftests/filesystems/overlayfs/pseudo_datadir.c
> @@ -0,0 +1,131 @@
[ ... ]
> +static int setup_tmp(void)
> +{
> + if (unshare(CLONE_NEWNS))
> + return -errno;
> + if (sys_mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL))
> + return -errno;
> + if (sys_mount("tmpfs", "/tmp", "tmpfs", 0, NULL))
> + return -errno;
> + if (mkdir("/tmp/lower", 0755) || mkdir("/tmp/data", 0755) ||
> + mkdir("/tmp/merged", 0755))
> + return -errno;
> + return 0;
> +}
[Severity: Low]
Should these tests invoke SKIP() with a reason string when root privileges
or kernel overlayfs support are unavailable?
Running this test without root privileges causes setup_tmp() to fail with
-EPERM on unshare(CLONE_NEWNS), and running on a kernel without
CONFIG_OVERLAY_FS causes mount_lowerdir() and fsmount_layers() to return
-ENODEV, failing all four tests in make run_tests instead of skipping them.
[ ... ]
> +TEST(datadir_sysfs)
> +{
> + ASSERT_EQ(setup_tmp(), 0);
> +
> + EXPECT_EQ(mount_lowerdir("/tmp/lower::/sys/kernel"), -EINVAL);
> + EXPECT_EQ(fsmount_layers("/tmp/lower", "/sys/kernel", false), -EINVAL);
> + EXPECT_EQ(fsmount_layers("/tmp/lower", "/sys/kernel", true), -EINVAL);
> +}
> +
> +TEST(datadir_procfs)
> +{
> + ASSERT_EQ(setup_tmp(), 0);
> +
> + EXPECT_EQ(mount_lowerdir("/tmp/lower::/proc"), -EINVAL);
> + EXPECT_EQ(fsmount_layers("/tmp/lower", "/proc", false), -EINVAL);
> + EXPECT_EQ(fsmount_layers("/tmp/lower", "/proc", true), -EINVAL);
> +}
> +
> +TEST(datadir_tmpfs)
> +{
> + ASSERT_EQ(setup_tmp(), 0);
> +
> + EXPECT_EQ(mount_lowerdir("/tmp/lower::/tmp/data"), 0);
> + EXPECT_EQ(fsmount_layers("/tmp/lower", "/tmp/data", false), 0);
> + EXPECT_EQ(fsmount_layers("/tmp/lower", "/tmp/data", true), 0);
> +}
> +
> +TEST(lowerdir_sysfs)
> +{
> + ASSERT_EQ(setup_tmp(), 0);
[Severity: Low]
This isn't a bug, but could setup_tmp() move into a FIXTURE_SETUP() block,
and could the three datadir_* tests be parameterized with FIXTURE_VARIANT()
over the path and expected return code to avoid duplicating the setup and
mount sequence? Also, since set_layers_via_fds.c already tests lowerdir+
and datadir+ layer configuration, should these cases live there instead of
in a new standalone binary?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116-work-loop-pseudo-v3-0-8cbbea1cf34f@kernel.org?part=34
More information about the Linux-nvme
mailing list