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: Linux Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Al Viro <viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	Cyrill Gorcunov
	<gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Linus Torvalds
	<torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH 18/43] userns: Convert group_info values from gid_t to kgid_t.
Date: Fri, 20 Apr 2012 16:05:34 -0700	[thread overview]
Message-ID: <m1vcku57i9.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20120418184936.GC4984-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org> (Serge E. Hallyn's message of "Wed, 18 Apr 2012 18:49:36 +0000")

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

> Quoting Eric W. Beiderman (ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org):
>> From: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
>> 
>> As a first step to converting struct cred to be all kuid_t and kgid_t
>> values convert the group values stored in group_info to always be
>> kgid_t values.   Unless user namespaces are used this change should
>> have no effect.
>> 
>> Signed-off-by: Eric W. Biederman <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
>> ---
>>  arch/s390/kernel/compat_linux.c   |   13 ++++++++-
>>  fs/nfsd/auth.c                    |    5 ++-
>>  fs/proc/array.c                   |    5 +++-
>>  include/linux/cred.h              |    9 ++++---
>>  kernel/groups.c                   |   48 +++++++++++++++++++-----------------
>>  kernel/uid16.c                    |   14 +++++++++-
>>  net/ipv4/ping.c                   |   11 ++++++--
>>  net/sunrpc/auth_generic.c         |    4 +-
>>  net/sunrpc/auth_gss/svcauth_gss.c |    7 ++++-
>>  net/sunrpc/auth_unix.c            |   15 ++++++++---
>>  net/sunrpc/svcauth_unix.c         |   18 ++++++++++---
>>  security/keys/permission.c        |    3 +-
>>  12 files changed, 103 insertions(+), 49 deletions(-)
>> 
>> diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
>> index ab64bdb..5baac18 100644
>> --- a/arch/s390/kernel/compat_linux.c
>> +++ b/arch/s390/kernel/compat_linux.c
>> @@ -173,11 +173,14 @@ asmlinkage long sys32_setfsgid16(u16 gid)
>>  
>>  static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info)
>>  {
>> +	struct user_namespace *user_ns = current_user_ns();
>>  	int i;
>>  	u16 group;
>> +	kgid_t kgid;
>>  
>>  	for (i = 0; i < group_info->ngroups; i++) {
>> -		group = (u16)GROUP_AT(group_info, i);
>> +		kgid = GROUP_AT(group_info, i);
>> +		group = (u16)from_kgid_munged(user_ns, kgid);
>>  		if (put_user(group, grouplist+i))
>>  			return -EFAULT;
>>  	}
>> @@ -187,13 +190,19 @@ static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info
>>  
>>  static int groups16_from_user(struct group_info *group_info, u16 __user *grouplist)
>>  {
>> +	struct user_namespace *user_ns = current_user_ns();
>>  	int i;
>>  	u16 group;
>
> need
>
> 	kgid_t kgid;
>
> here

Doh!  Thank you.

Now I am wondering why s390 has it's own copy of this function instead
of using the version in uid16.c.

>>  	for (i = 0; i < group_info->ngroups; i++) {
>>  		if (get_user(group, grouplist+i))
>>  			return  -EFAULT;
>> -		GROUP_AT(group_info, i) = (gid_t)group;
>> +
>> +		kgid = make_kgid(user_ns, (gid_t)group);
>> +		if (!gid_valid(kgid))
>> +			return -EINVAL;
>> +
>> +		GROUP_AT(group_info, i) = kgid;
>>  	}
>>  
>>  	return 0;

Eric

  parent reply	other threads:[~2012-04-20 23:05 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-08  5:10 [REVIEW][PATCH 0/43] Completing the user namespace Eric W. Biederman
     [not found] ` <m11unyn70b.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-04-08  5:14   ` [PATCH 01/43] vfs: Don't allow a user namespace root to make device nodes "Eric W. Beiderman
2012-04-08  5:14   ` [PATCH 02/43] userns: Kill bogus declaration of function release_uids "Eric W. Beiderman
2012-04-08  5:14   ` [PATCH 03/43] userns: Replace netlink uses of cap_raised with capable "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 04/43] userns: Remove unnecessary cast to struct user_struct when copying cred->user "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 05/43] cred: Add forward declaration of init_user_ns in all cases "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 06/43] userns: Use cred->user_ns instead of cred->user->user_ns "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 07/43] cred: Refcount the user_ns pointed to by the cred "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 08/43] userns: Add an explicit reference to the parent user namespace "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 09/43] mqueue: Explicitly capture the user namespace to send the notification to "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 10/43] userns: Deprecate and rename the user_namespace reference in the user_struct "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 11/43] userns: Start out with a full set of capabilities "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 12/43] userns: Replace the hard to write inode_userns with inode_capable "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 13/43] userns: Add kuid_t and kgid_t and associated infrastructure in uidgid.h "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 14/43] userns: Add a Kconfig option to enforce strict kuid and kgid type checks "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 15/43] userns: Disassociate user_struct from the user_namespace "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 16/43] userns: Simplify the user_namespace by making userns->creator a kuid "Eric W. Beiderman
     [not found]     ` <1333862139-31737-16-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:48       ` Serge E. Hallyn
     [not found]     ` <20120418184847.GA4984@mail.hallyn.com>
     [not found]       ` <20120418184847.GA4984-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-20 22:58         ` Eric W. Biederman
     [not found]       ` <m1aa266meh.fsf@fess.ebiederm.org>
     [not found]         ` <m1aa266meh.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-04-24 17:33           ` Serge E. Hallyn
     [not found]             ` <20120424173347.GA14017-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-24 19:41               ` Eric W. Biederman
     [not found]                 ` <m14ns8lxyc.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-04-24 20:23                   ` Serge E. Hallyn
     [not found]                     ` <20120424202301.GA11326-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-26  9:09                       ` Eric W. Biederman
     [not found]                     ` <m1ehradfl3.fsf@fess.ebiederm.org>
     [not found]                       ` <m1ehradfl3.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-04-26 16:21                         ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 17/43] userns: Rework the user_namespace adding uid/gid mapping support "Eric W. Beiderman
     [not found]     ` <1333862139-31737-17-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:49       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 18/43] userns: Convert group_info values from gid_t to kgid_t "Eric W. Beiderman
     [not found]     ` <1333862139-31737-18-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:49       ` Serge E. Hallyn
     [not found]     ` <20120418184936.GC4984@mail.hallyn.com>
     [not found]       ` <20120418184936.GC4984-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-20 23:05         ` Eric W. Biederman [this message]
