Linux Container Development
 help / color / mirror / Atom feed
From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman)
To: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: handling of supplemental groups with userns
Date: Tue, 22 Sep 2015 14:40:07 -0500	[thread overview]
Message-ID: <87d1xafdk8.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <20150922162157.GB27286-UgUKS2FnFs9+urZeOPWqwQ@public.gmane.org> (Mike Frysinger's message of "Tue, 22 Sep 2015 12:21:57 -0400")

Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org> writes:

> is it possible to map in supplemental groups in a userns when the user
> lacks setgid/etc... capabilities in the parent ns ?  it doesn't seem
> like it's currently possible, but is there a reason to not enable it ?

In your unprivileged use scenario, you won't be able to drop
your supplementary groups so why do you need them mapped?

> basically i have a build tool that i want to isolate a bit, but it
> requires access to some of my supplemental groups.  if i map just
> my effective uid/gid, the build will fail when it tries to use the
> chown/chgrp commands (gets back EINVAL).

Yes.  That really isn't valid as you are dropping groups.  Peculiarly
enough dropping groups can be a security issue as in some permission
checks not being a member of a group can give you enhanced access to
files and directories.

So to do something like what you want, you need a setuid helper (something
like newuidmap or newgidmap) to verify that what you are doing is ok
by local policy.

> my scenario boils down to:
>  - normal unprivileged user (uid=8282)
>  - member of multiple groups (gid=100, getgroups={100,16,250,...})
>  - create a new userns (to get access to other ns like mount/pid)
>    but still have access to existing groups where i'm root
>  - use various features that require caps (new pidns/mntns/etc...)
>  - create another userns and map back non-root users/groups
> i.e. i switch from 8282 to 0, do what i need, then switch back to 8282.

[snip]

> in the mean time, a "quick" fix might be to change new_idmap_permitted
> to walk all the extents, and if all the ranges are set to 1, check the
> supplemental groups in addition to the current egid ?

That allows dropping groups that you could not drop normally and so we
can't allow it, by default.

Eric

       reply	other threads:[~2015-09-22 19:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20150922162157.GB27286@vapier.lan>
     [not found] ` <20150922162157.GB27286-UgUKS2FnFs9+urZeOPWqwQ@public.gmane.org>
2015-09-22 19:40   ` Eric W. Biederman [this message]
     [not found]     ` <87d1xafdk8.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
2015-09-22 21:52       ` handling of supplemental groups with userns Mike Frysinger
     [not found]         ` <20150922215215.GE27286-UgUKS2FnFs9+urZeOPWqwQ@public.gmane.org>
2015-09-29  3:06           ` Mike Frysinger
2015-09-22 16:21 Mike Frysinger

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=87d1xafdk8.fsf@x220.int.ebiederm.org \
    --to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org \
    /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