[Devel] [PATCH RHEL9 COMMIT] net: export net/core/somaxconn sysctl for unprivileged users

Konstantin Khorenko khorenko at virtuozzo.com
Wed Oct 20 11:39:31 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.12
------>
commit c5d54222c87425d3c91adb8340ed9200ec4a25d2
Author: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
Date:   Wed Oct 20 11:39:31 2021 +0300

    net: export net/core/somaxconn sysctl for unprivileged users
    
    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);


More information about the Devel mailing list