2012-04-08  5:15   ` [PATCH 19/43] userns: Store uid and gid values in struct cred with kuid_t and kgid_t types "Eric W. Beiderman
     [not found]     ` <1333862139-31737-19-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:49       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 20/43] userns: Replace user_ns_map_uid and user_ns_map_gid with from_kuid and from_kgid "Eric W. Beiderman
     [not found]     ` <1333862139-31737-20-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:49       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 21/43] userns: Convert sched_set_affinity and sched_set_scheduler's permission checks "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 22/43] userns: Convert capabilities related permsion checks "Eric W. Beiderman
     [not found]     ` <1333862139-31737-22-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:51       ` Serge E. Hallyn
     [not found]     ` <20120418185106.GG4984@mail.hallyn.com>
     [not found]       ` <20120418185106.GG4984-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-20 23:18         ` Eric W. Biederman
2012-04-08  5:15   ` [PATCH 23/43] userns: Convert setting and getting uid and gid system calls to use kuid and kgid "Eric W. Beiderman
     [not found]     ` <1333862139-31737-23-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-26 16:20       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 24/43] userns: Convert ptrace, kill, set_priority permission checks to work with kuids and kgids "Eric W. Beiderman
     [not found]     ` <1333862139-31737-24-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:56       ` Serge E. Hallyn
     [not found]     ` <20120418185610.GA5186@mail.hallyn.com>
     [not found]       ` <20120418185610.GA5186-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-20 23:51         ` Eric W. Biederman
2012-04-08  5:15   ` [PATCH 25/43] userns: Store uid and gid types in vfs structures with kuid_t and kgid_t types "Eric W. Beiderman
     [not found]     ` <1333862139-31737-25-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:57       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 26/43] userns: Convert in_group_p and in_egroup_p to use kgid_t "Eric W. Beiderman
     [not found]     ` <1333862139-31737-26-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:58       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 28/43] userns: Convert user specfied uids and gids in chown into kuids and kgid "Eric W. Beiderman
     [not found]     ` <1333862139-31737-28-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 19:03       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 29/43] userns: Convert stat to return values mapped from kuids and kgids "Eric W. Beiderman
     [not found]     ` <1333862139-31737-29-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 19:03       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 30/43] userns: Fail exec for suid and sgid binaries with ids outside our user namespace "Eric W. Beiderman
     [not found]     ` <1333862139-31737-30-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 19:05       ` Serge E. Hallyn
