linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giuseppe Scrivano <gscrivan@redhat.com>
To: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Snaipe <snaipe@arista.com>,
	alexander@mihalicyn.com, christian.brauner@ubuntu.com,
	Linux Containers <containers@lists.linux.dev>,
	cyphar@cyphar.com, ebiederm@xmission.com, geofft@ldpreload.com,
	jcsible@cert.org, josh@joshtriplett.org, keescook@chromium.org,
	linux-kernel@vger.kernel.org, luto@amacapital.net,
	mic@digikod.net, mpatel@redhat.com, ptikhomirov@virtuozzo.com,
	sargun@sargun.me, stgraber@ubuntu.com, vgoyal@redhat.com,
	watl@google.com
Subject: Re: LPC 2020 Hackroom Session: summary and next steps for isolated user namespaces
Date: Mon, 10 May 2021 15:02:51 +0200	[thread overview]
Message-ID: <87cztyhhc4.fsf@redhat.com> (raw)
In-Reply-To: <20210507133703.GB22450@mail.hallyn.com> (Serge E. Hallyn's message of "Fri, 7 May 2021 08:37:03 -0500")

Hi Serge,

"Serge E. Hallyn" <serge@hallyn.com> writes:

> On Thu, Apr 22, 2021 at 11:18:01AM +0200, Giuseppe Scrivano wrote:
>> Snaipe <snaipe@arista.com> writes:
>> 
>> > "Giuseppe Scrivano" <gscrivan@redhat.com> writes:
>> >>>> >> instead of a prctl, I've added a new mode to /proc/PID/setgroups that
>> >>>> >> allows setgroups in a userns locking the current gids.
>> >>>> >> 
>> >>>> >> What do you think about using /proc/PID/setgroups instead of a new
>> >>>> >> prctl()?
>> >>>> >
>> >>>> > It's better than not having it, but two concerns -
>> >>>> >
>> >>>> > 1. some userspace, especially testsuites, could become confused by the fact
>> >>>> > that they can't drop groups no matter how hard they try, since these will all
>> >>>> > still show up as regular groups.
>> >>>> 
>> >>>> I forgot to send a link to a second patch :-) that completes the feature:
>> >>>> https://github.com/giuseppe/linux/commit/1c5fe726346b216293a527719e64f34e6297f0c2
>> >>>> 
>> >>>> When the new mode is used, the gids that are not known in the userns do
>> >>>> not show up in userspace.
>> >>>
>> >>> Ah, right - and of course those gids better not be mapped into the namespace :)
>> >>>
>> >>> But so, this is the patch you said you agreed was not worth the extra
>> >>> complexity?
>> >>
>> >> yes, these two patches are what looked too complex at that time.  The
>> >> problem still exists though, we could perhaps reconsider if the
>> >> extra-complexity is acceptable to address it.
>> >
>> > Hey Folks, sorry for necro-bumping, but I've found this discussion
>> > while searching for this specific issue, and it seems like the most
>> > recent relevant discussion on the matter. I'd like to chime in with
>> > our personal experience.
>> >
>> > We have a tool[1] that allows unprivileged use of namespaces
>> > (when using a userns, which is the default).
>> >
>> > The primary use-case of said tool is lightweight containerization,
>> > but we're also using it for other mundane usages, like a better
>> > substitute for fakeroot to build and package privileged software
>> > (e.g. sudo or ping, which needs to be installed with special
>> > capabilities) unprivileged, or to copy file trees that are owned by
>> > the user or sub-ids.
>> >
>> > For the first use-case, it's always safe to drop unmapped groups,
>> > because the target rootfs is always owned by the user or its sub-ids.
>> >
>> > For the other use-cases, this is more problematic, as you're all
>> > well-aware of. Our position right now is that the tool will always
>> > allow setgroups in user namespace, and that it's not safe to use on
>> > systems that rely on negative access groups.
>> >
>> > I think that something that's not mentioned is that if a user setgroups
>> > to a fixed list of subgids, dropping all unmapped gids, they don't just
>> > gain the ability to access these negative-access files, they also lose
>> > legitimate access to files that their unmapped groups allow them to
>> > access. This is fine for our first use-case, but a bit surprising for
>> > the second one -- and since setgroups never lets us keep unmapped gids,
>> > we have no way to keep these desired groups.
>> >
>> > From a first glance, a sysctl that explicitly controls that would not
>> > address the above problem, but keeping around the original group list
>> > of the owner of the user ns would have the desired semantics.
>> >
>> > Giuseppe's patch seems to address this use case, which would personally
>> > make me very happy.
>> >
>> > [1]: https://github.com/aristanetworks/bst
>> 
>> thanks for the feedback.  We are still facing the issue with rootless
>> Podman, and these patches (listed here so you won't need to dig into archives):
>> 
>> https://github.com/giuseppe/linux/commit/7e0701b389c497472d11fab8570c153a414050af
>> https://github.com/giuseppe/linux/commit/1c5fe726346b216293a527719e64f34e6297f0c2
>> 
>> would solve the issue for us as well and we can use setgroups within a
>> user namespace in a safe way.
>> 
>> Any comments on this approach?  Could we move forward with it?
>
> Can you send these to lkml?  I'll have to go back through our previous
> discussions, but offhand this looks good to me.

I've just sent them to lkml.

Regards,
Giuseppe


  reply	other threads:[~2021-05-10 13:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-30 14:39 LPC 2020 Hackroom Session: summary and next steps for isolated user namespaces Christian Brauner
2020-10-10  4:26 ` Serge E. Hallyn
2020-10-11 20:53   ` Josh Triplett
2020-10-12  0:38     ` Andy Lutomirski
2020-10-12  5:01       ` Eric W. Biederman
2020-10-12 15:00         ` Serge E. Hallyn
2020-10-14 19:46           ` Eric W. Biederman
2020-10-15 14:27             ` Serge E. Hallyn
2020-10-17 15:04               ` Eric W. Biederman
2020-10-12 17:05     ` Giuseppe Scrivano
2020-10-13 12:46       ` Serge E. Hallyn
2020-10-13 15:17         ` Giuseppe Scrivano
2020-10-15 14:32           ` Serge E. Hallyn
2020-10-19 12:12             ` Giuseppe Scrivano
2021-04-21 17:27               ` Snaipe
2021-04-22  9:18                 ` Giuseppe Scrivano
2021-04-23 14:36                   ` Franklin “Snaipe” Mathieu
2021-05-07 13:37                   ` Serge E. Hallyn
2021-05-10 13:02                     ` Giuseppe Scrivano [this message]
2021-05-10 13:57                       ` Giuseppe Scrivano
2020-10-15 15:31 ` Enrico Weigelt, metux IT consult
2020-10-17 16:51   ` Eric W. Biederman
2020-10-18 10:20     ` Christian Brauner
2020-10-18 13:05       ` The problem of setgroups and containers Eric W. Biederman
2020-10-19  0:15         ` Eric W. Biederman
2020-10-19 20:07           ` [RFC][PATCH] userns: Limit process in a user namespace to what the creator is allowed Eric W. Biederman
2020-10-20 14:11             ` Christian Brauner
2020-10-29 13:42     ` LPC 2020 Hackroom Session: summary and next steps for isolated user namespaces Enrico Weigelt, metux IT consult

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cztyhhc4.fsf@redhat.com \
    --to=gscrivan@redhat.com \
    --cc=alexander@mihalicyn.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=containers@lists.linux.dev \
    --cc=cyphar@cyphar.com \
    --cc=ebiederm@xmission.com \
    --cc=geofft@ldpreload.com \
    --cc=jcsible@cert.org \
    --cc=josh@joshtriplett.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mic@digikod.net \
    --cc=mpatel@redhat.com \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=sargun@sargun.me \
    --cc=serge@hallyn.com \
    --cc=snaipe@arista.com \
    --cc=stgraber@ubuntu.com \
    --cc=vgoyal@redhat.com \
    --cc=watl@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).