diff options
Diffstat (limited to 'arch/x86/ia32')
-rw-r--r-- | arch/x86/ia32/sys_ia32.c | 498 |
1 files changed, 253 insertions, 245 deletions
diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c index bee96d614432..58991abc5b59 100644 --- a/arch/x86/ia32/sys_ia32.c +++ b/arch/x86/ia32/sys_ia32.c | |||
@@ -1,29 +1,29 @@ | |||
1 | /* | 1 | /* |
2 | * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on | 2 | * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on |
3 | * sys_sparc32 | 3 | * sys_sparc32 |
4 | * | 4 | * |
5 | * Copyright (C) 2000 VA Linux Co | 5 | * Copyright (C) 2000 VA Linux Co |
6 | * Copyright (C) 2000 Don Dugger <n0ano@valinux.com> | 6 | * Copyright (C) 2000 Don Dugger <n0ano@valinux.com> |
7 | * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com> | 7 | * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com> |
8 | * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) | 8 | * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
9 | * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) | 9 | * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu) |
10 | * Copyright (C) 2000 Hewlett-Packard Co. | 10 | * Copyright (C) 2000 Hewlett-Packard Co. |
11 | * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com> | 11 | * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com> |
12 | * Copyright (C) 2000,2001,2002 Andi Kleen, SuSE Labs (x86-64 port) | 12 | * Copyright (C) 2000,2001,2002 Andi Kleen, SuSE Labs (x86-64 port) |
13 | * | 13 | * |
14 | * These routines maintain argument size conversion between 32bit and 64bit | 14 | * These routines maintain argument size conversion between 32bit and 64bit |
15 | * environment. In 2.5 most of this should be moved to a generic directory. | 15 | * environment. In 2.5 most of this should be moved to a generic directory. |
16 | * | 16 | * |
17 | * This file assumes that there is a hole at the end of user address space. | 17 | * This file assumes that there is a hole at the end of user address space. |
18 | * | 18 | * |
19 | * Some of the functions are LE specific currently. These are hopefully all marked. | 19 | * Some of the functions are LE specific currently. These are |
20 | * This should be fixed. | 20 | * hopefully all marked. This should be fixed. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/kernel.h> | 23 | #include <linux/kernel.h> |
24 | #include <linux/sched.h> | 24 | #include <linux/sched.h> |
25 | #include <linux/fs.h> | 25 | #include <linux/fs.h> |
26 | #include <linux/file.h> | 26 | #include <linux/file.h> |
27 | #include <linux/signal.h> | 27 | #include <linux/signal.h> |
28 | #include <linux/syscalls.h> | 28 | #include <linux/syscalls.h> |
29 | #include <linux/resource.h> | 29 | #include <linux/resource.h> |
@@ -90,43 +90,44 @@ int cp_compat_stat(struct kstat *kbuf, struct compat_stat __user *ubuf) | |||
90 | if (sizeof(ino) < sizeof(kbuf->ino) && ino != kbuf->ino) | 90 | if (sizeof(ino) < sizeof(kbuf->ino) && ino != kbuf->ino) |
91 | return -EOVERFLOW; | 91 | return -EOVERFLOW; |
92 | if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) || | 92 | if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct compat_stat)) || |
93 | __put_user (old_encode_dev(kbuf->dev), &ubuf->st_dev) || | 93 | __put_user(old_encode_dev(kbuf->dev), &ubuf->st_dev) || |
94 | __put_user (ino, &ubuf->st_ino) || | 94 | __put_user(ino, &ubuf->st_ino) || |
95 | __put_user (kbuf->mode, &ubuf->st_mode) || | 95 | __put_user(kbuf->mode, &ubuf->st_mode) || |
96 | __put_user (kbuf->nlink, &ubuf->st_nlink) || | 96 | __put_user(kbuf->nlink, &ubuf->st_nlink) || |
97 | __put_user (uid, &ubuf->st_uid) || | 97 | __put_user(uid, &ubuf->st_uid) || |
98 | __put_user (gid, &ubuf->st_gid) || | 98 | __put_user(gid, &ubuf->st_gid) || |
99 | __put_user (old_encode_dev(kbuf->rdev), &ubuf->st_rdev) || | 99 | __put_user(old_encode_dev(kbuf->rdev), &ubuf->st_rdev) || |
100 | __put_user (kbuf->size, &ubuf->st_size) || | 100 | __put_user(kbuf->size, &ubuf->st_size) || |
101 | __put_user (kbuf->atime.tv_sec, &ubuf->st_atime) || | 101 | __put_user(kbuf->atime.tv_sec, &ubuf->st_atime) || |
102 | __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) || | 102 | __put_user(kbuf->atime.tv_nsec, &ubuf->st_atime_nsec) || |
103 | __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime) || | 103 | __put_user(kbuf->mtime.tv_sec, &ubuf->st_mtime) || |
104 | __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) || | 104 | __put_user(kbuf->mtime.tv_nsec, &ubuf->st_mtime_nsec) || |
105 | __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime) || | 105 | __put_user(kbuf->ctime.tv_sec, &ubuf->st_ctime) || |
106 | __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) || | 106 | __put_user(kbuf->ctime.tv_nsec, &ubuf->st_ctime_nsec) || |
107 | __put_user (kbuf->blksize, &ubuf->st_blksize) || | 107 | __put_user(kbuf->blksize, &ubuf->st_blksize) || |
108 | __put_user (kbuf->blocks, &ubuf->st_blocks)) | 108 | __put_user(kbuf->blocks, &ubuf->st_blocks)) |
109 | return -EFAULT; | 109 | return -EFAULT; |
110 | return 0; | 110 | return 0; |
111 | } | 111 | } |
112 | 112 | ||
113 | asmlinkage long | 113 | asmlinkage long sys32_truncate64(char __user *filename, |
114 | sys32_truncate64(char __user * filename, unsigned long offset_low, unsigned long offset_high) | 114 | unsigned long offset_low, |
115 | unsigned long offset_high) | ||
115 | { | 116 | { |
116 | return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low); | 117 | return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low); |
117 | } | 118 | } |
118 | 119 | ||
119 | asmlinkage long | 120 | asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low, |
120 | sys32_ftruncate64(unsigned int fd, unsigned long offset_low, unsigned long offset_high) | 121 | unsigned long offset_high) |
121 | { | 122 | { |
122 | return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low); | 123 | return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low); |
123 | } | 124 | } |
124 | 125 | ||
125 | /* Another set for IA32/LFS -- x86_64 struct stat is different due to | 126 | /* |
126 | support for 64bit inode numbers. */ | 127 | * Another set for IA32/LFS -- x86_64 struct stat is different due to |
127 | 128 | * support for 64bit inode numbers. | |
128 | static int | 129 | */ |
129 | cp_stat64(struct stat64 __user *ubuf, struct kstat *stat) | 130 | static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat) |
130 | { | 131 | { |
131 | typeof(ubuf->st_uid) uid = 0; | 132 | typeof(ubuf->st_uid) uid = 0; |
132 | typeof(ubuf->st_gid) gid = 0; | 133 | typeof(ubuf->st_gid) gid = 0; |
@@ -134,38 +135,39 @@ cp_stat64(struct stat64 __user *ubuf, struct kstat *stat) | |||
134 | SET_GID(gid, stat->gid); | 135 | SET_GID(gid, stat->gid); |
135 | if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) || | 136 | if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) || |
136 | __put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) || | 137 | __put_user(huge_encode_dev(stat->dev), &ubuf->st_dev) || |
137 | __put_user (stat->ino, &ubuf->__st_ino) || | 138 | __put_user(stat->ino, &ubuf->__st_ino) || |
138 | __put_user (stat->ino, &ubuf->st_ino) || | 139 | __put_user(stat->ino, &ubuf->st_ino) || |
139 | __put_user (stat->mode, &ubuf->st_mode) || | 140 | __put_user(stat->mode, &ubuf->st_mode) || |
140 | __put_user (stat->nlink, &ubuf->st_nlink) || | 141 | __put_user(stat->nlink, &ubuf->st_nlink) || |
141 | __put_user (uid, &ubuf->st_uid) || | 142 | __put_user(uid, &ubuf->st_uid) || |
142 | __put_user (gid, &ubuf->st_gid) || | 143 | __put_user(gid, &ubuf->st_gid) || |
143 | __put_user (huge_encode_dev(stat->rdev), &ubuf->st_rdev) || | 144 | __put_user(huge_encode_dev(stat->rdev), &ubuf->st_rdev) || |
144 | __put_user (stat->size, &ubuf->st_size) || | 145 | __put_user(stat->size, &ubuf->st_size) || |
145 | __put_user (stat->atime.tv_sec, &ubuf->st_atime) || | 146 | __put_user(stat->atime.tv_sec, &ubuf->st_atime) || |
146 | __put_user (stat->atime.tv_nsec, &ubuf->st_atime_nsec) || | 147 | __put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec) || |
147 | __put_user (stat->mtime.tv_sec, &ubuf->st_mtime) || | 148 | __put_user(stat->mtime.tv_sec, &ubuf->st_mtime) || |
148 | __put_user (stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) || | 149 | __put_user(stat->mtime.tv_nsec, &ubuf->st_mtime_nsec) || |
149 | __put_user (stat->ctime.tv_sec, &ubuf->st_ctime) || | 150 | __put_user(stat->ctime.tv_sec, &ubuf->st_ctime) || |
150 | __put_user (stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) || | 151 | __put_user(stat->ctime.tv_nsec, &ubuf->st_ctime_nsec) || |
151 | __put_user (stat->blksize, &ubuf->st_blksize) || | 152 | __put_user(stat->blksize, &ubuf->st_blksize) || |
152 | __put_user (stat->blocks, &ubuf->st_blocks)) | 153 | __put_user(stat->blocks, &ubuf->st_blocks)) |
153 | return -EFAULT; | 154 | return -EFAULT; |
154 | return 0; | 155 | return 0; |
155 | } | 156 | } |
156 | 157 | ||
157 | asmlinkage long | 158 | asmlinkage long sys32_stat64(char __user *filename, |
158 | sys32_stat64(char __user * filename, struct stat64 __user *statbuf) | 159 | struct stat64 __user *statbuf) |
159 | { | 160 | { |
160 | struct kstat stat; | 161 | struct kstat stat; |
161 | int ret = vfs_stat(filename, &stat); | 162 | int ret = vfs_stat(filename, &stat); |
163 | |||
162 | if (!ret) | 164 | if (!ret) |
163 | ret = cp_stat64(statbuf, &stat); | 165 | ret = cp_stat64(statbuf, &stat); |
164 | return ret; | 166 | return ret; |
165 | } | 167 | } |
166 | 168 | ||
167 | asmlinkage long | 169 | asmlinkage long sys32_lstat64(char __user *filename, |
168 | sys32_lstat64(char __user * filename, struct stat64 __user *statbuf) | 170 | struct stat64 __user *statbuf) |
169 | { | 171 | { |
170 | struct kstat stat; | 172 | struct kstat stat; |
171 | int ret = vfs_lstat(filename, &stat); | 173 | int ret = vfs_lstat(filename, &stat); |
@@ -174,8 +176,7 @@ sys32_lstat64(char __user * filename, struct stat64 __user *statbuf) | |||
174 | return ret; | 176 | return ret; |
175 | } | 177 | } |
176 | 178 | ||
177 | asmlinkage long | 179 | asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf) |
178 | sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf) | ||
179 | { | 180 | { |
180 | struct kstat stat; | 181 | struct kstat stat; |
181 | int ret = vfs_fstat(fd, &stat); | 182 | int ret = vfs_fstat(fd, &stat); |
@@ -184,9 +185,8 @@ sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf) | |||
184 | return ret; | 185 | return ret; |
185 | } | 186 | } |
186 | 187 | ||
187 | asmlinkage long | 188 | asmlinkage long sys32_fstatat(unsigned int dfd, char __user *filename, |
188 | sys32_fstatat(unsigned int dfd, char __user *filename, | 189 | struct stat64 __user *statbuf, int flag) |
189 | struct stat64 __user* statbuf, int flag) | ||
190 | { | 190 | { |
191 | struct kstat stat; | 191 | struct kstat stat; |
192 | int error = -EINVAL; | 192 | int error = -EINVAL; |
@@ -221,8 +221,7 @@ struct mmap_arg_struct { | |||
221 | unsigned int offset; | 221 | unsigned int offset; |
222 | }; | 222 | }; |
223 | 223 | ||
224 | asmlinkage long | 224 | asmlinkage long sys32_mmap(struct mmap_arg_struct __user *arg) |
225 | sys32_mmap(struct mmap_arg_struct __user *arg) | ||
226 | { | 225 | { |
227 | struct mmap_arg_struct a; | 226 | struct mmap_arg_struct a; |
228 | struct file *file = NULL; | 227 | struct file *file = NULL; |
@@ -233,33 +232,33 @@ sys32_mmap(struct mmap_arg_struct __user *arg) | |||
233 | return -EFAULT; | 232 | return -EFAULT; |
234 | 233 | ||
235 | if (a.offset & ~PAGE_MASK) | 234 | if (a.offset & ~PAGE_MASK) |
236 | return -EINVAL; | 235 | return -EINVAL; |
237 | 236 | ||
238 | if (!(a.flags & MAP_ANONYMOUS)) { | 237 | if (!(a.flags & MAP_ANONYMOUS)) { |
239 | file = fget(a.fd); | 238 | file = fget(a.fd); |
240 | if (!file) | 239 | if (!file) |
241 | return -EBADF; | 240 | return -EBADF; |
242 | } | 241 | } |
243 | 242 | ||
244 | mm = current->mm; | 243 | mm = current->mm; |
245 | down_write(&mm->mmap_sem); | 244 | down_write(&mm->mmap_sem); |
246 | retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, a.offset>>PAGE_SHIFT); | 245 | retval = do_mmap_pgoff(file, a.addr, a.len, a.prot, a.flags, |
246 | a.offset>>PAGE_SHIFT); | ||
247 | if (file) | 247 | if (file) |
248 | fput(file); | 248 | fput(file); |
249 | 249 | ||
250 | up_write(&mm->mmap_sem); | 250 | up_write(&mm->mmap_sem); |
251 | 251 | ||
252 | return retval; | 252 | return retval; |
253 | } | 253 | } |
254 | 254 | ||
255 | asmlinkage long | 255 | asmlinkage long sys32_mprotect(unsigned long start, size_t len, |
256 | sys32_mprotect(unsigned long start, size_t len, unsigned long prot) | 256 | unsigned long prot) |
257 | { | 257 | { |
258 | return sys_mprotect(start,len,prot); | 258 | return sys_mprotect(start, len, prot); |
259 | } | 259 | } |
260 | 260 | ||
261 | asmlinkage long | 261 | asmlinkage long sys32_pipe(int __user *fd) |
262 | sys32_pipe(int __user *fd) | ||
263 | { | 262 | { |
264 | int retval; | 263 | int retval; |
265 | int fds[2]; | 264 | int fds[2]; |
@@ -269,13 +268,13 @@ sys32_pipe(int __user *fd) | |||
269 | goto out; | 268 | goto out; |
270 | if (copy_to_user(fd, fds, sizeof(fds))) | 269 | if (copy_to_user(fd, fds, sizeof(fds))) |
271 | retval = -EFAULT; | 270 | retval = -EFAULT; |
272 | out: | 271 | out: |
273 | return retval; | 272 | return retval; |
274 | } | 273 | } |
275 | 274 | ||
276 | asmlinkage long | 275 | asmlinkage long sys32_rt_sigaction(int sig, struct sigaction32 __user *act, |
277 | sys32_rt_sigaction(int sig, struct sigaction32 __user *act, | 276 | struct sigaction32 __user *oact, |
278 | struct sigaction32 __user *oact, unsigned int sigsetsize) | 277 | unsigned int sigsetsize) |
279 | { | 278 | { |
280 | struct k_sigaction new_ka, old_ka; | 279 | struct k_sigaction new_ka, old_ka; |
281 | int ret; | 280 | int ret; |
@@ -291,12 +290,17 @@ sys32_rt_sigaction(int sig, struct sigaction32 __user *act, | |||
291 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || | 290 | if (!access_ok(VERIFY_READ, act, sizeof(*act)) || |
292 | __get_user(handler, &act->sa_handler) || | 291 | __get_user(handler, &act->sa_handler) || |
293 | __get_user(new_ka.sa.sa_flags, &act->sa_flags) || | 292 | __get_user(new_ka.sa.sa_flags, &act->sa_flags) || |
294 | __get_user(restorer, &act->sa_restorer)|| | 293 | __get_user(restorer, &act->sa_restorer) || |
295 | __copy_from_user(&set32, &act->sa_mask, sizeof(compat_sigset_t))) | 294 | __copy_from_user(&set32, &act->sa_mask, |
295 | sizeof(compat_sigset_t))) | ||
296 | return -EFAULT; | 296 | return -EFAULT; |
297 | new_ka.sa.sa_handler = compat_ptr(handler); | 297 | new_ka.sa.sa_handler = compat_ptr(handler); |
298 | new_ka.sa.sa_restorer = compat_ptr(restorer); | 298 | new_ka.sa.sa_restorer = compat_ptr(restorer); |
299 | /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */ | 299 | |
300 | /* | ||
301 | * FIXME: here we rely on _COMPAT_NSIG_WORS to be >= | ||
302 | * than _NSIG_WORDS << 1 | ||
303 | */ | ||
300 | switch (_NSIG_WORDS) { | 304 | switch (_NSIG_WORDS) { |
301 | case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6] | 305 | case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6] |
302 | | (((long)set32.sig[7]) << 32); | 306 | | (((long)set32.sig[7]) << 32); |
@@ -312,7 +316,10 @@ sys32_rt_sigaction(int sig, struct sigaction32 __user *act, | |||
312 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); | 316 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
313 | 317 | ||
314 | if (!ret && oact) { | 318 | if (!ret && oact) { |
315 | /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */ | 319 | /* |
320 | * FIXME: here we rely on _COMPAT_NSIG_WORS to be >= | ||
321 | * than _NSIG_WORDS << 1 | ||
322 | */ | ||
316 | switch (_NSIG_WORDS) { | 323 | switch (_NSIG_WORDS) { |
317 | case 4: | 324 | case 4: |
318 | set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32); | 325 | set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32); |
@@ -328,23 +335,26 @@ sys32_rt_sigaction(int sig, struct sigaction32 __user *act, | |||
328 | set32.sig[0] = old_ka.sa.sa_mask.sig[0]; | 335 | set32.sig[0] = old_ka.sa.sa_mask.sig[0]; |
329 | } | 336 | } |
330 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || | 337 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || |
331 | __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) || | 338 | __put_user(ptr_to_compat(old_ka.sa.sa_handler), |
332 | __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) || | 339 | &oact->sa_handler) || |
340 | __put_user(ptr_to_compat(old_ka.sa.sa_restorer), | ||
341 | &oact->sa_restorer) || | ||
333 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || | 342 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || |
334 | __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t))) | 343 | __copy_to_user(&oact->sa_mask, &set32, |
344 | sizeof(compat_sigset_t))) | ||
335 | return -EFAULT; | 345 | return -EFAULT; |
336 | } | 346 | } |
337 | 347 | ||
338 | return ret; | 348 | return ret; |
339 | } | 349 | } |
340 | 350 | ||
341 | asmlinkage long | 351 | asmlinkage long sys32_sigaction(int sig, struct old_sigaction32 __user *act, |
342 | sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact) | 352 | struct old_sigaction32 __user *oact) |
343 | { | 353 | { |
344 | struct k_sigaction new_ka, old_ka; | 354 | struct k_sigaction new_ka, old_ka; |
345 | int ret; | 355 | int ret; |
346 | 356 | ||
347 | if (act) { | 357 | if (act) { |
348 | compat_old_sigset_t mask; | 358 | compat_old_sigset_t mask; |
349 | compat_uptr_t handler, restorer; | 359 | compat_uptr_t handler, restorer; |
350 | 360 | ||
@@ -359,33 +369,35 @@ sys32_sigaction (int sig, struct old_sigaction32 __user *act, struct old_sigacti | |||
359 | new_ka.sa.sa_restorer = compat_ptr(restorer); | 369 | new_ka.sa.sa_restorer = compat_ptr(restorer); |
360 | 370 | ||
361 | siginitset(&new_ka.sa.sa_mask, mask); | 371 | siginitset(&new_ka.sa.sa_mask, mask); |
362 | } | 372 | } |
363 | 373 | ||
364 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); | 374 | ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL); |
365 | 375 | ||
366 | if (!ret && oact) { | 376 | if (!ret && oact) { |
367 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || | 377 | if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || |
368 | __put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler) || | 378 | __put_user(ptr_to_compat(old_ka.sa.sa_handler), |
369 | __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer) || | 379 | &oact->sa_handler) || |
380 | __put_user(ptr_to_compat(old_ka.sa.sa_restorer), | ||
381 | &oact->sa_restorer) || | ||
370 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || | 382 | __put_user(old_ka.sa.sa_flags, &oact->sa_flags) || |
371 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) | 383 | __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask)) |
372 | return -EFAULT; | 384 | return -EFAULT; |
373 | } | 385 | } |
374 | 386 | ||
375 | return ret; | 387 | return ret; |
376 | } | 388 | } |
377 | 389 | ||
378 | asmlinkage long | 390 | asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, |
379 | sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, | 391 | compat_sigset_t __user *oset, |
380 | compat_sigset_t __user *oset, unsigned int sigsetsize) | 392 | unsigned int sigsetsize) |
381 | { | 393 | { |
382 | sigset_t s; | 394 | sigset_t s; |
383 | compat_sigset_t s32; | 395 | compat_sigset_t s32; |
384 | int ret; | 396 | int ret; |
385 | mm_segment_t old_fs = get_fs(); | 397 | mm_segment_t old_fs = get_fs(); |
386 | 398 | ||
387 | if (set) { | 399 | if (set) { |
388 | if (copy_from_user (&s32, set, sizeof(compat_sigset_t))) | 400 | if (copy_from_user(&s32, set, sizeof(compat_sigset_t))) |
389 | return -EFAULT; | 401 | return -EFAULT; |
390 | switch (_NSIG_WORDS) { | 402 | switch (_NSIG_WORDS) { |
391 | case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32); | 403 | case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32); |
@@ -394,13 +406,14 @@ sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, | |||
394 | case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32); | 406 | case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32); |
395 | } | 407 | } |
396 | } | 408 | } |
397 | set_fs (KERNEL_DS); | 409 | set_fs(KERNEL_DS); |
398 | ret = sys_rt_sigprocmask(how, | 410 | ret = sys_rt_sigprocmask(how, |
399 | set ? (sigset_t __user *)&s : NULL, | 411 | set ? (sigset_t __user *)&s : NULL, |
400 | oset ? (sigset_t __user *)&s : NULL, | 412 | oset ? (sigset_t __user *)&s : NULL, |
401 | sigsetsize); | 413 | sigsetsize); |
402 | set_fs (old_fs); | 414 | set_fs(old_fs); |
403 | if (ret) return ret; | 415 | if (ret) |
416 | return ret; | ||
404 | if (oset) { | 417 | if (oset) { |
405 | switch (_NSIG_WORDS) { | 418 | switch (_NSIG_WORDS) { |
406 | case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3]; | 419 | case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3]; |
@@ -408,52 +421,49 @@ sys32_rt_sigprocmask(int how, compat_sigset_t __user *set, | |||
408 | case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1]; | 421 | case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1]; |
409 | case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0]; | 422 | case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0]; |
410 | } | 423 | } |
411 | if (copy_to_user (oset, &s32, sizeof(compat_sigset_t))) | 424 | if (copy_to_user(oset, &s32, sizeof(compat_sigset_t))) |
412 | return -EFAULT; | 425 | return -EFAULT; |
413 | } | 426 | } |
414 | return 0; | 427 | return 0; |
415 | } | 428 | } |
416 | 429 | ||
417 | static inline long | 430 | static inline long get_tv32(struct timeval *o, struct compat_timeval __user *i) |
418 | get_tv32(struct timeval *o, struct compat_timeval __user *i) | ||
419 | { | 431 | { |
420 | int err = -EFAULT; | 432 | int err = -EFAULT; |
421 | if (access_ok(VERIFY_READ, i, sizeof(*i))) { | 433 | |
434 | if (access_ok(VERIFY_READ, i, sizeof(*i))) { | ||
422 | err = __get_user(o->tv_sec, &i->tv_sec); | 435 | err = __get_user(o->tv_sec, &i->tv_sec); |
423 | err |= __get_user(o->tv_usec, &i->tv_usec); | 436 | err |= __get_user(o->tv_usec, &i->tv_usec); |
424 | } | 437 | } |
425 | return err; | 438 | return err; |
426 | } | 439 | } |
427 | 440 | ||
428 | static inline long | 441 | static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i) |
429 | put_tv32(struct compat_timeval __user *o, struct timeval *i) | ||
430 | { | 442 | { |
431 | int err = -EFAULT; | 443 | int err = -EFAULT; |
432 | if (access_ok(VERIFY_WRITE, o, sizeof(*o))) { | 444 | |
445 | if (access_ok(VERIFY_WRITE, o, sizeof(*o))) { | ||
433 | err = __put_user(i->tv_sec, &o->tv_sec); | 446 | err = __put_user(i->tv_sec, &o->tv_sec); |
434 | err |= __put_user(i->tv_usec, &o->tv_usec); | 447 | err |= __put_user(i->tv_usec, &o->tv_usec); |
435 | } | 448 | } |
436 | return err; | 449 | return err; |
437 | } | 450 | } |
438 | 451 | ||
439 | extern unsigned int alarm_setitimer(unsigned int seconds); | 452 | asmlinkage long sys32_alarm(unsigned int seconds) |
440 | |||
441 | asmlinkage long | ||
442 | sys32_alarm(unsigned int seconds) | ||
443 | { | 453 | { |
444 | return alarm_setitimer(seconds); | 454 | return alarm_setitimer(seconds); |
445 | } | 455 | } |
446 | 456 | ||
447 | /* Translations due to time_t size differences. Which affects all | 457 | /* |
448 | sorts of things, like timeval and itimerval. */ | 458 | * Translations due to time_t size differences. Which affects all |
449 | 459 | * sorts of things, like timeval and itimerval. | |
450 | extern struct timezone sys_tz; | 460 | */ |
451 | 461 | asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv, | |
452 | asmlinkage long | 462 | struct timezone __user *tz) |
453 | sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz) | ||
454 | { | 463 | { |
455 | if (tv) { | 464 | if (tv) { |
456 | struct timeval ktv; | 465 | struct timeval ktv; |
466 | |||
457 | do_gettimeofday(&ktv); | 467 | do_gettimeofday(&ktv); |
458 | if (put_tv32(tv, &ktv)) | 468 | if (put_tv32(tv, &ktv)) |
459 | return -EFAULT; | 469 | return -EFAULT; |
@@ -465,14 +475,14 @@ sys32_gettimeofday(struct compat_timeval __user *tv, struct timezone __user *tz) | |||
465 | return 0; | 475 | return 0; |
466 | } | 476 | } |
467 | 477 | ||
468 | asmlinkage long | 478 | asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv, |
469 | sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user *tz) | 479 | struct timezone __user *tz) |
470 | { | 480 | { |
471 | struct timeval ktv; | 481 | struct timeval ktv; |
472 | struct timespec kts; | 482 | struct timespec kts; |
473 | struct timezone ktz; | 483 | struct timezone ktz; |
474 | 484 | ||
475 | if (tv) { | 485 | if (tv) { |
476 | if (get_tv32(&ktv, tv)) | 486 | if (get_tv32(&ktv, tv)) |
477 | return -EFAULT; | 487 | return -EFAULT; |
478 | kts.tv_sec = ktv.tv_sec; | 488 | kts.tv_sec = ktv.tv_sec; |
@@ -494,8 +504,7 @@ struct sel_arg_struct { | |||
494 | unsigned int tvp; | 504 | unsigned int tvp; |
495 | }; | 505 | }; |
496 | 506 | ||
497 | asmlinkage long | 507 | asmlinkage long sys32_old_select(struct sel_arg_struct __user *arg) |
498 | sys32_old_select(struct sel_arg_struct __user *arg) | ||
499 | { | 508 | { |
500 | struct sel_arg_struct a; | 509 | struct sel_arg_struct a; |
501 | 510 | ||
@@ -505,50 +514,45 @@ sys32_old_select(struct sel_arg_struct __user *arg) | |||
505 | compat_ptr(a.exp), compat_ptr(a.tvp)); | 514 | compat_ptr(a.exp), compat_ptr(a.tvp)); |
506 | } | 515 | } |
507 | 516 | ||
508 | extern asmlinkage long | 517 | asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, |
509 | compat_sys_wait4(compat_pid_t pid, compat_uint_t * stat_addr, int options, | 518 | int options) |
510 | struct compat_rusage *ru); | ||
511 | |||
512 | asmlinkage long | ||
513 | sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr, int options) | ||
514 | { | 519 | { |
515 | return compat_sys_wait4(pid, stat_addr, options, NULL); | 520 | return compat_sys_wait4(pid, stat_addr, options, NULL); |
516 | } | 521 | } |
517 | 522 | ||
518 | /* 32-bit timeval and related flotsam. */ | 523 | /* 32-bit timeval and related flotsam. */ |
519 | 524 | ||
520 | asmlinkage long | 525 | asmlinkage long sys32_sysfs(int option, u32 arg1, u32 arg2) |
521 | sys32_sysfs(int option, u32 arg1, u32 arg2) | ||
522 | { | 526 | { |
523 | return sys_sysfs(option, arg1, arg2); | 527 | return sys_sysfs(option, arg1, arg2); |
524 | } | 528 | } |
525 | 529 | ||
526 | asmlinkage long | 530 | asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid, |
527 | sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval) | 531 | struct compat_timespec __user *interval) |
528 | { | 532 | { |
529 | struct timespec t; | 533 | struct timespec t; |
530 | int ret; | 534 | int ret; |
531 | mm_segment_t old_fs = get_fs (); | 535 | mm_segment_t old_fs = get_fs(); |
532 | 536 | ||
533 | set_fs (KERNEL_DS); | 537 | set_fs(KERNEL_DS); |
534 | ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t); | 538 | ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t); |
535 | set_fs (old_fs); | 539 | set_fs(old_fs); |
536 | if (put_compat_timespec(&t, interval)) | 540 | if (put_compat_timespec(&t, interval)) |
537 | return -EFAULT; | 541 | return -EFAULT; |
538 | return ret; | 542 | return ret; |
539 | } | 543 | } |
540 | 544 | ||
541 | asmlinkage long | 545 | asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set, |
542 | sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize) | 546 | compat_size_t sigsetsize) |
543 | { | 547 | { |
544 | sigset_t s; | 548 | sigset_t s; |
545 | compat_sigset_t s32; | 549 | compat_sigset_t s32; |
546 | int ret; | 550 | int ret; |
547 | mm_segment_t old_fs = get_fs(); | 551 | mm_segment_t old_fs = get_fs(); |
548 | 552 | ||
549 | set_fs (KERNEL_DS); | 553 | set_fs(KERNEL_DS); |
550 | ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize); | 554 | ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize); |
551 | set_fs (old_fs); | 555 | set_fs(old_fs); |
552 | if (!ret) { | 556 | if (!ret) { |
553 | switch (_NSIG_WORDS) { | 557 | switch (_NSIG_WORDS) { |
554 | case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3]; | 558 | case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3]; |
@@ -556,30 +560,29 @@ sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize) | |||
556 | case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1]; | 560 | case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1]; |
557 | case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0]; | 561 | case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0]; |
558 | } | 562 | } |
559 | if (copy_to_user (set, &s32, sizeof(compat_sigset_t))) | 563 | if (copy_to_user(set, &s32, sizeof(compat_sigset_t))) |
560 | return -EFAULT; | 564 | return -EFAULT; |
561 | } | 565 | } |
562 | return ret; | 566 | return ret; |
563 | } | 567 | } |
564 | 568 | ||
565 | asmlinkage long | 569 | asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig, |
566 | sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo) | 570 | compat_siginfo_t __user *uinfo) |
567 | { | 571 | { |
568 | siginfo_t info; | 572 | siginfo_t info; |
569 | int ret; | 573 | int ret; |
570 | mm_segment_t old_fs = get_fs(); | 574 | mm_segment_t old_fs = get_fs(); |
571 | 575 | ||
572 | if (copy_siginfo_from_user32(&info, uinfo)) | 576 | if (copy_siginfo_from_user32(&info, uinfo)) |
573 | return -EFAULT; | 577 | return -EFAULT; |
574 | set_fs (KERNEL_DS); | 578 | set_fs(KERNEL_DS); |
575 | ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info); | 579 | ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info); |
576 | set_fs (old_fs); | 580 | set_fs(old_fs); |
577 | return ret; | 581 | return ret; |
578 | } | 582 | } |
579 | 583 | ||
580 | /* These are here just in case some old ia32 binary calls it. */ | 584 | /* These are here just in case some old ia32 binary calls it. */ |
581 | asmlinkage long | 585 | asmlinkage long sys32_pause(void) |
582 | sys32_pause(void) | ||
583 | { | 586 | { |
584 | current->state = TASK_INTERRUPTIBLE; | 587 | current->state = TASK_INTERRUPTIBLE; |
585 | schedule(); | 588 | schedule(); |
@@ -599,25 +602,25 @@ struct sysctl_ia32 { | |||
599 | }; | 602 | }; |
600 | 603 | ||
601 | 604 | ||
602 | asmlinkage long | 605 | asmlinkage long sys32_sysctl(struct sysctl_ia32 __user *args32) |
603 | sys32_sysctl(struct sysctl_ia32 __user *args32) | ||
604 | { | 606 | { |
605 | struct sysctl_ia32 a32; | 607 | struct sysctl_ia32 a32; |
606 | mm_segment_t old_fs = get_fs (); | 608 | mm_segment_t old_fs = get_fs(); |
607 | void __user *oldvalp, *newvalp; | 609 | void __user *oldvalp, *newvalp; |
608 | size_t oldlen; | 610 | size_t oldlen; |
609 | int __user *namep; | 611 | int __user *namep; |
610 | long ret; | 612 | long ret; |
611 | 613 | ||
612 | if (copy_from_user(&a32, args32, sizeof (a32))) | 614 | if (copy_from_user(&a32, args32, sizeof(a32))) |
613 | return -EFAULT; | 615 | return -EFAULT; |
614 | 616 | ||
615 | /* | 617 | /* |
616 | * We need to pre-validate these because we have to disable address checking | 618 | * We need to pre-validate these because we have to disable |
617 | * before calling do_sysctl() because of OLDLEN but we can't run the risk of the | 619 | * address checking before calling do_sysctl() because of |
618 | * user specifying bad addresses here. Well, since we're dealing with 32 bit | 620 | * OLDLEN but we can't run the risk of the user specifying bad |
619 | * addresses, we KNOW that access_ok() will always succeed, so this is an | 621 | * addresses here. Well, since we're dealing with 32 bit |
620 | * expensive NOP, but so what... | 622 | * addresses, we KNOW that access_ok() will always succeed, so |
623 | * this is an expensive NOP, but so what... | ||
621 | */ | 624 | */ |
622 | namep = compat_ptr(a32.name); | 625 | namep = compat_ptr(a32.name); |
623 | oldvalp = compat_ptr(a32.oldval); | 626 | oldvalp = compat_ptr(a32.oldval); |
@@ -636,34 +639,34 @@ sys32_sysctl(struct sysctl_ia32 __user *args32) | |||
636 | unlock_kernel(); | 639 | unlock_kernel(); |
637 | set_fs(old_fs); | 640 | set_fs(old_fs); |
638 | 641 | ||
639 | if (oldvalp && put_user (oldlen, (int __user *)compat_ptr(a32.oldlenp))) | 642 | if (oldvalp && put_user(oldlen, (int __user *)compat_ptr(a32.oldlenp))) |
640 | return -EFAULT; | 643 | return -EFAULT; |
641 | 644 | ||
642 | return ret; | 645 | return ret; |
643 | } | 646 | } |
644 | #endif | 647 | #endif |
645 | 648 | ||
646 | /* warning: next two assume little endian */ | 649 | /* warning: next two assume little endian */ |
647 | asmlinkage long | 650 | asmlinkage long sys32_pread(unsigned int fd, char __user *ubuf, u32 count, |
648 | sys32_pread(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi) | 651 | u32 poslo, u32 poshi) |
649 | { | 652 | { |
650 | return sys_pread64(fd, ubuf, count, | 653 | return sys_pread64(fd, ubuf, count, |
651 | ((loff_t)AA(poshi) << 32) | AA(poslo)); | 654 | ((loff_t)AA(poshi) << 32) | AA(poslo)); |
652 | } | 655 | } |
653 | 656 | ||
654 | asmlinkage long | 657 | asmlinkage long sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count, |
655 | sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count, u32 poslo, u32 poshi) | 658 | u32 poslo, u32 poshi) |
656 | { | 659 | { |
657 | return sys_pwrite64(fd, ubuf, count, | 660 | return sys_pwrite64(fd, ubuf, count, |
658 | ((loff_t)AA(poshi) << 32) | AA(poslo)); | 661 | ((loff_t)AA(poshi) << 32) | AA(poslo)); |
659 | } | 662 | } |
660 | 663 | ||
661 | 664 | ||
662 | asmlinkage long | 665 | asmlinkage long sys32_personality(unsigned long personality) |
663 | sys32_personality(unsigned long personality) | ||
664 | { | 666 | { |
665 | int ret; | 667 | int ret; |
666 | if (personality(current->personality) == PER_LINUX32 && | 668 | |
669 | if (personality(current->personality) == PER_LINUX32 && | ||
667 | personality == PER_LINUX) | 670 | personality == PER_LINUX) |
668 | personality = PER_LINUX32; | 671 | personality = PER_LINUX32; |
669 | ret = sys_personality(personality); | 672 | ret = sys_personality(personality); |
@@ -672,34 +675,33 @@ sys32_personality(unsigned long personality) | |||
672 | return ret; | 675 | return ret; |
673 | } | 676 | } |
674 | 677 | ||
675 | asmlinkage long | 678 | asmlinkage long sys32_sendfile(int out_fd, int in_fd, |
676 | sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count) | 679 | compat_off_t __user *offset, s32 count) |
677 | { | 680 | { |
678 | mm_segment_t old_fs = get_fs(); | 681 | mm_segment_t old_fs = get_fs(); |
679 | int ret; | 682 | int ret; |
680 | off_t of; | 683 | off_t of; |
681 | 684 | ||
682 | if (offset && get_user(of, offset)) | 685 | if (offset && get_user(of, offset)) |
683 | return -EFAULT; | 686 | return -EFAULT; |
684 | 687 | ||
685 | set_fs(KERNEL_DS); | 688 | set_fs(KERNEL_DS); |
686 | ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, | 689 | ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL, |
687 | count); | 690 | count); |
688 | set_fs(old_fs); | 691 | set_fs(old_fs); |
689 | 692 | ||
690 | if (offset && put_user(of, offset)) | 693 | if (offset && put_user(of, offset)) |
691 | return -EFAULT; | 694 | return -EFAULT; |
692 | |||
693 | return ret; | 695 | return ret; |
694 | } | 696 | } |
695 | 697 | ||
696 | asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len, | 698 | asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len, |
697 | unsigned long prot, unsigned long flags, | 699 | unsigned long prot, unsigned long flags, |
698 | unsigned long fd, unsigned long pgoff) | 700 | unsigned long fd, unsigned long pgoff) |
699 | { | 701 | { |
700 | struct mm_struct *mm = current->mm; | 702 | struct mm_struct *mm = current->mm; |
701 | unsigned long error; | 703 | unsigned long error; |
702 | struct file * file = NULL; | 704 | struct file *file = NULL; |
703 | 705 | ||
704 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); | 706 | flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); |
705 | if (!(flags & MAP_ANONYMOUS)) { | 707 | if (!(flags & MAP_ANONYMOUS)) { |
@@ -717,36 +719,35 @@ asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len, | |||
717 | return error; | 719 | return error; |
718 | } | 720 | } |
719 | 721 | ||
720 | asmlinkage long sys32_olduname(struct oldold_utsname __user * name) | 722 | asmlinkage long sys32_olduname(struct oldold_utsname __user *name) |
721 | { | 723 | { |
724 | char *arch = "x86_64"; | ||
722 | int err; | 725 | int err; |
723 | 726 | ||
724 | if (!name) | 727 | if (!name) |
725 | return -EFAULT; | 728 | return -EFAULT; |
726 | if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname))) | 729 | if (!access_ok(VERIFY_WRITE, name, sizeof(struct oldold_utsname))) |
727 | return -EFAULT; | 730 | return -EFAULT; |
728 | 731 | ||
729 | down_read(&uts_sem); | 732 | down_read(&uts_sem); |
730 | 733 | ||
731 | err = __copy_to_user(&name->sysname,&utsname()->sysname, | 734 | err = __copy_to_user(&name->sysname, &utsname()->sysname, |
732 | __OLD_UTS_LEN); | 735 | __OLD_UTS_LEN); |
733 | err |= __put_user(0,name->sysname+__OLD_UTS_LEN); | 736 | err |= __put_user(0, name->sysname+__OLD_UTS_LEN); |
734 | err |= __copy_to_user(&name->nodename,&utsname()->nodename, | 737 | err |= __copy_to_user(&name->nodename, &utsname()->nodename, |
735 | __OLD_UTS_LEN); | 738 | __OLD_UTS_LEN); |
736 | err |= __put_user(0,name->nodename+__OLD_UTS_LEN); | 739 | err |= __put_user(0, name->nodename+__OLD_UTS_LEN); |
737 | err |= __copy_to_user(&name->release,&utsname()->release, | 740 | err |= __copy_to_user(&name->release, &utsname()->release, |
738 | __OLD_UTS_LEN); | 741 | __OLD_UTS_LEN); |
739 | err |= __put_user(0,name->release+__OLD_UTS_LEN); | 742 | err |= __put_user(0, name->release+__OLD_UTS_LEN); |
740 | err |= __copy_to_user(&name->version,&utsname()->version, | 743 | err |= __copy_to_user(&name->version, &utsname()->version, |
741 | __OLD_UTS_LEN); | 744 | __OLD_UTS_LEN); |
742 | err |= __put_user(0,name->version+__OLD_UTS_LEN); | 745 | err |= __put_user(0, name->version+__OLD_UTS_LEN); |
743 | { | 746 | |
744 | char *arch = "x86_64"; | 747 | if (personality(current->personality) == PER_LINUX32) |
745 | if (personality(current->personality) == PER_LINUX32) | 748 | arch = "i686"; |
746 | arch = "i686"; | 749 | |
747 | 750 | err |= __copy_to_user(&name->machine, arch, strlen(arch) + 1); | |
748 | err |= __copy_to_user(&name->machine, arch, strlen(arch)+1); | ||
749 | } | ||
750 | 751 | ||
751 | up_read(&uts_sem); | 752 | up_read(&uts_sem); |
752 | 753 | ||
@@ -755,17 +756,19 @@ asmlinkage long sys32_olduname(struct oldold_utsname __user * name) | |||
755 | return err; | 756 | return err; |
756 | } | 757 | } |
757 | 758 | ||
758 | long sys32_uname(struct old_utsname __user * name) | 759 | long sys32_uname(struct old_utsname __user *name) |
759 | { | 760 | { |
760 | int err; | 761 | int err; |
762 | |||
761 | if (!name) | 763 | if (!name) |
762 | return -EFAULT; | 764 | return -EFAULT; |
763 | down_read(&uts_sem); | 765 | down_read(&uts_sem); |
764 | err = copy_to_user(name, utsname(), sizeof (*name)); | 766 | err = copy_to_user(name, utsname(), sizeof(*name)); |
765 | up_read(&uts_sem); | 767 | up_read(&uts_sem); |
766 | if (personality(current->personality) == PER_LINUX32) | 768 | if (personality(current->personality) == PER_LINUX32) |
767 | err |= copy_to_user(&name->machine, "i686", 5); | 769 | err |= copy_to_user(&name->machine, "i686", 5); |
768 | return err?-EFAULT:0; | 770 | |
771 | return err ? -EFAULT : 0; | ||
769 | } | 772 | } |
770 | 773 | ||
771 | long sys32_ustat(unsigned dev, struct ustat32 __user *u32p) | 774 | long sys32_ustat(unsigned dev, struct ustat32 __user *u32p) |
@@ -773,27 +776,28 @@ long sys32_ustat(unsigned dev, struct ustat32 __user *u32p) | |||
773 | struct ustat u; | 776 | struct ustat u; |
774 | mm_segment_t seg; | 777 | mm_segment_t seg; |
775 | int ret; | 778 | int ret; |
776 | 779 | ||
777 | seg = get_fs(); | 780 | seg = get_fs(); |
778 | set_fs(KERNEL_DS); | 781 | set_fs(KERNEL_DS); |
779 | ret = sys_ustat(dev, (struct ustat __user *)&u); | 782 | ret = sys_ustat(dev, (struct ustat __user *)&u); |
780 | set_fs(seg); | 783 | set_fs(seg); |
781 | if (ret >= 0) { | 784 | if (ret < 0) |
782 | if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) || | 785 | return ret; |
783 | __put_user((__u32) u.f_tfree, &u32p->f_tfree) || | 786 | |
784 | __put_user((__u32) u.f_tinode, &u32p->f_tfree) || | 787 | if (!access_ok(VERIFY_WRITE, u32p, sizeof(struct ustat32)) || |
785 | __copy_to_user(&u32p->f_fname, u.f_fname, sizeof(u.f_fname)) || | 788 | __put_user((__u32) u.f_tfree, &u32p->f_tfree) || |
786 | __copy_to_user(&u32p->f_fpack, u.f_fpack, sizeof(u.f_fpack))) | 789 | __put_user((__u32) u.f_tinode, &u32p->f_tfree) || |
787 | ret = -EFAULT; | 790 | __copy_to_user(&u32p->f_fname, u.f_fname, sizeof(u.f_fname)) || |
788 | } | 791 | __copy_to_user(&u32p->f_fpack, u.f_fpack, sizeof(u.f_fpack))) |
792 | ret = -EFAULT; | ||
789 | return ret; | 793 | return ret; |
790 | } | 794 | } |
791 | 795 | ||
792 | asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv, | 796 | asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv, |
793 | compat_uptr_t __user *envp, struct pt_regs *regs) | 797 | compat_uptr_t __user *envp, struct pt_regs *regs) |
794 | { | 798 | { |
795 | long error; | 799 | long error; |
796 | char * filename; | 800 | char *filename; |
797 | 801 | ||
798 | filename = getname(name); | 802 | filename = getname(name); |
799 | error = PTR_ERR(filename); | 803 | error = PTR_ERR(filename); |
@@ -814,16 +818,17 @@ asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp, | |||
814 | { | 818 | { |
815 | void __user *parent_tid = (void __user *)regs->rdx; | 819 | void __user *parent_tid = (void __user *)regs->rdx; |
816 | void __user *child_tid = (void __user *)regs->rdi; | 820 | void __user *child_tid = (void __user *)regs->rdi; |
821 | |||
817 | if (!newsp) | 822 | if (!newsp) |
818 | newsp = regs->rsp; | 823 | newsp = regs->rsp; |
819 | return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid); | 824 | return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid); |
820 | } | 825 | } |
821 | 826 | ||
822 | /* | 827 | /* |
823 | * Some system calls that need sign extended arguments. This could be done by a generic wrapper. | 828 | * Some system calls that need sign extended arguments. This could be |
824 | */ | 829 | * done by a generic wrapper. |
825 | 830 | */ | |
826 | long sys32_lseek (unsigned int fd, int offset, unsigned int whence) | 831 | long sys32_lseek(unsigned int fd, int offset, unsigned int whence) |
827 | { | 832 | { |
828 | return sys_lseek(fd, offset, whence); | 833 | return sys_lseek(fd, offset, whence); |
829 | } | 834 | } |
@@ -832,49 +837,52 @@ long sys32_kill(int pid, int sig) | |||
832 | { | 837 | { |
833 | return sys_kill(pid, sig); | 838 | return sys_kill(pid, sig); |
834 | } | 839 | } |
835 | 840 | ||
836 | long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, | 841 | long sys32_fadvise64_64(int fd, __u32 offset_low, __u32 offset_high, |
837 | __u32 len_low, __u32 len_high, int advice) | 842 | __u32 len_low, __u32 len_high, int advice) |
838 | { | 843 | { |
839 | return sys_fadvise64_64(fd, | 844 | return sys_fadvise64_64(fd, |
840 | (((u64)offset_high)<<32) | offset_low, | 845 | (((u64)offset_high)<<32) | offset_low, |
841 | (((u64)len_high)<<32) | len_low, | 846 | (((u64)len_high)<<32) | len_low, |
842 | advice); | 847 | advice); |
843 | } | 848 | } |
844 | 849 | ||
845 | long sys32_vm86_warning(void) | 850 | long sys32_vm86_warning(void) |
846 | { | 851 | { |
847 | struct task_struct *me = current; | 852 | struct task_struct *me = current; |
848 | static char lastcomm[sizeof(me->comm)]; | 853 | static char lastcomm[sizeof(me->comm)]; |
854 | |||
849 | if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) { | 855 | if (strncmp(lastcomm, me->comm, sizeof(lastcomm))) { |
850 | compat_printk(KERN_INFO "%s: vm86 mode not supported on 64 bit kernel\n", | 856 | compat_printk(KERN_INFO |
851 | me->comm); | 857 | "%s: vm86 mode not supported on 64 bit kernel\n", |
858 | me->comm); | ||
852 | strncpy(lastcomm, me->comm, sizeof(lastcomm)); | 859 | strncpy(lastcomm, me->comm, sizeof(lastcomm)); |
853 | } | 860 | } |
854 | return -ENOSYS; | 861 | return -ENOSYS; |
855 | } | 862 | } |
856 | 863 | ||
857 | long sys32_lookup_dcookie(u32 addr_low, u32 addr_high, | 864 | long sys32_lookup_dcookie(u32 addr_low, u32 addr_high, |
858 | char __user * buf, size_t len) | 865 | char __user *buf, size_t len) |
859 | { | 866 | { |
860 | return sys_lookup_dcookie(((u64)addr_high << 32) | addr_low, buf, len); | 867 | return sys_lookup_dcookie(((u64)addr_high << 32) | addr_low, buf, len); |
861 | } | 868 | } |
862 | 869 | ||
863 | asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi, size_t count) | 870 | asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi, |
871 | size_t count) | ||
864 | { | 872 | { |
865 | return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count); | 873 | return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count); |
866 | } | 874 | } |
867 | 875 | ||
868 | asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi, | 876 | asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi, |
869 | unsigned n_low, unsigned n_hi, int flags) | 877 | unsigned n_low, unsigned n_hi, int flags) |
870 | { | 878 | { |
871 | return sys_sync_file_range(fd, | 879 | return sys_sync_file_range(fd, |
872 | ((u64)off_hi << 32) | off_low, | 880 | ((u64)off_hi << 32) | off_low, |
873 | ((u64)n_hi << 32) | n_low, flags); | 881 | ((u64)n_hi << 32) | n_low, flags); |
874 | } | 882 | } |
875 | 883 | ||
876 | asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi, size_t len, | 884 | asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi, |
877 | int advice) | 885 | size_t len, int advice) |
878 | { | 886 | { |
879 | return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo, | 887 | return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo, |
880 | len, advice); | 888 | len, advice); |