All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace
@ 2021-09-21  6:22 Alexander Kuznetsov
  2021-09-21 13:09 ` Jakub Kicinski
  2021-09-30 14:59 ` Eric W. Biederman
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Kuznetsov @ 2021-09-21  6:22 UTC (permalink / raw)
  To: netdev; +Cc: zeil

We want to increase route cache size in network namespace
created with user namespace. Currently ipv6 route settings
are disabled for non-initial network namespaces.
Since routes are per network namespace it is safe
to enable these sysctls.

Signed-off-by: Alexander Kuznetsov <wwfq@yandex-team.ru>
Acked-by: Dmitry Yakunin <zeil@yandex-team.ru>
---
 net/ipv6/route.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b6ddf23..de85e3b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -6415,10 +6415,6 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
 		table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
 		table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
 		table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
-
-		/* Don't export sysctls to unprivileged users */
-		if (net->user_ns != &init_user_ns)
-			table[0].procname = NULL;
 	}
 
 	return table;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace
  2021-09-21  6:22 [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace Alexander Kuznetsov
@ 2021-09-21 13:09 ` Jakub Kicinski
  2021-09-21 15:32   ` Florian Westphal
  2021-09-30  8:44   ` Alexander Al. Kuznetsov
  2021-09-30 14:59 ` Eric W. Biederman
  1 sibling, 2 replies; 7+ messages in thread
From: Jakub Kicinski @ 2021-09-21 13:09 UTC (permalink / raw)
  To: Alexander Kuznetsov; +Cc: netdev, zeil

On Tue, 21 Sep 2021 09:22:04 +0300 Alexander Kuznetsov wrote:
> We want to increase route cache size in network namespace
> created with user namespace. Currently ipv6 route settings
> are disabled for non-initial network namespaces.
> Since routes are per network namespace it is safe
> to enable these sysctls.
> 
> Signed-off-by: Alexander Kuznetsov <wwfq@yandex-team.ru>
> Acked-by: Dmitry Yakunin <zeil@yandex-team.ru>

Your CC list is very narrow. IMO you should CC Eric B on this, 
at the very least.

Why only remove this part and not any other part of 464dc801c76aa?

> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index b6ddf23..de85e3b 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -6415,10 +6415,6 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
>  		table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
>  		table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
>  		table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
> -
> -		/* Don't export sysctls to unprivileged users */
> -		if (net->user_ns != &init_user_ns)
> -			table[0].procname = NULL;
>  	}
>  
>  	return table;

I don't know much about user ns, are we making an assumption here that
this user ns corresponds to a net ns? Or just because it's _possible_
to make them 1:1 we can shift the decision to the admin?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace
  2021-09-21 13:09 ` Jakub Kicinski
@ 2021-09-21 15:32   ` Florian Westphal
  2021-09-25 15:25     ` David Ahern
  2021-09-30  8:44   ` Alexander Al. Kuznetsov
  1 sibling, 1 reply; 7+ messages in thread
From: Florian Westphal @ 2021-09-21 15:32 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: Alexander Kuznetsov, netdev, zeil

Jakub Kicinski <kuba@kernel.org> wrote:
> On Tue, 21 Sep 2021 09:22:04 +0300 Alexander Kuznetsov wrote:
> > We want to increase route cache size in network namespace
> > created with user namespace. Currently ipv6 route settings
> > are disabled for non-initial network namespaces.
> > Since routes are per network namespace it is safe
> > to enable these sysctls.

Are routes accounted towards memcg or something like that?

Otherwise userns could start eating up memory by cranking the limit
up to 11 and just adds a gazillion routes?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace
  2021-09-21 15:32   ` Florian Westphal
@ 2021-09-25 15:25     ` David Ahern
  0 siblings, 0 replies; 7+ messages in thread
