[Devel] [PATCH RH7 03/32] Revert "ms/net: add an ioctl to get a socket network namespace"

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


This reverts commit 302889fa2e3d0b9a36f118efa56c3378d63e0d94.

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         |  2 +-
 include/linux/proc_ns.h      |  8 --------
 include/uapi/linux/sockios.h |  1 -
 net/socket.c                 | 32 --------------------------------
 4 files changed, 1 insertion(+), 42 deletions(-)

diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index 95254dd4c831..c94f64c0b9c2 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -130,7 +130,7 @@ static struct dentry *proc_ns_get_dentry(struct super_block *sb,
 	return __proc_ns_get_dentry(sb, ns, ns_ops);
 }
 
-int open_related_ns(struct vfsmount *mnt, struct proc_ns *ns,
+static int open_related_ns(struct vfsmount *mnt, struct proc_ns *ns,
 		const struct proc_ns_operations *relative_ns_ops,
 		void *(*get_ns)(void *ns,
 			const struct proc_ns_operations *ns_ops)) {
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index 53d7aca52478..af898ed6fbad 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -78,12 +78,4 @@ static inline bool proc_ns_inode(struct inode *inode) { return false; }
 
 #endif /* CONFIG_PROC_FS */
 
-struct vfsmount;
-int open_related_ns(struct vfsmount *mnt, struct proc_ns *ns,
-		    const struct proc_ns_operations *relative_ns_ops,
-		    void *(*get_ns)(void *ns,
-		    const struct proc_ns_operations *ns_ops));
-
-int open_net_ns_fd(struct net *net);
-
 #endif /* _LINUX_PROC_NS_H */
diff --git a/include/uapi/linux/sockios.h b/include/uapi/linux/sockios.h
index cf0a25ebc74c..e888b1aed69f 100644
--- a/include/uapi/linux/sockios.h
+++ b/include/uapi/linux/sockios.h
@@ -84,7 +84,6 @@
 #define SIOCWANDEV	0x894A		/* get/set netdev parameters	*/
 
 #define SIOCOUTQNSD	0x894B		/* output queue size (not sent only) */
-#define SIOCGSKNS	0x894C		/* get socket network namespace */
 
 /* ARP cache control calls. */
 		    /*  0x8950 - 0x8952  * obsolete calls, don't re-use */
diff --git a/net/socket.c b/net/socket.c
index fb6e5a296337..5cb4ccef937c 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -67,7 +67,6 @@
 #include <linux/rcupdate.h>
 #include <linux/netdevice.h>
 #include <linux/proc_fs.h>
-#include <linux/proc_ns.h>
 #include <linux/seq_file.h>
 #include <linux/mutex.h>
 #include <linux/if_bridge.h>
@@ -1092,29 +1091,6 @@ static long sock_do_ioctl(struct net *net, struct socket *sock,
  *	what to do with it - that's up to the protocol still.
  */
 
-static void *get_net_ns(void *ns, const struct proc_ns_operations *ns_ops)
-{
-	struct net *net = ns;
-	return get_net(net);
-}
-
-int open_net_ns_fd(struct net *net)
-{
-	struct proc_ns ns = { .ns = net, .ns_ops = &netns_operations, };
-	struct vfsmount *proc_mnt;
-	int ret;
-
-	proc_mnt = mntget(task_active_pid_ns(current)->proc_mnt);
-	if (IS_ERR(proc_mnt))
-		return PTR_ERR(proc_mnt);
-
-	ret = open_related_ns(proc_mnt, &ns, ns.ns_ops, get_net_ns);
-	mntput(proc_mnt);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(open_net_ns_fd);
-
 static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 {
 	struct socket *sock;
@@ -1182,13 +1158,6 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
 				err = dlci_ioctl_hook(cmd, argp);
 			mutex_unlock(&dlci_ioctl_mutex);
 			break;
-		case SIOCGSKNS:
-			err = -EPERM;
-			if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
-				break;
-
-			err = open_net_ns_fd(net);
-			break;
 		default:
 			err = sock_do_ioctl(net, sock, cmd, arg);
 			break;
@@ -3347,7 +3316,6 @@ static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
 	case SIOCSIFVLAN:
 	case SIOCADDDLCI:
 	case SIOCDELDLCI:
-	case SIOCGSKNS:
 		return sock_ioctl(file, cmd, arg);
 
 	case SIOCGIFFLAGS:
-- 
2.24.1



More information about the Devel mailing list