[Devel] [PATCH RH7 05/32] Revert "nsfs: add ioctl to get a parent namespace"

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Jun 8 20:05:35 MSK 2020


This reverts commit ac08c64138ac52eaba5a451801a931181e845359.

We switch from procfs ns-files to nsfs ones, so we will apply nsfs
version of the patch instead.

https://jira.sw.ru/browse/PSBM-102357

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 fs/proc/namespaces.c    |  6 ------
 include/linux/proc_ns.h |  1 -
 kernel/pid_namespace.c  | 20 --------------------
 kernel/user_namespace.c |  1 -
 4 files changed, 28 deletions(-)

diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index c94f64c0b9c2..a6a3c79764d7 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -19,8 +19,6 @@
 
 /* Returns a file descriptor that refers to an owning user namespace */
 #define NS_GET_USERNS  _IO(NSIO, 0x1)
-/* Returns a file descriptor that refers to a parent namespace */
-#define NS_GET_PARENT  _IO(NSIO, 0x2)
 
 static const struct proc_ns_operations *ns_entries[] = {
 #ifdef CONFIG_NET_NS
@@ -177,10 +175,6 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
 	switch (ioctl) {
 	case NS_GET_USERNS:
 		return open_related_ns(mnt, ns, &userns_operations, ns_get_owner);
-	case NS_GET_PARENT:
-		if (!ns->ns_ops->get_parent)
-			return -EINVAL;
-		return open_related_ns(mnt, ns, ns->ns_ops, ns->ns_ops->get_parent);
 	default:
 		return -ENOTTY;
 	}
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index af898ed6fbad..3f71f8e1aa18 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -17,7 +17,6 @@ struct proc_ns_operations {
 	int (*install)(struct nsproxy *nsproxy, void *ns);
 	unsigned int (*inum)(void *ns);
 	struct user_namespace *(*owner)(void *ns);
-	void *(*get_parent)(void *ns, const struct proc_ns_operations *ns_ops);
 };
 
 struct proc_ns {
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 38e2c2da1417..1bab842a8e1e 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -426,24 +426,6 @@ static struct user_namespace *pidns_owner(void *ns)
 	return pid_ns->user_ns;
 }
 
-static void *pidns_get_parent(void *ns, const struct proc_ns_operations *ns_ops)
-{
-	struct pid_namespace *active = task_active_pid_ns(current);
-	struct pid_namespace *pid_ns, *p;
-
-	/* See if the parent is in the current namespace */
-	pid_ns = p = ((struct pid_namespace *)ns)->parent;
-	for (;;) {
-		if (!p)
-			return ERR_PTR(-EPERM);
-		if (p == active)
-			break;
-		p = p->parent;
-	}
-
-	return get_pid_ns(pid_ns);
-}
-
 const struct proc_ns_operations pidns_operations = {
 	.name		= "pid",
 	.type		= CLONE_NEWPID,
@@ -452,7 +434,6 @@ const struct proc_ns_operations pidns_operations = {
 	.install	= pidns_install,
 	.inum		= pidns_inum,
 	.owner		= pidns_owner,
-	.get_parent     = pidns_get_parent,
 };
 
 const struct proc_ns_operations pidns_for_children_operations = {
@@ -464,7 +445,6 @@ const struct proc_ns_operations pidns_for_children_operations = {
 	.install	= pidns_install,
 	.inum		= pidns_inum,
 	.owner		= pidns_owner,
-	.get_parent     = pidns_get_parent,
 };
 
 static __init int pid_namespaces_init(void)
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index e64607f02c4c..6c4244bcebfe 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -1111,7 +1111,6 @@ const struct proc_ns_operations userns_operations = {
 	.install	= userns_install,
 	.inum		= userns_inum,
 	.owner		= userns_owner,
-	.get_parent	= ns_get_owner,
 };
 
 static __init int user_namespaces_init(void)
-- 
2.24.1



More information about the Devel mailing list