Skip to contentSkip to conversation

sysctl: expose all net/core sysctls inside netns

PATCH In review Mahesh Bandewar 3 participants 4 messages Dec 22, 2022 – Dec 28, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysctl: expose all net/core sysctls inside netns

All were not visible to the non-priv users inside netns. However, with 4ecb90090c84 ("sysctl: allow override of /proc/sys/net with CAP_NET_ADMIN"), these vars are protected from getting modified. A proc with capable(CAP_NET_ADMIN) can change the values so not having them visible inside netns is just causing nuisance to process that check certain values (e.g. net.core.somaxconn) and see different behavior in root-netns vs. other-netns

Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>
---
 net/core/sysctl_net_core.c | 5 -----
 1 file changed, 5 deletions(-)
net/core/sysctl_net_core.c +0 -5
index 5b1ce656baa1..e7b98162c632 100644
@@ -643,11 +643,6 @@ static __net_init int sysctl_core_net_init(struct net *net)
 
 		for (tmp = tbl; tmp->procname; tmp++)
 			tmp->data += (char *)net - (char *)&init_net;
-
-		/* Don't export any sysctls to unprivileged users */
-		if (net->user_ns != &init_user_ns) {
-			tbl[0].procname = NULL;
-		}
 	}
 
 	net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
Signature · 1 line
2.39.0.314.g84b9a713c41-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Mahesh Bandewar

All were not visible to the non-priv users inside netns. However, with 4ecb90090c84 ("sysctl: allow override of /proc/sys/net with CAP_NET_ADMIN"), these vars are protected from getting modified. A proc with capable(CAP_NET_ADMIN) can change the values so not having them visible inside netns is just causing nuisance to process that check certain values (e.g. net.core.somaxconn) and see different behavior in root-netns vs. other-netns

Quoted 6 lines
Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Soheil Hassas Yeganeh <[email protected]>

Thanks!

Quoted 22 lines
---
 net/core/sysctl_net_core.c | 5 -----
 1 file changed, 5 deletions(-)
net/core/sysctl_net_core.c +0 -6
index 5b1ce656baa1..e7b98162c632 100644
@@ -643,11 +643,6 @@ static __net_init int sysctl_core_net_init(struct net *net)
 
                for (tmp = tbl; tmp->procname; tmp++)
                        tmp->data += (char *)net - (char *)&init_net;
-
-               /* Don't export any sysctls to unprivileged users */
-               if (net->user_ns != &init_user_ns) {
-                       tbl[0].procname = NULL;
-               }
        }
 
        net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
--

2.39.0.314.g84b9a713c41-goog

maintainer
#2 lore raw
In reply to Mahesh Bandewar
Quoted 7 lines · On Thu, 22 Dec 2022 11:10:05 -0800 Mahesh Bandewar wrote:

All were not visible to the non-priv users inside netns. However, with 4ecb90090c84 ("sysctl: allow override of /proc/sys/net with CAP_NET_ADMIN"), these vars are protected from getting modified. A proc with capable(CAP_NET_ADMIN) can change the values so not having them visible inside netns is just causing nuisance to process that check certain values (e.g. net.core.somaxconn) and see different behavior in root-netns vs. other-netns

SG, but net-next is closed, please repost after New Year.

#3 lore raw
Quoted 11 lines · Jakub Kicinski
Quoted 7 lines · On Thu, 22 Dec 2022 11:10:05 -0800 Mahesh Bandewar wrote:

All were not visible to the non-priv users inside netns. However, with 4ecb90090c84 ("sysctl: allow override of /proc/sys/net with CAP_NET_ADMIN"), these vars are protected from getting modified. A proc with capable(CAP_NET_ADMIN) can change the values so not having them visible inside netns is just causing nuisance to process that check certain values (e.g. net.core.somaxconn) and see different behavior in root-netns vs. other-netns

SG, but net-next is closed, please repost after New Year.

My bad, thanks for the note. Happy holidays and will post it next year.