lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210118143932.56069-2-dong.menglong@zte.com.cn>
Date:   Mon, 18 Jan 2021 22:39:30 +0800
From:   menglong8.dong@...il.com
To:     kuba@...nel.org, christian.brauner@...ntu.com
Cc:     davem@...emloft.net, yoshfuji@...ux-ipv6.org,
        dong.menglong@....com.cn, daniel@...earbox.net, gnault@...hat.com,
        ast@...nel.org, nicolas.dichtel@...nd.com, ap420073@...il.com,
        edumazet@...gle.com, pabeni@...hat.com, jakub@...udflare.com,
        bjorn.topel@...el.com, keescook@...omium.org,
        viro@...iv.linux.org.uk, rdna@...com, maheshb@...gle.com,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH net-next 1/3] net: core: init every ctl_table in netns_core_table

From: Menglong Dong <dong.menglong@....com.cn>

For now, there is only one element in netns_core_table, and it is inited
directly in sysctl_core_net_init. To make it more flexible, we can init
every element at once, just like what ipv4_sysctl_init_net() did.

Signed-off-by: Menglong Dong <dong.menglong@....com.cn>
---
 net/core/sysctl_net_core.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index d86d8d11cfe4..966d976dee84 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -606,15 +606,19 @@ static __net_init int sysctl_core_net_init(struct net *net)
 
 	tbl = netns_core_table;
 	if (!net_eq(net, &init_net)) {
+		int i;
+
 		tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
 		if (tbl == NULL)
 			goto err_dup;
 
-		tbl[0].data = &net->core.sysctl_somaxconn;
+		/* Update the variables to point into the current struct net */
+		for (i = 0; i < ARRAY_SIZE(netns_core_table) - 1; i++) {
+			tbl[i].data += (void *)net - (void *)&init_net;
 
-		/* Don't export any sysctls to unprivileged users */
-		if (net->user_ns != &init_user_ns) {
-			tbl[0].procname = NULL;
+			/* Don't export any sysctls to unprivileged users */
+			if (net->user_ns != &init_user_ns)
+				tbl[i].procname = NULL;
 		}
 	}
 
-- 
2.30.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