aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-02-09 12:10:30 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-05-15 17:08:35 -0400
commita7c1938e22c02b008655524c766d185ae99d9d53 (patch)
treef6b862a5d187908007614e5537f4cd1e31a40df4 /fs
parent52137abe1820196d956bfd51edebc571b3427deb (diff)
userns: Convert stat to return values mapped from kuids and kgids
- Store uids and gids with kuid_t and kgid_t in struct kstat - Convert uid and gids to userspace usable values with from_kuid and from_kgid Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/compat.c4
-rw-r--r--fs/stat.c12
2 files changed, 8 insertions, 8 deletions
diff --git a/fs/compat.c b/fs/compat.c
index f2944ace7a7b..0781e619a62a 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -144,8 +144,8 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
144 tmp.st_nlink = stat->nlink; 144 tmp.st_nlink = stat->nlink;
145 if (tmp.st_nlink != stat->nlink) 145 if (tmp.st_nlink != stat->nlink)
146 return -EOVERFLOW; 146 return -EOVERFLOW;
147 SET_UID(tmp.st_uid, stat->uid); 147 SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid));
148 SET_GID(tmp.st_gid, stat->gid); 148 SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid));
149 tmp.st_rdev = old_encode_dev(stat->rdev); 149 tmp.st_rdev = old_encode_dev(stat->rdev);
150 if ((u64) stat->size > MAX_NON_LFS) 150 if ((u64) stat->size > MAX_NON_LFS)
151 return -EOVERFLOW; 151 return -EOVERFLOW;
diff --git a/fs/stat.c b/fs/stat.c
index c733dc5753ae..31acca5f5a0c 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -137,8 +137,8 @@ static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * sta
137 tmp.st_nlink = stat->nlink; 137 tmp.st_nlink = stat->nlink;
138 if (tmp.st_nlink != stat->nlink) 138 if (tmp.st_nlink != stat->nlink)
139 return -EOVERFLOW; 139 return -EOVERFLOW;
140 SET_UID(tmp.st_uid, stat->uid); 140 SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid));
141 SET_GID(tmp.st_gid, stat->gid); 141 SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid));
142 tmp.st_rdev = old_encode_dev(stat->rdev); 142 tmp.st_rdev = old_encode_dev(stat->rdev);
143#if BITS_PER_LONG == 32 143#if BITS_PER_LONG == 32
144 if (stat->size > MAX_NON_LFS) 144 if (stat->size > MAX_NON_LFS)
@@ -215,8 +215,8 @@ static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf)
215 tmp.st_nlink = stat->nlink; 215 tmp.st_nlink = stat->nlink;
216 if (tmp.st_nlink != stat->nlink) 216 if (tmp.st_nlink != stat->nlink)
217 return -EOVERFLOW; 217 return -EOVERFLOW;
218 SET_UID(tmp.st_uid, stat->uid); 218 SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid));
219 SET_GID(tmp.st_gid, stat->gid); 219 SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid));
220#if BITS_PER_LONG == 32 220#if BITS_PER_LONG == 32
221 tmp.st_rdev = old_encode_dev(stat->rdev); 221 tmp.st_rdev = old_encode_dev(stat->rdev);
222#else 222#else
@@ -350,8 +350,8 @@ static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf)
350#endif 350#endif
351 tmp.st_mode = stat->mode; 351 tmp.st_mode = stat->mode;
352 tmp.st_nlink = stat->nlink; 352 tmp.st_nlink = stat->nlink;
353 tmp.st_uid = stat->uid; 353 tmp.st_uid = from_kuid_munged(current_user_ns(), stat->uid);
354 tmp.st_gid = stat->gid; 354 tmp.st_gid = from_kgid_munged(current_user_ns(), stat->gid);
355 tmp.st_atime = stat->atime.tv_sec; 355 tmp.st_atime = stat->atime.tv_sec;
356 tmp.st_atime_nsec = stat->atime.tv_nsec; 356 tmp.st_atime_nsec = stat->atime.tv_nsec;
357 tmp.st_mtime = stat->mtime.tv_sec; 357 tmp.st_mtime = stat->mtime.tv_sec;