From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v3 3/3] selftests/ve: check repeated slashes in a permission path
Date: Tue, 01 Dec 2026 14:02:43 +0100 [thread overview]
Message-ID: <20261201-ve-perms-skip-slashes-v3-3-aecb89f6d082@virtuozzo.com> (raw)
In-Reply-To: <20261201-ve-perms-skip-slashes-v3-0-aecb89f6d082@virtuozzo.com>
Each variant names a nested file with repeated slashes,
"kernel//vmcoreinfo" in sysfs and "bus//pci/devices" in proc. With the
directories above the file traversable, write a rule for it and check
that the file gets the mode and a VE can read it. Skip if the file is
granted to every VE by default, as the open would then prove nothing.
https://virtuozzo.atlassian.net/browse/VSTOR-158149
Feature: kernfs: per-CT entries visibility and permissions configuration
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
tools/testing/selftests/ve/ve_perms_test.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/tools/testing/selftests/ve/ve_perms_test.c b/tools/testing/selftests/ve/ve_perms_test.c
index 375f98c36f87e..3b26defe9574b 100644
--- a/tools/testing/selftests/ve/ve_perms_test.c
+++ b/tools/testing/selftests/ve/ve_perms_test.c
@@ -15,6 +15,7 @@
* - cover the write parser (masks, comments, several entries, replace,
* duplicate op, remove of an absent entry, missing mask) and check each
* entry renders at its true depth, a directory with a trailing slash
+ * - confirm repeated slashes in a path count as one
* - enforce the r and x mask bits end to end from inside a VE
*/
#define _GNU_SOURCE
@@ -46,6 +47,8 @@ FIXTURE_VARIANT(ve_perms)
const char *dir_prefix; /* host mount point: "/proc" or "/sys" */
const char *files[NR_FILES]; /* host-only readable leaves */
const char *dir; /* host-only directory */
+ const char *slashed; /* a nested file, with repeated slashes */
+ const char *unslashed; /* the same file, as the kernel lists it */
};
FIXTURE_VARIANT_ADD(ve_perms, proc)
@@ -54,6 +57,8 @@ FIXTURE_VARIANT_ADD(ve_perms, proc)
.dir_prefix = "/proc",
.files = { "interrupts", "slabinfo" },
.dir = "bus",
+ .slashed = "bus//pci/devices",
+ .unslashed = "bus/pci/devices",
};
FIXTURE_VARIANT_ADD(ve_perms, sysfs)
@@ -62,6 +67,8 @@ FIXTURE_VARIANT_ADD(ve_perms, sysfs)
.dir_prefix = "/sys",
.files = { "kernel/vmcoreinfo", "kernel/notes" },
.dir = "power",
+ .slashed = "kernel//vmcoreinfo",
+ .unslashed = "kernel/vmcoreinfo",
};
/* The per-VE cgroup file for this ctid and filesystem. */
@@ -373,6 +380,28 @@ static int allow_paths(int cgv2_fd, const char *path, const char *const files[])
return 0;
}
+/* "first//second" sets first/second, as in a path lookup, and a VE can read it */
+TEST_F(ve_perms, repeated_slashes)
+{
+ const char *file = variant->unslashed;
+ char path[PATH_MAX], line[PATH_MAX], buf[8192];
+
+ if (!entry_present(variant->dir_prefix, file))
+ SKIP(return, "%s absent under %s", file, variant->dir_prefix);
+ if (default_granted(self->cgv2_fd, variant->fs, file))
+ SKIP(return, "%s granted by default", file);
+
+ ve_file(path, sizeof(path), self->ctid_a, variant->fs);
+
+ ASSERT_EQ(allow_path(self->cgv2_fd, path, file), 0);
+ ASSERT_EQ(set_entry(self->cgv2_fd, path, variant->slashed, "r"), 0);
+ ASSERT_GT(read_file_at(self->cgv2_fd, path, buf, sizeof(buf)), 0);
+ snprintf(line, sizeof(line), "%s r\n", file);
+ EXPECT_NE(strstr(buf, line), NULL);
+ EXPECT_EQ(ve_open_rel(self->cgv2_fd, self->ctid_a, variant->dir_prefix,
+ file, O_RDONLY), 0);
+}
+
/*
* Enforcement, allowed side: from inside a VE, granting r lets each file be
* read, and granting x on the directory lets it be traversed (the lookup then
--
2.56.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-12-01 13:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 13:02 [Devel] [PATCH hci-8.2 v3 0/3] ve: count repeated slashes in a permission path as one Pavel Tikhomirov
2026-12-01 13:02 ` [Devel] [PATCH hci-8.2 v3 1/3] ve/kernfs: " Pavel Tikhomirov
2026-12-01 13:02 ` [Devel] [PATCH hci-8.2 v3 2/3] fs/proc, ve: " Pavel Tikhomirov
2026-12-01 13:02 ` Pavel Tikhomirov [this message]
2026-12-01 13:06 ` [Devel] [PATCH hci-8.2 v3 3/3] selftests/ve: check repeated slashes in a permission path no-reply
2026-12-01 13:26 ` Pavel Tikhomirov
2026-12-01 13:49 ` Vasileios Almpanis
2026-12-01 15:37 ` [Devel] [PATCH hci-8.2 v3 0/3] ve: count repeated slashes in a permission path as one Konstantin Khorenko
2026-12-01 15:38 ` Konstantin Khorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201-ve-perms-skip-slashes-v3-3-aecb89f6d082@virtuozzo.com \
--to=ptikhomirov@virtuozzo.com \
--cc=devel@openvz.org \
--cc=khorenko@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.