diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-03-04 04:52:01 +0100 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-05-03 12:29:34 +0200 |
commit | 52137abe1820196d956bfd51edebc571b3427deb (patch) | |
tree | 29a06b63fa36d6b794f7b848e4a65eea1fb74f0f | |
parent | userns: Use uid_eq gid_eq helpers when comparing kuids and kgids in the vfs (diff) | |
download | linux-52137abe1820196d956bfd51edebc571b3427deb.tar.xz linux-52137abe1820196d956bfd51edebc571b3427deb.zip |
userns: Convert user specfied uids and gids in chown into kuids and kgid
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r-- | fs/open.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/open.c b/fs/open.c index 92335f663545..e16680138323 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 |= |