diff mbox series

[next] sysctl: expose all net/core sysctls inside netns

Message ID 20221222191005.71787-1-maheshb@google.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [next] sysctl: expose all net/core sysctls inside netns | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2 this patch: 2
netdev/cc_maintainers warning 3 maintainers not CCed: xiangxia.m.yue@gmail.com hmukos@yandex-team.ru ast@kernel.org
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

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" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
 net/core/sysctl_net_core.c | 5 -----
 1 file changed, 5 deletions(-)

Comments

Soheil Hassas Yeganeh Dec. 22, 2022, 8:16 p.m. UTC | #1
On Thu, Dec 22, 2022 at 2:10 PM Mahesh Bandewar <maheshb@google.com> 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
>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Soheil Hassas Yeganeh <soheil@google.com>
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>

Acked-by: Soheil Hassas Yeganeh <soheil@google.com>

Thanks!

> ---
>  net/core/sysctl_net_core.c | 5 -----
>  1 file changed, 5 deletions(-)
>
> diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
> index 5b1ce656baa1..e7b98162c632 100644
> --- a/net/core/sysctl_net_core.c
> +++ b/net/core/sysctl_net_core.c
> @@ -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
Jakub Kicinski Dec. 23, 2022, 2:12 a.m. UTC | #2
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.
On Thu, Dec 22, 2022 at 6:12 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> 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.
diff mbox series

Patch

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index 5b1ce656baa1..e7b98162c632 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -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);