2 * sys_ia32.c: Conversion between 32bit and 64bit native syscalls. Based on
5 * Copyright (C) 2000 VA Linux Co
6 * Copyright (C) 2000 Don Dugger <n0ano@valinux.com>
7 * Copyright (C) 1999 Arun Sharma <arun.sharma@intel.com>
8 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
9 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
10 * Copyright (C) 2000 Hewlett-Packard Co.
11 * Copyright (C) 2000 David Mosberger-Tang <davidm@hpl.hp.com>
12 * Copyright (C) 2000,2001,2002 Andi Kleen, SuSE Labs (x86-64 port)
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.
17 * This file assumes that there is a hole at the end of user address space.
19 * Some of the functions are LE specific currently. These are hopefully all marked.
20 * This should be fixed.
23 #include <linux/kernel.h>
24 #include <linux/sched.h>
26 #include <linux/file.h>
27 #include <linux/signal.h>
28 #include <linux/syscalls.h>
29 #include <linux/resource.h>
30 #include <linux/times.h>
31 #include <linux/utsname.h>
32 #include <linux/smp.h>
33 #include <linux/smp_lock.h>
34 #include <linux/sem.h>
35 #include <linux/msg.h>
37 #include <linux/shm.h>
38 #include <linux/slab.h>
39 #include <linux/uio.h>
40 #include <linux/nfs_fs.h>
41 #include <linux/quota.h>
42 #include <linux/module.h>
43 #include <linux/sunrpc/svc.h>
44 #include <linux/nfsd/nfsd.h>
45 #include <linux/nfsd/cache.h>
46 #include <linux/nfsd/xdr.h>
47 #include <linux/nfsd/syscall.h>
48 #include <linux/poll.h>
49 #include <linux/personality.h>
50 #include <linux/stat.h>
51 #include <linux/ipc.h>
52 #include <linux/rwsem.h>
53 #include <linux/binfmts.h>
54 #include <linux/init.h>
55 #include <linux/aio_abi.h>
56 #include <linux/aio.h>
57 #include <linux/compat.h>
58 #include <linux/vfs.h>
59 #include <linux/ptrace.h>
60 #include <linux/highuid.h>
61 #include <linux/vmalloc.h>
62 #include <linux/fsnotify.h>
63 #include <linux/sysctl.h>
65 #include <asm/types.h>
66 #include <asm/uaccess.h>
67 #include <asm/semaphore.h>
68 #include <asm/atomic.h>
75 #define AA(__x) ((unsigned long)(__x))
77 int cp_compat_stat(struct kstat
*kbuf
, struct compat_stat __user
*ubuf
)
81 typeof(ubuf
->st_uid
) uid
= 0;
82 typeof(ubuf
->st_gid
) gid
= 0;
83 SET_UID(uid
, kbuf
->uid
);
84 SET_GID(gid
, kbuf
->gid
);
85 if (!old_valid_dev(kbuf
->dev
) || !old_valid_dev(kbuf
->rdev
))
87 if (kbuf
->size
>= 0x7fffffff)
90 if (sizeof(ino
) < sizeof(kbuf
->ino
) && ino
!= kbuf
->ino
)
92 if (!access_ok(VERIFY_WRITE
, ubuf
, sizeof(struct compat_stat
)) ||
93 __put_user (old_encode_dev(kbuf
->dev
), &ubuf
->st_dev
) ||
94 __put_user (ino
, &ubuf
->st_ino
) ||
95 __put_user (kbuf
->mode
, &ubuf
->st_mode
) ||
96 __put_user (kbuf
->nlink
, &ubuf
->st_nlink
) ||
97 __put_user (uid
, &ubuf
->st_uid
) ||
98 __put_user (gid
, &ubuf
->st_gid
) ||
99 __put_user (old_encode_dev(kbuf
->rdev
), &ubuf
->st_rdev
) ||
100 __put_user (kbuf
->size
, &ubuf
->st_size
) ||
101 __put_user (kbuf
->atime
.tv_sec
, &ubuf
->st_atime
) ||
102 __put_user (kbuf
->atime
.tv_nsec
, &ubuf
->st_atime_nsec
) ||
103 __put_user (kbuf
->mtime
.tv_sec
, &ubuf
->st_mtime
) ||
104 __put_user (kbuf
->mtime
.tv_nsec
, &ubuf
->st_mtime_nsec
) ||
105 __put_user (kbuf
->ctime
.tv_sec
, &ubuf
->st_ctime
) ||
106 __put_user (kbuf
->ctime
.tv_nsec
, &ubuf
->st_ctime_nsec
) ||
107 __put_user (kbuf
->blksize
, &ubuf
->st_blksize
) ||
108 __put_user (kbuf
->blocks
, &ubuf
->st_blocks
))
114 sys32_truncate64(char __user
* filename
, unsigned long offset_low
, unsigned long offset_high
)
116 return sys_truncate(filename
, ((loff_t
) offset_high
<< 32) | offset_low
);
120 sys32_ftruncate64(unsigned int fd
, unsigned long offset_low
, unsigned long offset_high
)
122 return sys_ftruncate(fd
, ((loff_t
) offset_high
<< 32) | offset_low
);
125 /* Another set for IA32/LFS -- x86_64 struct stat is different due to
126 support for 64bit inode numbers. */
129 cp_stat64(struct stat64 __user
*ubuf
, struct kstat
*stat
)
131 typeof(ubuf
->st_uid
) uid
= 0;
132 typeof(ubuf
->st_gid
) gid
= 0;
133 SET_UID(uid
, stat
->uid
);
134 SET_GID(gid
, stat
->gid
);
135 if (!access_ok(VERIFY_WRITE
, ubuf
, sizeof(struct stat64
)) ||
136 __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
) ||
139 __put_user (stat
->mode
, &ubuf
->st_mode
) ||
140 __put_user (stat
->nlink
, &ubuf
->st_nlink
) ||
141 __put_user (uid
, &ubuf
->st_uid
) ||
142 __put_user (gid
, &ubuf
->st_gid
) ||
143 __put_user (huge_encode_dev(stat
->rdev
), &ubuf
->st_rdev
) ||
144 __put_user (stat
->size
, &ubuf
->st_size
) ||
145 __put_user (stat
->atime
.tv_sec
, &ubuf
->st_atime
) ||
146 __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_nsec
, &ubuf
->st_mtime_nsec
) ||
149 __put_user (stat
->ctime
.tv_sec
, &ubuf
->st_ctime
) ||
150 __put_user (stat
->ctime
.tv_nsec
, &ubuf
->st_ctime_nsec
) ||
151 __put_user (stat
->blksize
, &ubuf
->st_blksize
) ||
152 __put_user (stat
->blocks
, &ubuf
->st_blocks
))
158 sys32_stat64(char __user
* filename
, struct stat64 __user
*statbuf
)
161 int ret
= vfs_stat(filename
, &stat
);
163 ret
= cp_stat64(statbuf
, &stat
);
168 sys32_lstat64(char __user
* filename
, struct stat64 __user
*statbuf
)
171 int ret
= vfs_lstat(filename
, &stat
);
173 ret
= cp_stat64(statbuf
, &stat
);
178 sys32_fstat64(unsigned int fd
, struct stat64 __user
*statbuf
)
181 int ret
= vfs_fstat(fd
, &stat
);
183 ret
= cp_stat64(statbuf
, &stat
);
188 sys32_fstatat(unsigned int dfd
, char __user
*filename
,
189 struct stat64 __user
* statbuf
, int flag
)
194 if ((flag
& ~AT_SYMLINK_NOFOLLOW
) != 0)
197 if (flag
& AT_SYMLINK_NOFOLLOW
)
198 error
= vfs_lstat_fd(dfd
, filename
, &stat
);
200 error
= vfs_stat_fd(dfd
, filename
, &stat
);
203 error
= cp_stat64(statbuf
, &stat
);
210 * Linux/i386 didn't use to be able to handle more than
211 * 4 system call parameters, so these system calls used a memory
212 * block for parameter passing..
215 struct mmap_arg_struct
{
225 sys32_mmap(struct mmap_arg_struct __user
*arg
)
227 struct mmap_arg_struct a
;
228 struct file
*file
= NULL
;
229 unsigned long retval
;
230 struct mm_struct
*mm
;
232 if (copy_from_user(&a
, arg
, sizeof(a
)))
235 if (a
.offset
& ~PAGE_MASK
)
238 if (!(a
.flags
& MAP_ANONYMOUS
)) {
245 down_write(&mm
->mmap_sem
);
246 retval
= do_mmap_pgoff(file
, a
.addr
, a
.len
, a
.prot
, a
.flags
, a
.offset
>>PAGE_SHIFT
);
250 up_write(&mm
->mmap_sem
);
256 sys32_mprotect(unsigned long start
, size_t len
, unsigned long prot
)
258 return sys_mprotect(start
,len
,prot
);
262 sys32_pipe(int __user
*fd
)
267 retval
= do_pipe(fds
);
270 if (copy_to_user(fd
, fds
, sizeof(fds
)))
277 sys32_rt_sigaction(int sig
, struct sigaction32 __user
*act
,
278 struct sigaction32 __user
*oact
, unsigned int sigsetsize
)
280 struct k_sigaction new_ka
, old_ka
;
282 compat_sigset_t set32
;
284 /* XXX: Don't preclude handling different sized sigset_t's. */
285 if (sigsetsize
!= sizeof(compat_sigset_t
))
289 compat_uptr_t handler
, restorer
;
291 if (!access_ok(VERIFY_READ
, act
, sizeof(*act
)) ||
292 __get_user(handler
, &act
->sa_handler
) ||
293 __get_user(new_ka
.sa
.sa_flags
, &act
->sa_flags
) ||
294 __get_user(restorer
, &act
->sa_restorer
)||
295 __copy_from_user(&set32
, &act
->sa_mask
, sizeof(compat_sigset_t
)))
297 new_ka
.sa
.sa_handler
= compat_ptr(handler
);
298 new_ka
.sa
.sa_restorer
= compat_ptr(restorer
);
299 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
300 switch (_NSIG_WORDS
) {
301 case 4: new_ka
.sa
.sa_mask
.sig
[3] = set32
.sig
[6]
302 | (((long)set32
.sig
[7]) << 32);
303 case 3: new_ka
.sa
.sa_mask
.sig
[2] = set32
.sig
[4]
304 | (((long)set32
.sig
[5]) << 32);
305 case 2: new_ka
.sa
.sa_mask
.sig
[1] = set32
.sig
[2]
306 | (((long)set32
.sig
[3]) << 32);
307 case 1: new_ka
.sa
.sa_mask
.sig
[0] = set32
.sig
[0]
308 | (((long)set32
.sig
[1]) << 32);
312 ret
= do_sigaction(sig
, act
? &new_ka
: NULL
, oact
? &old_ka
: NULL
);
315 /* FIXME: here we rely on _COMPAT_NSIG_WORS to be >= than _NSIG_WORDS << 1 */
316 switch (_NSIG_WORDS
) {
318 set32
.sig
[7] = (old_ka
.sa
.sa_mask
.sig
[3] >> 32);
319 set32
.sig
[6] = old_ka
.sa
.sa_mask
.sig
[3];
321 set32
.sig
[5] = (old_ka
.sa
.sa_mask
.sig
[2] >> 32);
322 set32
.sig
[4] = old_ka
.sa
.sa_mask
.sig
[2];
324 set32
.sig
[3] = (old_ka
.sa
.sa_mask
.sig
[1] >> 32);
325 set32
.sig
[2] = old_ka
.sa
.sa_mask
.sig
[1];
327 set32
.sig
[1] = (old_ka
.sa
.sa_mask
.sig
[0] >> 32);
328 set32
.sig
[0] = old_ka
.sa
.sa_mask
.sig
[0];
330 if (!access_ok(VERIFY_WRITE
, oact
, sizeof(*oact
)) ||
331 __put_user(ptr_to_compat(old_ka
.sa
.sa_handler
), &oact
->sa_handler
) ||
332 __put_user(ptr_to_compat(old_ka
.sa
.sa_restorer
), &oact
->sa_restorer
) ||
333 __put_user(old_ka
.sa
.sa_flags
, &oact
->sa_flags
) ||
334 __copy_to_user(&oact
->sa_mask
, &set32
, sizeof(compat_sigset_t
)))
342 sys32_sigaction (int sig
, struct old_sigaction32 __user
*act
, struct old_sigaction32 __user
*oact
)
344 struct k_sigaction new_ka
, old_ka
;
348 compat_old_sigset_t mask
;
349 compat_uptr_t handler
, restorer
;
351 if (!access_ok(VERIFY_READ
, act
, sizeof(*act
)) ||
352 __get_user(handler
, &act
->sa_handler
) ||
353 __get_user(new_ka
.sa
.sa_flags
, &act
->sa_flags
) ||
354 __get_user(restorer
, &act
->sa_restorer
) ||
355 __get_user(mask
, &act
->sa_mask
))
358 new_ka
.sa
.sa_handler
= compat_ptr(handler
);
359 new_ka
.sa
.sa_restorer
= compat_ptr(restorer
);
361 siginitset(&new_ka
.sa
.sa_mask
, mask
);
364 ret
= do_sigaction(sig
, act
? &new_ka
: NULL
, oact
? &old_ka
: NULL
);
367 if (!access_ok(VERIFY_WRITE
, oact
, sizeof(*oact
)) ||
368 __put_user(ptr_to_compat(old_ka
.sa
.sa_handler
), &oact
->sa_handler
) ||
369 __put_user(ptr_to_compat(old_ka
.sa
.sa_restorer
), &oact
->sa_restorer
) ||
370 __put_user(old_ka
.sa
.sa_flags
, &oact
->sa_flags
) ||
371 __put_user(old_ka
.sa
.sa_mask
.sig
[0], &oact
->sa_mask
))
379 sys32_rt_sigprocmask(int how
, compat_sigset_t __user
*set
,
380 compat_sigset_t __user
*oset
, unsigned int sigsetsize
)
385 mm_segment_t old_fs
= get_fs();
388 if (copy_from_user (&s32
, set
, sizeof(compat_sigset_t
)))
390 switch (_NSIG_WORDS
) {
391 case 4: s
.sig
[3] = s32
.sig
[6] | (((long)s32
.sig
[7]) << 32);
392 case 3: s
.sig
[2] = s32
.sig
[4] | (((long)s32
.sig
[5]) << 32);
393 case 2: s
.sig
[1] = s32
.sig
[2] | (((long)s32
.sig
[3]) << 32);
394 case 1: s
.sig
[0] = s32
.sig
[0] | (((long)s32
.sig
[1]) << 32);
398 ret
= sys_rt_sigprocmask(how
,
399 set
? (sigset_t __user
*)&s
: NULL
,
400 oset
? (sigset_t __user
*)&s
: NULL
,
405 switch (_NSIG_WORDS
) {
406 case 4: s32
.sig
[7] = (s
.sig
[3] >> 32); s32
.sig
[6] = s
.sig
[3];
407 case 3: s32
.sig
[5] = (s
.sig
[2] >> 32); s32
.sig
[4] = s
.sig
[2];
408 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];
411 if (copy_to_user (oset
, &s32
, sizeof(compat_sigset_t
)))
418 get_tv32(struct timeval
*o
, struct compat_timeval __user
*i
)
421 if (access_ok(VERIFY_READ
, i
, sizeof(*i
))) {
422 err
= __get_user(o
->tv_sec
, &i
->tv_sec
);
423 err
|= __get_user(o
->tv_usec
, &i
->tv_usec
);
429 put_tv32(struct compat_timeval __user
*o
, struct timeval
*i
)
432 if (access_ok(VERIFY_WRITE
, o
, sizeof(*o
))) {
433 err
= __put_user(i
->tv_sec
, &o
->tv_sec
);
434 err
|= __put_user(i
->tv_usec
, &o
->tv_usec
);
439 extern unsigned int alarm_setitimer(unsigned int seconds
);
442 sys32_alarm(unsigned int seconds
)
444 return alarm_setitimer(seconds
);
447 /* Translations due to time_t size differences. Which affects all
448 sorts of things, like timeval and itimerval. */
450 extern struct timezone sys_tz
;
453 sys32_gettimeofday(struct compat_timeval __user
*tv
, struct timezone __user
*tz
)
457 do_gettimeofday(&ktv
);
458 if (put_tv32(tv
, &ktv
))
462 if (copy_to_user(tz
, &sys_tz
, sizeof(sys_tz
)))
469 sys32_settimeofday(struct compat_timeval __user
*tv
, struct timezone __user
*tz
)
476 if (get_tv32(&ktv
, tv
))
478 kts
.tv_sec
= ktv
.tv_sec
;
479 kts
.tv_nsec
= ktv
.tv_usec
* NSEC_PER_USEC
;
482 if (copy_from_user(&ktz
, tz
, sizeof(ktz
)))
486 return do_sys_settimeofday(tv
? &kts
: NULL
, tz
? &ktz
: NULL
);
489 struct sel_arg_struct
{
498 sys32_old_select(struct sel_arg_struct __user
*arg
)
500 struct sel_arg_struct a
;
502 if (copy_from_user(&a
, arg
, sizeof(a
)))
504 return compat_sys_select(a
.n
, compat_ptr(a
.inp
), compat_ptr(a
.outp
),
505 compat_ptr(a
.exp
), compat_ptr(a
.tvp
));
508 extern asmlinkage
long
509 compat_sys_wait4(compat_pid_t pid
, compat_uint_t
* stat_addr
, int options
,
510 struct compat_rusage
*ru
);
513 sys32_waitpid(compat_pid_t pid
, unsigned int *stat_addr
, int options
)
515 return compat_sys_wait4(pid
, stat_addr
, options
, NULL
);
518 /* 32-bit timeval and related flotsam. */
521 sys32_sysfs(int option
, u32 arg1
, u32 arg2
)
523 return sys_sysfs(option
, arg1
, arg2
);
527 sys32_sched_rr_get_interval(compat_pid_t pid
, struct compat_timespec __user
*interval
)
531 mm_segment_t old_fs
= get_fs ();
534 ret
= sys_sched_rr_get_interval(pid
, (struct timespec __user
*)&t
);
536 if (put_compat_timespec(&t
, interval
))
542 sys32_rt_sigpending(compat_sigset_t __user
*set
, compat_size_t sigsetsize
)
547 mm_segment_t old_fs
= get_fs();
550 ret
= sys_rt_sigpending((sigset_t __user
*)&s
, sigsetsize
);
553 switch (_NSIG_WORDS
) {
554 case 4: s32
.sig
[7] = (s
.sig
[3] >> 32); s32
.sig
[6] = s
.sig
[3];
555 case 3: s32
.sig
[5] = (s
.sig
[2] >> 32); s32
.sig
[4] = s
.sig
[2];
556 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];
559 if (copy_to_user (set
, &s32
, sizeof(compat_sigset_t
)))
566 sys32_rt_sigqueueinfo(int pid
, int sig
, compat_siginfo_t __user
*uinfo
)
570 mm_segment_t old_fs
= get_fs();
572 if (copy_siginfo_from_user32(&info
, uinfo
))
575 ret
= sys_rt_sigqueueinfo(pid
, sig
, (siginfo_t __user
*)&info
);
580 /* These are here just in case some old ia32 binary calls it. */
584 current
->state
= TASK_INTERRUPTIBLE
;
586 return -ERESTARTNOHAND
;
590 #ifdef CONFIG_SYSCTL_SYSCALL
595 unsigned int oldlenp
;
598 unsigned int __unused
[4];
603 sys32_sysctl(struct sysctl_ia32 __user
*args32
)
605 struct sysctl_ia32 a32
;
606 mm_segment_t old_fs
= get_fs ();
607 void __user
*oldvalp
, *newvalp
;
612 if (copy_from_user(&a32
, args32
, sizeof (a32
)))
616 * We need to pre-validate these because we have to disable address checking
617 * before calling do_sysctl() because of OLDLEN but we can't run the risk of the
618 * user specifying bad addresses here. Well, since we're dealing with 32 bit
619 * addresses, we KNOW that access_ok() will always succeed, so this is an
620 * expensive NOP, but so what...
622 namep
= compat_ptr(a32
.name
);
623 oldvalp
= compat_ptr(a32
.oldval
);
624 newvalp
= compat_ptr(a32
.newval
);
626 if ((oldvalp
&& get_user(oldlen
, (int __user
*)compat_ptr(a32
.oldlenp
)))
627 || !access_ok(VERIFY_WRITE
, namep
, 0)
628 || !access_ok(VERIFY_WRITE
, oldvalp
, 0)
629 || !access_ok(VERIFY_WRITE
, newvalp
, 0))
634 ret
= do_sysctl(namep
, a32
.nlen
, oldvalp
, (size_t __user
*)&oldlen
,
635 newvalp
, (size_t) a32
.newlen
);
639 if (oldvalp
&& put_user (oldlen
, (int __user
*)compat_ptr(a32
.oldlenp
)))
646 /* warning: next two assume little endian */
648 sys32_pread(unsigned int fd
, char __user
*ubuf
, u32 count
, u32 poslo
, u32 poshi
)
650 return sys_pread64(fd
, ubuf
, count
,
651 ((loff_t
)AA(poshi
) << 32) | AA(poslo
));
655 sys32_pwrite(unsigned int fd
, char __user
*ubuf
, u32 count
, u32 poslo
, u32 poshi
)
657 return sys_pwrite64(fd
, ubuf
, count
,
658 ((loff_t
)AA(poshi
) << 32) | AA(poslo
));
663 sys32_personality(unsigned long personality
)
666 if (personality(current
->personality
) == PER_LINUX32
&&
667 personality
== PER_LINUX
)
668 personality
= PER_LINUX32
;
669 ret
= sys_personality(personality
);
670 if (ret
== PER_LINUX32
)
676 sys32_sendfile(int out_fd
, int in_fd
, compat_off_t __user
*offset
, s32 count
)
678 mm_segment_t old_fs
= get_fs();
682 if (offset
&& get_user(of
, offset
))
686 ret
= sys_sendfile(out_fd
, in_fd
, offset
? (off_t __user
*)&of
: NULL
,
690 if (offset
&& put_user(of
, offset
))
696 asmlinkage
long sys32_mmap2(unsigned long addr
, unsigned long len
,
697 unsigned long prot
, unsigned long flags
,
698 unsigned long fd
, unsigned long pgoff
)
700 struct mm_struct
*mm
= current
->mm
;
702 struct file
* file
= NULL
;
704 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
705 if (!(flags
& MAP_ANONYMOUS
)) {
711 down_write(&mm
->mmap_sem
);
712 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
713 up_write(&mm
->mmap_sem
);
720 asmlinkage
long sys32_olduname(struct oldold_utsname __user
* name
)
726 if (!access_ok(VERIFY_WRITE
, name
, sizeof(struct oldold_utsname
)))
731 err
= __copy_to_user(&name
->sysname
,&utsname()->sysname
,
733 err
|= __put_user(0,name
->sysname
+__OLD_UTS_LEN
);
734 err
|= __copy_to_user(&name
->nodename
,&utsname()->nodename
,
736 err
|= __put_user(0,name
->nodename
+__OLD_UTS_LEN
);
737 err
|= __copy_to_user(&name
->release
,&utsname()->release
,
739 err
|= __put_user(0,name
->release
+__OLD_UTS_LEN
);
740 err
|= __copy_to_user(&name
->version
,&utsname()->version
,
742 err
|= __put_user(0,name
->version
+__OLD_UTS_LEN
);
744 char *arch
= "x86_64";
745 if (personality(current
->personality
) == PER_LINUX32
)
748 err
|= __copy_to_user(&name
->machine
, arch
, strlen(arch
)+1);
753 err
= err
? -EFAULT
: 0;
758 long sys32_uname(struct old_utsname __user
* name
)
764 err
= copy_to_user(name
, utsname(), sizeof (*name
));
766 if (personality(current
->personality
) == PER_LINUX32
)
767 err
|= copy_to_user(&name
->machine
, "i686", 5);
768 return err
?-EFAULT
:0;
771 long sys32_ustat(unsigned dev
, struct ustat32 __user
*u32p
)
779 ret
= sys_ustat(dev
, (struct ustat __user
*)&u
);
782 if (!access_ok(VERIFY_WRITE
,u32p
,sizeof(struct ustat32
)) ||
783 __put_user((__u32
) u
.f_tfree
, &u32p
->f_tfree
) ||
784 __put_user((__u32
) u
.f_tinode
, &u32p
->f_tfree
) ||
785 __copy_to_user(&u32p
->f_fname
, u
.f_fname
, sizeof(u
.f_fname
)) ||
786 __copy_to_user(&u32p
->f_fpack
, u
.f_fpack
, sizeof(u
.f_fpack
)))
792 asmlinkage
long sys32_execve(char __user
*name
, compat_uptr_t __user
*argv
,
793 compat_uptr_t __user
*envp
, struct pt_regs
*regs
)
798 filename
= getname(name
);
799 error
= PTR_ERR(filename
);
800 if (IS_ERR(filename
))
802 error
= compat_do_execve(filename
, argv
, envp
, regs
);
805 current
->ptrace
&= ~PT_DTRACE
;
806 task_unlock(current
);
812 asmlinkage
long sys32_clone(unsigned int clone_flags
, unsigned int newsp
,
813 struct pt_regs
*regs
)
815 void __user
*parent_tid
= (void __user
*)regs
->rdx
;
816 void __user
*child_tid
= (void __user
*)regs
->rdi
;
819 return do_fork(clone_flags
, newsp
, regs
, 0, parent_tid
, child_tid
);
823 * Some system calls that need sign extended arguments. This could be done by a generic wrapper.
826 long sys32_lseek (unsigned int fd
, int offset
, unsigned int whence
)
828 return sys_lseek(fd
, offset
, whence
);
831 long sys32_kill(int pid
, int sig
)
833 return sys_kill(pid
, sig
);
836 long sys32_fadvise64_64(int fd
, __u32 offset_low
, __u32 offset_high
,
837 __u32 len_low
, __u32 len_high
, int advice
)
839 return sys_fadvise64_64(fd
,
840 (((u64
)offset_high
)<<32) | offset_low
,
841 (((u64
)len_high
)<<32) | len_low
,
845 long sys32_vm86_warning(void)
847 struct task_struct
*me
= current
;
848 static char lastcomm
[sizeof(me
->comm
)];
849 if (strncmp(lastcomm
, me
->comm
, sizeof(lastcomm
))) {
850 compat_printk(KERN_INFO
"%s: vm86 mode not supported on 64 bit kernel\n",
852 strncpy(lastcomm
, me
->comm
, sizeof(lastcomm
));
857 long sys32_lookup_dcookie(u32 addr_low
, u32 addr_high
,
858 char __user
* buf
, size_t len
)
860 return sys_lookup_dcookie(((u64
)addr_high
<< 32) | addr_low
, buf
, len
);
863 asmlinkage ssize_t
sys32_readahead(int fd
, unsigned off_lo
, unsigned off_hi
, size_t count
)
865 return sys_readahead(fd
, ((u64
)off_hi
<< 32) | off_lo
, count
);
868 asmlinkage
long sys32_sync_file_range(int fd
, unsigned off_low
, unsigned off_hi
,
869 unsigned n_low
, unsigned n_hi
, int flags
)
871 return sys_sync_file_range(fd
,
872 ((u64
)off_hi
<< 32) | off_low
,
873 ((u64
)n_hi
<< 32) | n_low
, flags
);
876 asmlinkage
long sys32_fadvise64(int fd
, unsigned offset_lo
, unsigned offset_hi
, size_t len
,
879 return sys_fadvise64_64(fd
, ((u64
)offset_hi
<< 32) | offset_lo
,
883 asmlinkage
long sys32_fallocate(int fd
, int mode
, unsigned offset_lo
,
884 unsigned offset_hi
, unsigned len_lo
,
887 return sys_fallocate(fd
, mode
, ((u64
)offset_hi
<< 32) | offset_lo
,
888 ((u64
)len_hi
<< 32) | len_lo
);