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

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 13 20:39:23 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.29
------>
commit b45bbc8354fa0e03fc6f877f5f489d68bd27121a
Author: Jan Dakinevich <jan.dakinevich at virtuozzo.com>
Date:   Fri Jan 25 17:37:55 2019 +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>
---
 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 4f07f9298e12..f3b18762070c 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>
@@ -572,9 +573,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