aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat.c
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2008-10-17 12:20:26 -0400
committerArjan van de Ven <arjan@linux.intel.com>2008-10-17 12:20:26 -0400
commit651dab4264e4ba0e563f5ff56f748127246e9065 (patch)
tree016630974bdcb00fe529b673f96d389e0fd6dc94 /fs/compat.c
parent40b8606253552109815786e5d4b0de98782d31f5 (diff)
parent2e532d68a2b3e2aa6b19731501222069735c741c (diff)
Merge commit 'linus/master' into merge-linus
Conflicts: arch/x86/kvm/i8254.c
Diffstat (limited to 'fs/compat.c')
-rw-r--r--fs/compat.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/fs/compat.c b/fs/compat.c
index 133ed7f5d681..3b58c32be526 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -137,6 +137,45 @@ asmlinkage long compat_sys_utimes(char __user *filename, struct compat_timeval _
137 return compat_sys_futimesat(AT_FDCWD, filename, t); 137 return compat_sys_futimesat(AT_FDCWD, filename, t);
138} 138}
139 139
140static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)
141{
142 compat_ino_t ino = stat->ino;
143 typeof(ubuf->st_uid) uid = 0;
144 typeof(ubuf->st_gid) gid = 0;
145 int err;
146
147 SET_UID(uid, stat->uid);
148 SET_GID(gid, stat->gid);
149
150 if ((u64) stat->size > MAX_NON_LFS ||
151 !old_valid_dev(stat->dev) ||
152 !old_valid_dev(stat->rdev))
153 return -EOVERFLOW;
154 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
155 return -EOVERFLOW;
156
157 if (clear_user(ubuf, sizeof(*ubuf)))
158 return -EFAULT;
159
160 err = __put_user(old_encode_dev(stat->dev), &ubuf->st_dev);
161 err |= __put_user(ino, &ubuf->st_ino);
162 err |= __put_user(stat->mode, &ubuf->st_mode);
163 err |= __put_user(stat->nlink, &ubuf->st_nlink);
164 err |= __put_user(uid, &ubuf->st_uid);
165 err |= __put_user(gid, &ubuf->st_gid);
166 err |= __put_user(old_encode_dev(stat->rdev), &ubuf->st_rdev);
167 err |= __put_user(stat->size, &ubuf->st_size);
168 err |= __put_user(stat->atime.tv_sec, &ubuf->st_atime);
169 err |= __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec);
170 err |= __put_user(stat->mtime.tv_sec, &ubuf->st_mtime);
171 err |= __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec);
172 err |= __put_user(stat->ctime.tv_sec, &ubuf->st_ctime);
173 err |= __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec);
174 err |= __put_user(stat->blksize, &ubuf->st_blksize);
175 err |= __put_user(stat->blocks, &ubuf->st_blocks);
176 return err;
177}
178
140asmlinkage long compat_sys_newstat(char __user * filename, 179asmlinkage long compat_sys_newstat(char __user * filename,
141 struct compat_stat __user *statbuf) 180 struct compat_stat __user *statbuf)
142{ 181{
@@ -1239,7 +1278,7 @@ static int compat_count(compat_uptr_t __user *argv, int max)
1239 if (!p) 1278 if (!p)
1240 break; 1279 break;
1241 argv++; 1280 argv++;
1242 if(++i > max) 1281 if (i++ >= max)
1243 return -E2BIG; 1282 return -E2BIG;
1244 } 1283 }
1245 } 1284 }