diff mbox series

[net-next] net: Enable unix sysctls to be configurable by non-init user namespaces

Message ID 20211207202101.2457994-1-joannekoong@fb.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: Enable unix sysctls to be configurable by non-init user namespaces | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
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: 0 this patch: 0
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Joanne Koong Dec. 7, 2021, 8:21 p.m. UTC
Currently, when a networking namespace is initialized, its unix sysctls
are exposed only if the user namespace that "owns" it is the init user
namespace.

If there is a non-init user namespace that "owns" a networking
namespace (for example, in the case after we call clone() with both
CLONE_NEWUSER and CLONE_NEWNET set), the sysctls are hidden from view
and not configurable.

This patch enables the unix networking sysctls (there is currently only
1, "sysctl_max_dgram_qlen", which is used as the default
"sk_max_ack_backlog" value when a unix socket is created) to be exposed
to non-init user namespaces.

This is safe because any changes made to these sysctls will be limited
in scope to the networking namespace the non-init user namespace "owns"
and has privileges over.

Signed-off-by: Joanne Koong <joannekoong@fb.com>
---
 net/unix/sysctl_net_unix.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Jakub Kicinski Dec. 8, 2021, 5:49 a.m. UTC | #1
CC: Eric B

On Tue, 7 Dec 2021 12:21:01 -0800 Joanne Koong wrote:
> Currently, when a networking namespace is initialized, its unix sysctls
> are exposed only if the user namespace that "owns" it is the init user
> namespace.
> 
> If there is a non-init user namespace that "owns" a networking
> namespace (for example, in the case after we call clone() with both
> CLONE_NEWUSER and CLONE_NEWNET set), the sysctls are hidden from view
> and not configurable.
> 
> This patch enables the unix networking sysctls (there is currently only
> 1, "sysctl_max_dgram_qlen", which is used as the default
> "sk_max_ack_backlog" value when a unix socket is created) to be exposed
> to non-init user namespaces.
> 
> This is safe because any changes made to these sysctls will be limited
> in scope to the networking namespace the non-init user namespace "owns"
> and has privileges over.
> 
> Signed-off-by: Joanne Koong <joannekoong@fb.com>
> ---
>  net/unix/sysctl_net_unix.c | 4 ----
>  1 file changed, 4 deletions(-)
> 
> diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
> index c09bea89151b..01d44e2598e2 100644
> --- a/net/unix/sysctl_net_unix.c
> +++ b/net/unix/sysctl_net_unix.c
> @@ -30,10 +30,6 @@ int __net_init unix_sysctl_register(struct net *net)
>  	if (table == NULL)
>  		goto err_alloc;
>  
> -	/* Don't export sysctls to unprivileged users */
> -	if (net->user_ns != &init_user_ns)
> -		table[0].procname = NULL;
> -
>  	table[0].data = &net->unx.sysctl_max_dgram_qlen;
>  	net->unx.ctl = register_net_sysctl(net, "net/unix", table);
>  	if (net->unx.ctl == NULL)
diff mbox series

Patch

diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
index c09bea89151b..01d44e2598e2 100644
--- a/net/unix/sysctl_net_unix.c
+++ b/net/unix/sysctl_net_unix.c
@@ -30,10 +30,6 @@  int __net_init unix_sysctl_register(struct net *net)
 	if (table == NULL)
 		goto err_alloc;
 
-	/* Don't export sysctls to unprivileged users */
-	if (net->user_ns != &init_user_ns)
-		table[0].procname = NULL;
-
 	table[0].data = &net->unx.sysctl_max_dgram_qlen;
 	net->unx.ctl = register_net_sysctl(net, "net/unix", table);
 	if (net->unx.ctl == NULL)