2012-04-18 19:09       ` Serge E. Hallyn
     [not found]     ` <20120418190927.GK5186@mail.hallyn.com>
     [not found]       ` <20120418190927.GK5186-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-24  2:28         ` Eric W. Biederman
     [not found]           ` <m1ehrdrhgr.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-04-24 15:10             ` Serge Hallyn
2012-04-08  5:15   ` [PATCH 31/43] userns: Teach inode_capable to understand inodes whose uids map to other namespaces "Eric W. Beiderman
     [not found]     ` <1333862139-31737-31-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 19:06       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 32/43] userns: signal remove unnecessary map_cred_ns "Eric W. Beiderman
     [not found]     ` <1333862139-31737-32-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 19:07       ` Serge E. Hallyn
2012-04-08  5:15   ` [PATCH 33/43] userns: Convert binary formats to use kuid/kgid where appropriate "Eric W. Beiderman
     [not found]     ` <1333862139-31737-33-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 19:10       ` Serge E. Hallyn
     [not found]     ` <20120418191033.GL5186@mail.hallyn.com>
     [not found]       ` <20120418191033.GL5186-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-24  2:44         ` Eric W. Biederman
2012-04-08  5:15   ` [PATCH 34/43] userns: Convert devpts " "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 35/43] userns: Convert ext2 " "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 36/43] userns: Convert ext3 " "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 37/43] userns: Convert ext4 to user " "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 38/43] userns: Convert proc to use " "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 39/43] userns: Convert sysctl permission checks to use kuid and kgids "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 40/43] userns: Convert sysfs to use kgid/kuid where appropriate "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 41/43] userns: Convert tmpfs to use kuid and kgid " "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 42/43] userns: Convert cgroup permission checks to use uid_eq "Eric W. Beiderman
2012-04-08  5:15   ` [PATCH 43/43] userns: Convert the move_pages, and migrate_pages " "Eric W. Beiderman
2012-04-08 14:54   ` [REVIEW][PATCH 0/43] Completing the user namespace Serge Hallyn
2012-04-08 17:40   ` richard -rw- weinberger
2012-05-11 23:20   ` Please include user-namespace.git in linux-next Eric W. Biederman
     [not found]     ` <m1likyz4mh.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-05-13 23:35       ` Stephen Rothwell
     [not found] ` <CAFLxGvwyx6S6+eZtR=UNSQe_O+W7oZW=GosseL54HGpjtYGXjg@mail.gmail.com>
     [not found]   ` <CAFLxGvwyx6S6+eZtR=UNSQe_O+W7oZW=GosseL54HGpjtYGXjg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-08 21:30     ` [REVIEW][PATCH 0/43] Completing the user namespace Eric W. Biederman
     [not found]       ` <m1iph9ewsy.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-04-08 22:04         ` richard -rw- weinberger
     [not found]           ` <CAFLxGvwHtA028V2XudM-5HXmXCPw5ENL5E_nHKZh_gbrsRV69g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-04-08 22:52             ` Eric W. Biederman
     [not found] ` <1333862139-31737-21-git-send-email-ebiederm@xmission.com>
     [not found]   ` <1333862139-31737-21-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 18:50     ` [PATCH 21/43] userns: Convert sched_set_affinity and sched_set_scheduler's permission checks Serge E. Hallyn
     [not found] ` <1333862139-31737-27-git-send-email-ebiederm@xmission.com>
     [not found]   ` <1333862139-31737-27-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-04-18 19:02     ` [PATCH 27/43] userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs Serge E. Hallyn
     [not found]       ` <20120418190213.GD5186-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-21  0:05         ` Eric W. Biederman
2012-04-18 19:03     ` Serge E. Hallyn
     [not found]       ` <20120418190337.GE5186-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-21  0:58         ` Eric W. Biederman
     [not found]           ` <m1sjfx2950.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
2012-04-24 17:41             ` Serge E. Hallyn
2012-04-26  0:11             ` Serge E. Hallyn
     [not found]               ` <20120426001101.GA10308-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-04-26  5:33                 ` Eric W. Biederman

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=m1vcku57i9.fsf@fess.ebiederm.org \
    --to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=gorcunov-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org \
    --cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=serge-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org \
    --cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@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