[Devel] [PATCH RHEL7 COMMIT] net: export "net/core/xfrm*" sysctls for containers

Vasily Averin vvs at virtuozzo.com
Tue Sep 14 09:57:08 MSK 2021


The commit is pushed to "branch-rh7-3.10.0-1160.41.1.vz7.183.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.41.1.vz7.183.3
------>
commit 22dee1003c153a8b787e9cb54834a41c6ae2e257
Author: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
Date:   Tue Sep 14 09:57:08 2021 +0300

    net: export "net/core/xfrm*" sysctls for containers
    
    These sysctls only modify namespace-local XFRM protocol settings, and
    are used by 'libreswan' package.
    
    https://jira.sw.ru/browse/PSBM-132916
    Signed-off-by: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 net/xfrm/xfrm_sysctl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
index 05a6e3d..de612e6 100644
--- a/net/xfrm/xfrm_sysctl.c
+++ b/net/xfrm/xfrm_sysctl.c
@@ -1,5 +1,6 @@
 #include <linux/sysctl.h>
 #include <linux/slab.h>
+#include <linux/ve.h>
 #include <net/net_namespace.h>
 #include <net/xfrm.h>
 
@@ -54,8 +55,8 @@ int __net_init xfrm_sysctl_init(struct net *net)
 	table[2].data = &net->xfrm.sysctl_larval_drop;
 	table[3].data = &net->xfrm.sysctl_acq_expires;
 
-	/* Don't export sysctls to unprivileged users */
-	if (net->user_ns != &init_user_ns)
+	/* Export sysctls only to root userns of the host or the container */
+	if (ve_net_hide_sysctl(net))
 		table[0].procname = NULL;
 
 	net->xfrm.sysctl_hdr = register_net_sysctl(net, "net/core", table);


More information about the Devel mailing list