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

Konstantin Khorenko khorenko at virtuozzo.com
Tue Dec 14 19:45:04 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.36
------>
commit 2549cc3e0fbfe7e18abfca74d65714f2f2ecd7a1
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>
    
    (cherry picked from vz8 commit 22dee1003c153a8b787e9cb54834a41c6ae2e257)
    Signed-off-by: Konstantin Khorenko <khorenko 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 0c6c5ef65f9d..8ddb0cd0010c 100644
--- a/net/xfrm/xfrm_sysctl.c
+++ b/net/xfrm/xfrm_sysctl.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <linux/sysctl.h>
 #include <linux/slab.h>
+#include <linux/ve.h>
 #include <net/net_namespace.h>
 #include <net/xfrm.h>
 
@@ -55,8 +56,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