[Devel] [PATCH vz9 11/20] net: export net/core/somaxconn sysctl for unprivileged users

Nikita Yushchenko nikita.yushchenko at virtuozzo.com
Wed Oct 13 18:26:22 MSK 2021


From: Jan Dakinevich <jan.dakinevich at virtuozzo.com>

Some unprivileged containers desire this sysctl. Apparently it is safe
for userns root, and there is no reason to restrict them.

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

Signed-off-by: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
Reviewed-by: Vasily Averin <vvs at virtuozzo.com>

(cherry picked from vz7 commit dccf5143b132 ("net: export
net/core/somaxconn sysctl for unprivileged users"))

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

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>

(cherry-picked from vz8 commit 6a248cdbe338 ("net: export
net/core/somaxconn sysctl for unprivileged users"))

Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 net/core/sysctl_net_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index c8496c1142c9..b014d1be56c5 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -15,6 +15,7 @@
 #include <linux/vmalloc.h>
 #include <linux/init.h>
 #include <linux/slab.h>
+#include <linux/ve.h>
 
 #include <net/ip.h>
 #include <net/sock.h>
@@ -621,9 +622,8 @@ static __net_init int sysctl_core_net_init(struct net *net)
 		tbl[0].data = &net->core.sysctl_somaxconn;
 
 		/* Don't export any sysctls to unprivileged users */
-		if (net->user_ns != &init_user_ns) {
+		if (ve_net_hide_sysctl(net))
 			tbl[0].procname = NULL;
-		}
 	}
 
 	net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
-- 
2.30.2



More information about the Devel mailing list