From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Serge E. Hallyn" Subject: Re: [PATCH 28/43] userns: Convert user specfied uids and gids in chown into kuids and kgid Date: Wed, 18 Apr 2012 19:03:47 +0000 Message-ID: <20120418190347.GF5186@mail.hallyn.com> References: <1333862139-31737-28-git-send-email-ebiederm@xmission.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Linux Containers , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Al Viro , Cyrill Gorcunov , Andrew Morton , Linus Torvalds To: "Eric W. Beiderman" Return-path: Content-Disposition: inline In-Reply-To: <1333862139-31737-28-git-send-email-ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org Quoting Eric W. Beiderman (ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org): > From: Eric W. Biederman > > Signed-off-by: Eric W. Biederman Acked-by: Serge Hallyn > --- > fs/open.c | 13 +++++++++++-- > 1 files changed, 11 insertions(+), 2 deletions(-) > > diff --git a/fs/open.c b/fs/open.c > index 92335f6..e166801 100644 > --- a/fs/open.c > +++ b/fs/open.c > @@ -506,15 +506,24 @@ static int chown_common(struct path *path, uid_t user, gid_t group) > struct inode *inode = path->dentry->d_inode; > int error; > struct iattr newattrs; > + kuid_t uid; > + kgid_t gid; > + > + uid = make_kuid(current_user_ns(), user); > + gid = make_kgid(current_user_ns(), group); > > newattrs.ia_valid = ATTR_CTIME; > if (user != (uid_t) -1) { > + if (!uid_valid(uid)) > + return -EINVAL; > newattrs.ia_valid |= ATTR_UID; > - newattrs.ia_uid = user; > + newattrs.ia_uid = uid; > } > if (group != (gid_t) -1) { > + if (!gid_valid(gid)) > + return -EINVAL; > newattrs.ia_valid |= ATTR_GID; > - newattrs.ia_gid = group; > + newattrs.ia_gid = gid; > } > if (!S_ISDIR(inode->i_mode)) > newattrs.ia_valid |= > -- > 1.7.2.5 > > _______________________________________________ > Containers mailing list > Containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org > https://lists.linuxfoundation.org/mailman/listinfo/containers