Re: [PATCH] userns: Default to 'yes' when CONFIG_MEMCG option is enabled

From: Christian Brauner
Date: Fri May 24 2024 - 07:48:53 EST


On Fri, May 24, 2024 at 10:24:16AM +0200, Javier Martinez Canillas wrote:
> The default value for the CONFIG_USER_NS Kconfig symbol changed over time.
>
> When first was introduced by commit acce292c82d4 ("user namespace: add the
> framework"), the default was 'no'. But then it was changed to 'yes' if the
> CONFIG_NAMESPACES option was enabled, by commit 17a6d4411a4d ("namespaces:
> default all the namespaces to 'yes' when CONFIG_NAMESPACES is selected").
>
> Then, commit 5673a94c1457 ("userns: Add a Kconfig option to enforce strict
> kuid and kgid type checks") changed the default to 'no' again and selected
> the (now defunct) UIDGID_STRICT_TYPE_CHECKS option.
>
> This selected option was removed by commit 261000a56b63 ("userns: Remove
> UIDGID_STRICT_TYPE_CHECKS"), but CONFIG_USER_NS default was left to 'no'.
>
> Finally, the commit e11f0ae388f2 ("userns: Recommend use of memory control
> groups") added to the Kconfig symbol's help text a recommendation that the
> memory control groups should be used, to limit the amount of memory that a
> user who can create user namespaces can consume.
>
> Looking at the changes' history, a default to 'yes' when the CONFIG_MEMCG
> option is enabled seems like a sane thing to do. Specially since systemd
> requires user namespaces support for services that use the PrivateUsers=
> property in their unit files (e.g: the UPower daemon).

Fyi, user namespaces are an entirely optional feature in systemd and it
gracefully falls back if they are not available with PrivateUsers= set.
If that isn't the case then it's a bug in systemd with PrivateUsers=
handling and should be reported.

But specifically to you change, afair CONFIG_MEMCG and userns are
unrelated so tying them together like this in the kconfig seems
misguided.