OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org, Sashiko <no-reply@sashiko.virtuozzo.com>
Subject: [Devel] [PATCH hci-8.2 v3 1/3] ve/kernfs: count repeated slashes in a permission path as one
Date: Tue, 01 Dec 2026 14:02:41 +0100	[thread overview]
Message-ID: <20261201-ve-perms-skip-slashes-v3-1-aecb89f6d082@virtuozzo.com> (raw)
In-Reply-To: <20261201-ve-perms-skip-slashes-v3-0-aecb89f6d082@virtuozzo.com>

kernfs_perms_set() stops at the first empty component of the path and
applies the mode to the node it reached so far:

  +-----------------------+-------------------+
  | rule                  | applied to        |
  +-----------------------+-------------------+
  | cpuN/cache/uevent rw  | cpuN/cache/uevent |
  | cpuN/cache//uevent rw | cpuN/cache        |
  +-----------------------+-------------------+

vzctl writes such rules: it passes the cpuN/cache directory with a
trailing slash and appends "/<child>" for each child, so in every
Container cpuN/cache ends up "rw" without "x". A recent mongod 8.0
(tcmalloc) reads cpuN/cache/indexM/shared_cpu_list on start, gets EACCES
and aborts.

Walk the path with kernfs_walk_and_get(), which skips empty components
as a path lookup does.
Now the rule applies to the actual path, not to the part before an
empty component.

https://virtuozzo.atlassian.net/browse/VSTOR-158149

Fixes: 57739dce06d0 ("ve/kernfs: add new interface to control per-VE nodes visibility")
Feature: sysfs: per-CT entries visibility and permissions configuration
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
Reviewed-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 fs/kernfs/ve.c | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/fs/kernfs/ve.c b/fs/kernfs/ve.c
index 1097fd30598e3..963760b3ac73d 100644
--- a/fs/kernfs/ve.c
+++ b/fs/kernfs/ve.c
@@ -252,33 +252,14 @@ int kernfs_perms_show(struct seq_file *m, void *v, struct kmapset_key *key)
 int kernfs_perms_set(char *path, struct ve_struct *ve, int mask,
 		     struct kernfs_node *root, struct kmapset_key *key)
 {
-	struct kernfs_node *kn = root, *nkn;
-	char *sep = path, *dname;
-	int ret = 0;
+	struct kernfs_node *kn;
+	int ret;
 
-	kernfs_get(kn);
-	do {
-		dname = sep;
-
-		sep = strchr(sep, '/');
-		if (sep)
-			*sep++ = 0;
-
-		if (!*dname)
-			break;
-
-		nkn = kernfs_find_and_get(kn, dname);
-		if (!nkn) {
-			ret = -ENOENT;
-			goto out;
-		}
-
-		kernfs_put(kn);
-		kn = nkn;
-	} while (sep);
+	kn = kernfs_walk_and_get(root, path);
+	if (!kn)
+		return -ENOENT;
 
 	ret = ve_perms_apply(&kn->ve_perms_map, key, ve_is_super(ve), mask);
-out:
 	kernfs_put(kn);
 	return ret;
 }

-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  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: " Pavel Tikhomirov
2026-12-01 13:02 ` Pavel Tikhomirov [this message]
2026-12-01 13:02 ` [Devel] [PATCH hci-8.2 v3 2/3] fs/proc, " Pavel Tikhomirov
2026-12-01 13:02 ` [Devel] [PATCH hci-8.2 v3 3/3] selftests/ve: check repeated slashes in a permission path Pavel Tikhomirov
2026-12-01 13:06   ` 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-1-aecb89f6d082@virtuozzo.com \
    --to=ptikhomirov@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=no-reply@sashiko.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox