Linux Container Development
 help / color / mirror / Atom feed
From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman)
To: "Serge E. Hallyn" <serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org>
Cc: David Howells <dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [PATCH] KEYS: allow changing key ownership with CAP_SYS_ADMIN in a NS
Date: Tue, 03 Oct 2017 09:51:14 -0500	[thread overview]
Message-ID: <87y3oscmjh.fsf@xmission.com> (raw)
In-Reply-To: <20171003041121.GA2751-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org> (Serge E. Hallyn's message of "Mon, 2 Oct 2017 23:11:21 -0500")

"Serge E. Hallyn" <serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org> writes:

> On Mon, Oct 02, 2017 at 10:30:43PM -0500, Eric W. Biederman wrote:
>> Dimitri John Ledkov <xnox-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org> writes:
>> 
>> > Currently, changing key ownership from one namespaced uid/gid to
>> > another namespaced uid/gid is only allowed by processes that have
>> > CAP_SYS_ADMIN in the intial namespace. Fix the capability check to
>> > also check the capability in the current capability.
>> 
>> Nacked-by: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
>> 
>> I won't deny the issue, but unless I am misreading something this
>> will allow me to change the the uid of any key simply by unsharing
>> a user namespace.  At which point there is no point in having a
>> permission check at all.
>
> Right so without having looked closely, at the very least you need to
> verify that the ucrrent user is privileged over key->{uid,gid} and
> over @user and @group.  Now the latter is I *think* being done
> implicitly by the make_kuid(current_user_ns, user) at the top.  So
> you need to further verify that key->uid and key->gid are mapped into
> current_user_ns.
>
> That *may* be sufficient.

Yes.  It sounds like either we need to change something in the
implementation of keys so they have a clear user namespace owner
or implement capable_wrt_key_uidgid.

The latter is tricky so at the very least I would prefer it have a
function of it's own.  Just so people don't handroll the necessary
pattern incorrectly at different places.

Eric

  parent reply	other threads:[~2017-10-03 14:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03  2:45 [PATCH] KEYS: allow changing key ownership with CAP_SYS_ADMIN in a NS Dimitri John Ledkov
     [not found] ` <20171003024528.28242-1-xnox-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-10-03  3:30   ` Eric W. Biederman
     [not found]     ` <87fub0gb6k.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-10-03  4:11       ` Serge E. Hallyn
     [not found]         ` <20171003041121.GA2751-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2017-10-03 14:51           ` Eric W. Biederman [this message]
     [not found]             ` <87y3oscmjh.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2017-10-03 14:56               ` Serge E. Hallyn
2017-10-03 15:04               ` David Howells
2017-10-14 20:59       ` Dimitri John Ledkov

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=87y3oscmjh.fsf@xmission.com \
    --to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=dhowells-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=serge-A9i7LUbDfNHQT0dZR+AlfA@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