From: David Ahern @ 2021-09-25 15:25 UTC (permalink / raw)
  To: Florian Westphal, Jakub Kicinski; +Cc: Alexander Kuznetsov, netdev, zeil

On 9/21/21 9:32 AM, Florian Westphal wrote:
> Jakub Kicinski <kuba@kernel.org> wrote:
>> On Tue, 21 Sep 2021 09:22:04 +0300 Alexander Kuznetsov wrote:
>>> We want to increase route cache size in network namespace
>>> created with user namespace. Currently ipv6 route settings
>>> are disabled for non-initial network namespaces.
>>> Since routes are per network namespace it is safe
>>> to enable these sysctls.
> 
> Are routes accounted towards memcg or something like that?
> 
> Otherwise userns could start eating up memory by cranking the limit
> up to 11 and just adds a gazillion routes?
> 

Adding FIB entries I believe is now handled after commit:

commit 6126891c6d4f6f4ef50323d2020635ee255a796e
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Mon Jul 19 13:44:31 2021 +0300

    memcg: enable accounting for IP address and routing-related objects


The ip6_rt_max_size sysctl manages the number of dst entries (cached
dst's and exceptions) that can be created, and there should be some
limit that network namespace users can not exceed.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace
  2021-09-21 13:09 ` Jakub Kicinski
  2021-09-21 15:32   ` Florian Westphal
@ 2021-09-30  8:44   ` Alexander Al. Kuznetsov
  1 sibling, 0 replies; 7+ messages in thread
From: Alexander Al. Kuznetsov @ 2021-09-30  8:44 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, zeil, ebiederm, davem



> On 21 Sep 2021, at 16:09, Jakub Kicinski <kuba@kernel.org> wrote:
> 
> On Tue, 21 Sep 2021 09:22:04 +0300 Alexander Kuznetsov wrote:
>> We want to increase route cache size in network namespace
>> created with user namespace. Currently ipv6 route settings
>> are disabled for non-initial network namespaces.
>> Since routes are per network namespace it is safe
>> to enable these sysctls.
>> 
>> Signed-off-by: Alexander Kuznetsov <wwfq@yandex-team.ru>
>> Acked-by: Dmitry Yakunin <zeil@yandex-team.ru>
> 
> Your CC list is very narrow. IMO you should CC Eric B on this, 
> at the very least.
> 
> Why only remove this part and not any other part of 464dc801c76aa?

We remove this part by analogy with 5cdda5f1d6add and enable only sysctls that we need.

>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
>> index b6ddf23..de85e3b 100644
>> --- a/net/ipv6/route.c
>> +++ b/net/ipv6/route.c
>> @@ -6415,10 +6415,6 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
>> 		table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
>> 		table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
>> 		table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
>> -
>> -		/* Don't export sysctls to unprivileged users */
>> -		if (net->user_ns != &init_user_ns)
>> -			table[0].procname = NULL;
>> 	}
>> 
>> 	return table;
> 
> I don't know much about user ns, are we making an assumption here that
> this user ns corresponds to a net ns? Or just because it's _possible_
> to make them 1:1 we can shift the decision to the admin?

Sorry, but I don't understand what you mean.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace
  2021-09-21  6:22 [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace Alexander Kuznetsov
  2021-09-21 13:09 ` Jakub Kicinski
@ 2021-09-30 14:59 ` Eric W. Biederman
  1 sibling, 0 replies; 7+ messages in thread
From: Eric W. Biederman @ 2021-09-30 14:59 UTC (permalink / raw)
  To: Alexander Kuznetsov
  Cc: netdev, zeil, Jakub Kicinski, Florian Westphal, David Ahern

Alexander Kuznetsov <wwfq@yandex-team.ru> writes:

> We want to increase route cache size in network namespace
> created with user namespace. Currently ipv6 route settings
> are disabled for non-initial network namespaces.
> Since routes are per network namespace it is safe
> to enable these sysctls.

The case where this matters is when the network namespaces is created by
by the root user in a user namespace.  AKA this is something we allow
any user to do.

These were disabled because out of an abundance of caution rather than
any particular policy when the kernel started allowing non-root users
to create network namespaces.

That said it would really help if your commit message listed the
sysctls you are enabling and listed why it was safe to enable them.

That is it would really help if you performed the review that says
the sysctls are safe for ordinary users to use and that they won't
enable DOS attacks or the like.

If you just care about the route cache size you can only enable
that sysctl.

These are the 10 sysctls you are enabling.  All you talk about
in your commit message is route cache size which I believe is
the 3rd entry in the table net->ipv6.sysctl.ip6_rt_max_size.
It certainly is not all of them.

		table[0].data = &net->ipv6.sysctl.flush_delay;
		table[1].data = &net->ipv6.ip6_dst_ops.gc_thresh;
		table[2].data = &net->ipv6.sysctl.ip6_rt_max_size;
		table[3].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
		table[4].data = &net->ipv6.sysctl.ip6_rt_gc_timeout;
		table[5].data = &net->ipv6.sysctl.ip6_rt_gc_interval;
		table[6].data = &net->ipv6.sysctl.ip6_rt_gc_elasticity;
		table[7].data = &net->ipv6.sysctl.ip6_rt_mtu_expires;
		table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
		table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
		table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;


I took a quick look and we don't enable any of these for ipv4 either.

I suspect it is probably reasonable to enable these sysctls for
all users of the system to use, but can we please show the reason
for each sysctl why it is safe?

Thank you.

Eric



> Signed-off-by: Alexander Kuznetsov <wwfq@yandex-team.ru>
> Acked-by: Dmitry Yakunin <zeil@yandex-team.ru>
> ---
>  net/ipv6/route.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> index b6ddf23..de85e3b 100644
> --- a/net/ipv6/route.c
> +++ b/net/ipv6/route.c
> @@ -6415,10 +6415,6 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
>  		table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
>  		table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
>  		table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
> -
> -		/* Don't export sysctls to unprivileged users */
> -		if (net->user_ns != &init_user_ns)
> -			table[0].procname = NULL;
>  	}
>  
>  	return table;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace
@ 2021-09-09 11:14 Alexander Kuznetsov
  0 siblings, 0 replies; 7+ messages in thread
From: Alexander Kuznetsov @ 2021-09-09 11:14 UTC (permalink / raw)
  To: netdev; +Cc: zeil

We want to increase route cache size in network namespace
created with user namespace. Currently ipv6 route settings
are disabled for non-initial network namespaces.
Since routes are per network namespace it is safe
to enable these sysctls.

Signed-off-by: Alexander Kuznetsov <wwfq@yandex-team.ru>
Acked-by: Dmitry Yakunin <zeil@yandex-team.ru>
---
 net/ipv6/route.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b6ddf23..de85e3b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -6415,10 +6415,6 @@ struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
 		table[8].data = &net->ipv6.sysctl.ip6_rt_min_advmss;
 		table[9].data = &net->ipv6.sysctl.ip6_rt_gc_min_interval;
 		table[10].data = &net->ipv6.sysctl.skip_notify_on_dev_down;
-
-		/* Don't export sysctls to unprivileged users */
-		if (net->user_ns != &init_user_ns)
-			table[0].procname = NULL;
 	}
 
 	return table;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-09-30 14:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21  6:22 [PATCH] ipv6: enable net.ipv6.route sysctls in network namespace Alexander Kuznetsov
2021-09-21 13:09 ` Jakub Kicinski
2021-09-21 15:32   ` Florian Westphal
2021-09-25 15:25     ` David Ahern
2021-09-30  8:44   ` Alexander Al. Kuznetsov
2021-09-30 14:59 ` Eric W. Biederman
  -- strict thread matches above, loose matches on Subject: below --
2021-09-09 11:14 Alexander Kuznetsov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.