OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
To: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 1/2] capability: Add new helper to check specific VE capabilities
Date: Sun, 20 Sep 2026 17:45:42 +0000	[thread overview]
Message-ID: <20260920-ovl-use-orig-ve-v1-1-b3e63f6ff80d@virtuozzo.com> (raw)
In-Reply-To: <20260920-ovl-use-orig-ve-v1-0-b3e63f6ff80d@virtuozzo.com>

Currently ve_capable checks only current VE caps. It is useful to be
able to check capabilities of VEs other than current.

https://virtuozzo.atlassian.net/browse/VSTOR-142405
Signed-off-by: Vladimir Riabchun <vladimir.riabchun@virtuozzo.com>
---
 include/linux/capability.h |  3 +++
 kernel/capability.c        | 15 +++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/include/linux/capability.h b/include/linux/capability.h
index e1cc7133b16c..443fc2331cac 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -191,6 +191,9 @@ bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
 				 const struct inode *inode);
 bool capable_wrt_inode_uidgid(struct mnt_idmap *idmap,
 			      const struct inode *inode, int cap);
+
+struct ve_struct;
+extern bool __ve_capable(struct ve_struct *ve, int cap);
 extern bool ve_capable(int cap);
 extern bool feature_capable(int feature, int cap);
 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
diff --git a/kernel/capability.c b/kernel/capability.c
index 34716847c6b8..1dd88645a6a3 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -386,13 +386,13 @@ bool ns_capable(struct user_namespace *ns, int cap)
 EXPORT_SYMBOL(ns_capable);
 
 #ifdef CONFIG_VE
-bool ve_capable(int cap)
+bool __ve_capable(struct ve_struct *ve, int cap)
 {
 	struct cred *cred;
 	bool ret;
 
 	rcu_read_lock();
-	cred = get_exec_env()->init_cred;
+	cred = ve->init_cred;
 
 	if (cred == NULL) /* ve isn't running */
 		cred = ve0.init_cred;
@@ -403,6 +403,11 @@ bool ve_capable(int cap)
 	return ret;
 }
 
+bool ve_capable(int cap)
+{
+	return __ve_capable(get_exec_env(), cap);
+}
+
 bool ve_capable_noaudit(int cap)
 {
 	struct cred *cred;
@@ -428,6 +433,11 @@ bool feature_capable(int feature, int cap)
 		return capable(cap);
 }
 #else
+bool __ve_capable(struct ve_struct *ve, int cap)
+{
+	return capable(cap);
+}
+
 bool ve_capable(int cap)
 {
 	return capable(cap);
@@ -443,6 +453,7 @@ bool feature_capable(int feature, int cap)
 	return capable(cap);
 }
 #endif
+EXPORT_SYMBOL_GPL(__ve_capable);
 EXPORT_SYMBOL_GPL(ve_capable);
 EXPORT_SYMBOL_GPL(ve_capable_noaudit);
 

-- 
2.47.1

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

  reply	other threads:[~2026-09-20 17:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-20 17:45 [Devel] [PATCH hci-8.1 0/2] Fix kernel crash in overlayfs Vladimir Riabchun
2026-09-20 17:45 ` Vladimir Riabchun [this message]
2026-09-20 17:45 ` [Devel] [PATCH hci-8.1 2/2] ovl: Keep creator VE in overlayfs superblock Vladimir Riabchun
2026-09-25 17:58   ` Konstantin Khorenko
2026-10-19  9:00     ` Pavel Tikhomirov

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=20260920-ovl-use-orig-ve-v1-1-b3e63f6ff80d@virtuozzo.com \
    --to=vladimir.riabchun@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox