mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: Cedric Le Goater <clg@fr.ibm.com>,
	linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>,
	Kirill Korotaev <dev@openvz.org>, Andrey Savochkin <saw@sw.ru>,
	Herbert Poetzl <herbert@13thfloor.at>,
	Sam Vilain <sam.vilain@catalyst.net.nz>,
	Dave Hansen <haveblue@us.ibm.com>
Subject: Re: [PATCH -mm 5/7] add user namespace
Date: Fri, 14 Jul 2006 09:05:41 -0600	[thread overview]
Message-ID: <m1fyh4w7ju.fsf@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <20060714141728.GE28436@sergelap.austin.ibm.com> (Serge E. Hallyn's message of "Fri, 14 Jul 2006 09:17:28 -0500")

"Serge E. Hallyn" <serue@us.ibm.com> writes:

> Quoting Eric W. Biederman (ebiederm@xmission.com):
>> Cedric Le Goater <clg@fr.ibm.com> writes:
>> 
>> > Eric W. Biederman wrote:
>> >> Cedric Le Goater <clg@fr.ibm.com> writes:
>> >> 
>> >>> This patch adds the user namespace.
>> >>>
>> >>> Basically, it allows a process to unshare its user_struct table,
>> >>> resetting at the same time its own user_struct and all the associated
>> >>> accounting.
>> >>>
>> >>> For the moment, the root_user is added to the new user namespace when
>> >>> it is cloned. An alternative behavior would be to let the system
>> >>> allocate a new user_struct(0) in each new user namespace. However,
>> >>> these 0 users would not have the privileges of the root_user and it
>> >>> would be necessary to work on the process capabilities to give them
>> >>> some permissions.
>> >> 
>> >> It is completely the wrong thing for a the root_user to span multiple
>> >> namespaces as you describe.  It is important for uid 0 in other namespaces
>> >> to not have the privileges of the root_user.  That is half the point.
>> >
>> > ok good. that's what i thought also.
>> >
>> >> Too many files in sysfs and proc don't require caps but instead simply
>> >> limit things to uid 0.  Having a separate uid 0 in the different namespaces
>> >> instantly makes all of these files inaccessible, and keeps processes from
>> >> doing something bad.
>> >
>> > but in order to be useful, the uid 0 in other namespaces will need to have
>> > some capabilities.
>> 
>> Yes.  It is useful for uid 0 in other namespaces to have some capabilities.
>> But that is just a matter of giving another user some additional
>> capabilities.  That mechanism may still work but it should not be
>> namespace specific magic there.  The trick I guess is which
>> capabilities a setuid binary for the other root user gets.
>
> Agreed.  Any ideas for how to specify this?  In a sane way?  I suppose
> it could be a part of forking off the user namespace.  No idea what
> interface we'd want to use.  Perhaps root user in the child namespace by
> default gets all the caps as the root user, and is expected to drop what
> it doesn't need?

Currently this is a security module policy, so it gets weird.
The default is:
> int cap_bprm_set_security (struct linux_binprm *bprm)
> {
> 	/* Copied from fs/exec.c:prepare_binprm. */
> 
> 	/* We don't have VFS support for capabilities yet */
> 	cap_clear (bprm->cap_inheritable);
> 	cap_clear (bprm->cap_permitted);
> 	cap_clear (bprm->cap_effective);
> 
> 	/*  To support inheritance of root-permissions and suid-root
> 	 *  executables under compatibility mode, we raise all three
> 	 *  capability sets for the file.
> 	 *
> 	 *  If only the real uid is 0, we only raise the inheritable
> 	 *  and permitted sets of the executable file.
> 	 */
> 
> 	if (!issecure (SECURE_NOROOT)) {
> 		if (bprm->e_uid == 0 || current->uid == 0) {
> 			cap_set_full (bprm->cap_inheritable);
> 			cap_set_full (bprm->cap_permitted);
> 		}
> 		if (bprm->e_uid == 0)
> 			cap_set_full (bprm->cap_effective);
> 	}
> 	return 0;
> }

My gut feel is that we put a cap_suid in struct user, and the
setup some kind of user interface to it.  And then just
have the above routine copy cap_suid from the struct user
and not special case uid == 0.

But only the root user would by default have any caps in his
struct user.

>> No.  The uids in a filesystem are interpreted in some user namespace
>> context.  We can discover that context at the first mount of the
>> filesystem.  Assuming the uids on a filesystem are the same set
>> of uids your process is using is just wrong.
>
> But, when I insert a usb keychain disk into my laptop, that fs assumes
> the uids on it's fs are the same as uids on my laptop...

I agree that setting the fs_user_namespace at mount time is fine.
However when we use a mount that a process in another user namespace
we need to not assume the uids are the same.

Do you see the difference?

> Solving that problem is interesting, but may be something to work with a
> much wider community on.  I.e. the cifs and nifs folks.  I haven't even
> googled to see what they say about it.

Yes.

>> Yes.  Your patch does lay some interesting foundation work.
>> But we must not merge it upstream until we have a complete patchset
>> that handles all of the user namespace issues.
>
> Don't think Cedric expected this to be merged  :)  Just to start
> discussion, which it certainly did...

If we could have [RFC] in front of these proof of concept patches
it would clear up a lot of confusion.

> If we're going to talk about keys (which I'd like to) I think we need to
> decide whether we are just using them as an easy wider-than-uid
> identifier, or if we actually need cryptographic keys to prevent
> "identity theft"  (heheh).  I don't know that we need the latter for
> anything, but of course if we're going to try for a more general
> solution, then we do.

Actually I was thinking something as mundane as a mapping table.  This
uid in this namespace equals that uid in that other namespace.

Eric

  reply	other threads:[~2006-07-14 15:06 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-11  7:50 [PATCH -mm 0/7] execns syscall and " Cedric Le Goater
2006-07-11  7:50 ` [PATCH -mm 1/7] add execns syscall core routine Cedric Le Goater
2006-07-11  7:50 ` [PATCH -mm 2/7] add execns syscall to s390 Cedric Le Goater
2006-07-11 13:44   ` Martin Schwidefsky
2006-07-11 13:44   ` Martin Schwidefsky
2006-07-11 14:44     ` Cedric Le Goater
2006-07-11 14:54       ` Martin Schwidefsky
2006-07-11 15:43         ` Cedric Le Goater
2006-07-11  7:50 ` [PATCH -mm 3/7] add execns syscall to x86_64 Cedric Le Goater
2006-07-11  7:50 ` [PATCH -mm 4/7] add execns syscall to i386 Cedric Le Goater
2006-07-11  7:50 ` [PATCH -mm 5/7] add user namespace Cedric Le Goater
2006-07-11 16:39   ` Kirill Korotaev
2006-07-11 17:38     ` Cedric Le Goater
2006-07-12 11:21       ` Kirill Korotaev
2006-07-13 16:01         ` Cedric Le Goater
2006-07-12  3:33     ` Eric W. Biederman
2006-07-12 11:13       ` Kirill Korotaev
2006-07-12 18:10         ` Eric W. Biederman
2006-07-13 17:00           ` Cedric Le Goater
2006-07-13 18:07             ` Eric W. Biederman
2006-07-13 18:21             ` Eric W. Biederman
2006-07-13 18:31               ` Dave Hansen
2006-07-13 18:54                 ` Eric W. Biederman
2006-07-12  3:46   ` Eric W. Biederman
2006-07-12 12:05     ` Herbert Poetzl
2006-07-12 17:09       ` Eric W. Biederman
2006-07-12 14:00     ` Cedric Le Goater
2006-07-12 17:24       ` Eric W. Biederman
2006-07-13 17:36         ` Cedric Le Goater
2006-07-13 17:47           ` Serge E. Hallyn
2006-07-13 18:14             ` Eric W. Biederman
2006-07-13 18:29               ` Dave Hansen
2006-07-13 19:02                 ` Eric W. Biederman
2006-07-13 20:03                   ` Dave Hansen
2006-07-14  3:45                     ` Eric W. Biederman
2006-07-14 14:28                       ` Dave Hansen
2006-07-14 15:13                         ` Eric W. Biederman
2006-07-14 16:29                           ` Serge E. Hallyn
2006-07-14 16:49                             ` Eric W. Biederman
2006-07-14 16:55                               ` Dave Hansen
2006-07-14 17:08                                 ` Serge E. Hallyn
2006-07-14 17:19                                   ` Dave Hansen
2006-07-14 17:36                                     ` Eric W. Biederman
2006-07-14 18:15                                       ` Trond Myklebust
2006-07-14 18:40                                         ` Eric W. Biederman
2006-07-14 21:04                                           ` Trond Myklebust
2006-07-15  4:09                                             ` Eric W. Biederman
2006-07-15  4:35                                               ` Kyle Moffett
2006-07-15 12:35                                                 ` Eric W. Biederman
2006-07-15 13:25                                                   ` Kyle Moffett
2006-07-15 15:54                                                   ` Dave Hansen
2006-07-15 17:01                                                   ` Trond Myklebust
2006-07-15 23:29                                                     ` Eric W. Biederman
2006-07-16 16:18                                                       ` Dave Hansen
2006-07-14 17:14                                 ` Eric W. Biederman
2006-07-16  8:36                                 ` Kirill Korotaev
2006-07-16 10:08                                   ` Eric W. Biederman
2006-07-14 17:05                               ` Serge E. Hallyn
2006-07-14 17:50                                 ` Kyle Moffett
2006-07-15 11:33                                   ` Serge E. Hallyn
2006-07-14 17:56                                 ` Eric W. Biederman
2006-07-14 16:35                           ` Dave Hansen
2006-07-13 21:41                   ` Serge E. Hallyn
2006-07-14  3:52                     ` Eric W. Biederman
2006-07-14 14:02                       ` Serge E. Hallyn
2006-07-14 14:50                         ` Eric W. Biederman
2006-07-14 16:39                           ` Serge E. Hallyn
2006-07-14 17:18                             ` Eric W. Biederman
2006-07-14 17:24                               ` Dave Hansen
2006-07-14 18:06                                 ` Eric W. Biederman
2006-07-14 18:42                                   ` Dave Hansen
2006-07-14 19:07                                     ` Eric W. Biederman
2006-07-13 17:59           ` Eric W. Biederman
2006-07-13 21:22             ` Serge E. Hallyn
2006-07-14  3:50               ` Eric W. Biederman
2006-07-14 14:17         ` Serge E. Hallyn
2006-07-14 15:05           ` Eric W. Biederman [this message]
2006-07-14 16:46             ` Serge E. Hallyn
2006-07-14 16:58               ` Eric W. Biederman
2006-07-14 15:43           ` Kyle Moffett
2006-07-14 16:13             ` Eric W. Biederman
2006-07-11  7:50 ` [PATCH -mm 6/7] add the user namespace to the execns syscall Cedric Le Goater
2006-07-11  7:50 ` [PATCH -mm 7/7] forbid the use of the unshare syscall on ipc namespaces Cedric Le Goater
2006-07-11 14:10   ` Kirill Korotaev
2006-07-11 15:06     ` Cedric Le Goater
2006-07-11  8:02 ` [PATCH -mm 0/7] execns syscall and user namespace Arjan van de Ven
2006-07-11  8:42   ` Cedric Le Goater
2006-07-11 18:12 ` H. Peter Anvin
2006-07-11 18:26   ` Cedric Le Goater
2006-07-11 18:28     ` H. Peter Anvin
2006-07-11 19:50       ` Ulrich Drepper
2006-07-11 21:50         ` Cedric Le Goater
2006-07-11 21:57           ` H. Peter Anvin
2006-07-12  0:16             ` Ulrich Drepper
2006-07-12  0:25               ` H. Peter Anvin
2006-07-12  0:28           ` H. Peter Anvin
2006-07-11 20:22 ` Eric W. Biederman
2006-07-11 21:28   ` Cedric Le Goater
2006-07-12  3:24     ` Eric W. Biederman
2006-07-12 13:05       ` Cedric Le Goater
2006-07-12 16:56         ` Eric W. Biederman
2006-07-13 16:13           ` Cedric Le Goater
2006-07-12 11:11   ` Kirill Korotaev
2006-07-12 13:10     ` Cedric Le Goater
2006-07-15 17:39 [PATCH -mm 5/7] add " Al Boldi
2006-07-16 12:19 ` Kyle Moffett
2006-07-17 11:25   ` Al Boldi

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=m1fyh4w7ju.fsf@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=akpm@osdl.org \
    --cc=clg@fr.ibm.com \
    --cc=dev@openvz.org \
    --cc=haveblue@us.ibm.com \
    --cc=herbert@13thfloor.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam.vilain@catalyst.net.nz \
    --cc=saw@sw.ru \
    --cc=serue@us.ibm.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

all inboxes | Powered by JetHome®