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
20 * hopefully all marked. 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
))
113 asmlinkage
long sys32_truncate64(char __user
*filename
,
114 unsigned long offset_low
,
115 unsigned long offset_high
)
117 return sys_truncate(filename
, ((loff_t
) offset_high
<< 32) | offset_low
);
120 asmlinkage
long sys32_ftruncate64(unsigned int fd
, unsigned long offset_low
,
121 unsigned long offset_high
)
123 return sys_ftruncate(fd
, ((loff_t
) offset_high
<< 32) | offset_low
);
127 * Another set for IA32/LFS -- x86_64 struct stat is different due to
128 * support for 64bit inode numbers.
130 static int cp_stat64(struct stat64 __user
*ubuf
, struct kstat
*stat
)
132 typeof(ubuf
->st_uid
) uid
= 0;
133 typeof(ubuf
->st_gid
) gid
= 0;
134 SET_UID(uid
, stat
->uid
);
135 SET_GID(gid
, stat
->gid
);
136 if (!access_ok(VERIFY_WRITE
, ubuf
, sizeof(struct stat64
)) ||
137 __put_user(huge_encode_dev(stat
->dev
), &ubuf
->st_dev
) ||
138 __put_user(stat
->ino
, &ubuf
->__st_ino
) ||
139 __put_user(stat
->ino
, &ubuf
->st_ino
) ||
140 __put_user(stat
->mode
, &ubuf
->st_mode
) ||
141 __put_user(stat
->nlink
, &ubuf
->st_nlink
) ||
142 __put_user(uid
, &ubuf
->st_uid
) ||
143 __put_user(gid
, &ubuf
->st_gid
) ||
144 __put_user(huge_encode_dev(stat
->rdev
), &ubuf
->st_rdev
) ||
145 __put_user(stat
->size
, &ubuf
->st_size
) ||
146 __put_user(stat
->atime
.tv_sec
, &ubuf
->st_atime
) ||
147 __put_user(stat
->atime
.tv_nsec
, &ubuf
->st_atime_nsec
) ||
148 __put_user(stat
->mtime
.tv_sec
, &ubuf
->st_mtime
) ||
149 __put_user(stat
->mtime
.tv_nsec
, &ubuf
->st_mtime_nsec
) ||
150 __put_user(stat
->ctime
.tv_sec
, &ubuf
->st_ctime
) ||
151 __put_user(stat
->ctime
.tv_nsec
, &ubuf
->st_ctime_nsec
) ||
152 __put_user(stat
->blksize
, &ubuf
->st_blksize
) ||
153 __put_user(stat
->blocks
, &ubuf
->st_blocks
))
158 asmlinkage
long sys32_stat64(char __user
*filename
,
159 struct stat64 __user
*statbuf
)
162 int ret
= vfs_stat(filename
, &stat
);
165 ret
= cp_stat64(statbuf
, &stat
);
169 asmlinkage
long sys32_lstat64(char __user
*filename
,
170 struct stat64 __user
*statbuf
)
173 int ret
= vfs_lstat(filename
, &stat
);
175 ret
= cp_stat64(statbuf
, &stat
);
179 asmlinkage
long sys32_fstat64(unsigned int fd
, struct stat64 __user
*statbuf
)
182 int ret
= vfs_fstat(fd
, &stat
);
184 ret
= cp_stat64(statbuf
, &stat
);
188 asmlinkage
long 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
{
224 asmlinkage
long sys32_mmap(struct mmap_arg_struct __user
*arg
)
226 struct mmap_arg_struct a
;
227 struct file
*file
= NULL
;
228 unsigned long retval
;
229 struct mm_struct
*mm
;
231 if (copy_from_user(&a
, arg
, sizeof(a
)))
234 if (a
.offset
& ~PAGE_MASK
)
237 if (!(a
.flags
& MAP_ANONYMOUS
)) {
244 down_write(&mm
->mmap_sem
);
245 retval
= do_mmap_pgoff(file
, a
.addr
, a
.len
, a
.prot
, a
.flags
,
246 a
.offset
>>PAGE_SHIFT
);
250 up_write(&mm
->mmap_sem
);
255 asmlinkage
long sys32_mprotect(unsigned long start
, size_t len
,
258 return sys_mprotect(start
, len
, prot
);
261 asmlinkage
long sys32_pipe(int __user
*fd
)
266 retval
= do_pipe(fds
);
269 if (copy_to_user(fd
, fds
, sizeof(fds
)))
275 asmlinkage
long sys32_rt_sigaction(int sig
, struct sigaction32 __user
*act
,
276 struct sigaction32 __user
*oact
,
277 unsigned int sigsetsize
)
279 struct k_sigaction new_ka
, old_ka
;
281 compat_sigset_t set32
;
283 /* XXX: Don't preclude handling different sized sigset_t's. */
284 if (sigsetsize
!= sizeof(compat_sigset_t
))
288 compat_uptr_t handler
, restorer
;
290 if (!access_ok(VERIFY_READ
, act
, sizeof(*act
)) ||
291 __get_user(handler
, &act
->sa_handler
) ||
292 __get_user(new_ka
.sa
.sa_flags
, &act
->sa_flags
) ||
293 __get_user(restorer
, &act
->sa_restorer
) ||
294 __copy_from_user(&set32
, &act
->sa_mask
,
295 sizeof(compat_sigset_t
)))
297 new_ka
.sa
.sa_handler
= compat_ptr(handler
);
298 new_ka
.sa
.sa_restorer
= compat_ptr(restorer
);
301 * FIXME: here we rely on _COMPAT_NSIG_WORS to be >=
302 * than _NSIG_WORDS << 1
304 switch (_NSIG_WORDS
) {
305 case 4: new_ka
.sa
.sa_mask
.sig
[3] = set32
.sig
[6]
306 | (((long)set32
.sig
[7]) << 32);
307 case 3: new_ka
.sa
.sa_mask
.sig
[2] = set32
.sig
[4]
308 | (((long)set32
.sig
[5]) << 32);
309 case 2: new_ka
.sa
.sa_mask
.sig
[1] = set32
.sig
[2]
310 | (((long)set32
.sig
[3]) << 32);
311 case 1: new_ka
.sa
.sa_mask
.sig
[0] = set32
.sig
[0]
312 | (((long)set32
.sig
[1]) << 32);
316 ret
= do_sigaction(sig
, act
? &new_ka
: NULL
, oact
? &old_ka
: NULL
);
320 * FIXME: here we rely on _COMPAT_NSIG_WORS to be >=
321 * than _NSIG_WORDS << 1
323 switch (_NSIG_WORDS
) {
325 set32
.sig
[7] = (old_ka
.sa
.sa_mask
.sig
[3] >> 32);
326 set32
.sig
[6] = old_ka
.sa
.sa_mask
.sig
[3];
328 set32
.sig
[5] = (old_ka
.sa
.sa_mask
.sig
[2] >> 32);
329 set32
.sig
[4] = old_ka
.sa
.sa_mask
.sig
[2];
331 set32
.sig
[3] = (old_ka
.sa
.sa_mask
.sig
[1] >> 32);
332 set32
.sig
[2] = old_ka
.sa
.sa_mask
.sig
[1];
334 set32
.sig
[1] = (old_ka
.sa
.sa_mask
.sig
[0] >> 32);
335 set32
.sig
[0] = old_ka
.sa
.sa_mask
.sig
[0];
337 if (!access_ok(VERIFY_WRITE
, oact
, sizeof(*oact
)) ||
338 __put_user(ptr_to_compat(old_ka
.sa
.sa_handler
),
339 &oact
->sa_handler
) ||
340 __put_user(ptr_to_compat(old_ka
.sa
.sa_restorer
),
341 &oact
->sa_restorer
) ||
342 __put_user(old_ka
.sa
.sa_flags
, &oact
->sa_flags
) ||
343 __copy_to_user(&oact
->sa_mask
, &set32
,
344 sizeof(compat_sigset_t
)))
351 asmlinkage
long sys32_sigaction(int sig
, struct old_sigaction32 __user
*act
,
352 struct old_sigaction32 __user
*oact
)
354 struct k_sigaction new_ka
, old_ka
;
358 compat_old_sigset_t mask
;
359 compat_uptr_t handler
, restorer
;
361 if (!access_ok(VERIFY_READ
, act
, sizeof(*act
)) ||
362 __get_user(handler
, &act
->sa_handler
) ||
363 __get_user(new_ka
.sa
.sa_flags
, &act
->sa_flags
) ||
364 __get_user(restorer
, &act
->sa_restorer
) ||
365 __get_user(mask
, &act
->sa_mask
))
368 new_ka
.sa
.sa_handler
= compat_ptr(handler
);
369 new_ka
.sa
.sa_restorer
= compat_ptr(restorer
);
371 siginitset(&new_ka
.sa
.sa_mask
, mask
);
374 ret
= do_sigaction(sig
, act
? &new_ka
: NULL
, oact
? &old_ka
: NULL
);
377 if (!access_ok(VERIFY_WRITE
, oact
, sizeof(*oact
)) ||
378 __put_user(ptr_to_compat(old_ka
.sa
.sa_handler
),
379 &oact
->sa_handler
) ||
380 __put_user(ptr_to_compat(old_ka
.sa
.sa_restorer
),
381 &oact
->sa_restorer
) ||
382 __put_user(old_ka
.sa
.sa_flags
, &oact
->sa_flags
) ||
383 __put_user(old_ka
.sa
.sa_mask
.sig
[0], &oact
->sa_mask
))
390 asmlinkage
long sys32_rt_sigprocmask(int how
, compat_sigset_t __user
*set
,
391 compat_sigset_t __user
*oset
,
392 unsigned int sigsetsize
)
397 mm_segment_t old_fs
= get_fs();
400 if (copy_from_user(&s32
, set
, sizeof(compat_sigset_t
)))
402 switch (_NSIG_WORDS
) {
403 case 4: s
.sig
[3] = s32
.sig
[6] | (((long)s32
.sig
[7]) << 32);
404 case 3: s
.sig
[2] = s32
.sig
[4] | (((long)s32
.sig
[5]) << 32);
405 case 2: s
.sig
[1] = s32
.sig
[2] | (((long)s32
.sig
[3]) << 32);
406 case 1: s
.sig
[0] = s32
.sig
[0] | (((long)s32
.sig
[1]) << 32);
410 ret
= sys_rt_sigprocmask(how
,
411 set
? (sigset_t __user
*)&s
: NULL
,
412 oset
? (sigset_t __user
*)&s
: NULL
,
418 switch (_NSIG_WORDS
) {
419 case 4: s32
.sig
[7] = (s
.sig
[3] >> 32); s32
.sig
[6] = s
.sig
[3];
420 case 3: s32
.sig
[5] = (s
.sig
[2] >> 32); s32
.sig
[4] = s
.sig
[2];
421 case 2: s32
.sig
[3] = (s
.sig
[1] >> 32); s32
.sig
[2] = s
.sig
[1];
422 case 1: s32
.sig
[1] = (s
.sig
[0] >> 32); s32
.sig
[0] = s
.sig
[0];
424 if (copy_to_user(oset
, &s32
, sizeof(compat_sigset_t
)))
430 static inline long get_tv32(struct timeval
*o
, struct compat_timeval __user
*i
)
434 if (access_ok(VERIFY_READ
, i
, sizeof(*i
))) {
435 err
= __get_user(o
->tv_sec
, &i
->tv_sec
);
436 err
|= __get_user(o
->tv_usec
, &i
->tv_usec
);
441 static inline long put_tv32(struct compat_timeval __user
*o
, struct timeval
*i
)
445 if (access_ok(VERIFY_WRITE
, o
, sizeof(*o
))) {
446 err
= __put_user(i
->tv_sec
, &o
->tv_sec
);
447 err
|= __put_user(i
->tv_usec
, &o
->tv_usec
);
452 asmlinkage
long sys32_alarm(unsigned int seconds
)
454 return alarm_setitimer(seconds
);
458 * Translations due to time_t size differences. Which affects all
459 * sorts of things, like timeval and itimerval.
461 asmlinkage
long sys32_gettimeofday(struct compat_timeval __user
*tv
,
462 struct timezone __user
*tz
)
467 do_gettimeofday(&ktv
);
468 if (put_tv32(tv
, &ktv
))
472 if (copy_to_user(tz
, &sys_tz
, sizeof(sys_tz
)))
478 asmlinkage
long sys32_settimeofday(struct compat_timeval __user
*tv
,
479 struct timezone __user
*tz
)
486 if (get_tv32(&ktv
, tv
))
488 kts
.tv_sec
= ktv
.tv_sec
;
489 kts
.tv_nsec
= ktv
.tv_usec
* NSEC_PER_USEC
;
492 if (copy_from_user(&ktz
, tz
, sizeof(ktz
)))
496 return do_sys_settimeofday(tv
? &kts
: NULL
, tz
? &ktz
: NULL
);
499 struct sel_arg_struct
{
507 asmlinkage
long sys32_old_select(struct sel_arg_struct __user
*arg
)
509 struct sel_arg_struct a
;
511 if (copy_from_user(&a
, arg
, sizeof(a
)))
513 return compat_sys_select(a
.n
, compat_ptr(a
.inp
), compat_ptr(a
.outp
),
514 compat_ptr(a
.exp
), compat_ptr(a
.tvp
));
517 asmlinkage
long sys32_waitpid(compat_pid_t pid
, unsigned int *stat_addr
,
520 return compat_sys_wait4(pid
, stat_addr
, options
, NULL
);
523 /* 32-bit timeval and related flotsam. */
525 asmlinkage
long sys32_sysfs(int option
, u32 arg1
, u32 arg2
)
527 return sys_sysfs(option
, arg1
, arg2
);
530 asmlinkage
long sys32_sched_rr_get_interval(compat_pid_t pid
,
531 struct compat_timespec __user
*interval
)
535 mm_segment_t old_fs
= get_fs();
538 ret
= sys_sched_rr_get_interval(pid
, (struct timespec __user
*)&t
);
540 if (put_compat_timespec(&t
, interval
))
545 asmlinkage
long sys32_rt_sigpending(compat_sigset_t __user
*set
,
546 compat_size_t sigsetsize
)
551 mm_segment_t old_fs
= get_fs();
554 ret
= sys_rt_sigpending((sigset_t __user
*)&s
, sigsetsize
);
557 switch (_NSIG_WORDS
) {
558 case 4: s32
.sig
[7] = (s
.sig
[3] >> 32); s32
.sig
[6] = s
.sig
[3];
559 case 3: s32
.sig
[5] = (s
.sig
[2] >> 32); s32
.sig
[4] = s
.sig
[2];
560 case 2: s32
.sig
[3] = (s
.sig
[1] >> 32); s32
.sig
[2] = s
.sig
[1];
561 case 1: s32
.sig
[1] = (s
.sig
[0] >> 32); s32
.sig
[0] = s
.sig
[0];
563 if (copy_to_user(set
, &s32
, sizeof(compat_sigset_t
)))
569 asmlinkage
long sys32_rt_sigqueueinfo(int pid
, int sig
,
570 compat_siginfo_t __user
*uinfo
)
574 mm_segment_t old_fs
= get_fs();
576 if (copy_siginfo_from_user32(&info
, uinfo
))
579 ret
= sys_rt_sigqueueinfo(pid
, sig
, (siginfo_t __user
*)&info
);
584 /* These are here just in case some old ia32 binary calls it. */
585 asmlinkage
long sys32_pause(void)
587 current
->state
= TASK_INTERRUPTIBLE
;
589 return -ERESTARTNOHAND
;
593 #ifdef CONFIG_SYSCTL_SYSCALL
598 unsigned int oldlenp
;
601 unsigned int __unused
[4];
605 asmlinkage
long sys32_sysctl(struct sysctl_ia32 __user
*args32
)
607 struct sysctl_ia32 a32
;
608 mm_segment_t old_fs
= get_fs();
609 void __user
*oldvalp
, *newvalp
;
614 if (copy_from_user(&a32
, args32
, sizeof(a32
)))
618 * We need to pre-validate these because we have to disable
619 * address checking before calling do_sysctl() because of
620 * OLDLEN but we can't run the risk of the user specifying bad
621 * addresses here. Well, since we're dealing with 32 bit
622 * addresses, we KNOW that access_ok() will always succeed, so
623 * this is an expensive NOP, but so what...
625 namep
= compat_ptr(a32
.name
);
626 oldvalp
= compat_ptr(a32
.oldval
);
627 newvalp
= compat_ptr(a32
.newval
);
629 if ((oldvalp
&& get_user(oldlen
, (int __user
*)compat_ptr(a32
.oldlenp
)))
630 || !access_ok(VERIFY_WRITE
, namep
, 0)
631 || !access_ok(VERIFY_WRITE
, oldvalp
, 0)
632 || !access_ok(VERIFY_WRITE
, newvalp
, 0))
637 ret
= do_sysctl(namep
, a32
.nlen
, oldvalp
, (size_t __user
*)&oldlen
,
638 newvalp
, (size_t) a32
.newlen
);
642 if (oldvalp
&& put_user(oldlen
, (int __user
*)compat_ptr(a32
.oldlenp
)))
649 /* warning: next two assume little endian */
650 asmlinkage
long sys32_pread(unsigned int fd
, char __user
*ubuf
, u32 count
,
651 u32 poslo
, u32 poshi
)
653 return sys_pread64(fd
, ubuf
, count
,
654 ((loff_t
)AA(poshi
) << 32) | AA(poslo
));
657 asmlinkage
long sys32_pwrite(unsigned int fd
, char __user
*ubuf
, u32 count
,
658 u32 poslo
, u32 poshi
)
660 return sys_pwrite64(fd
, ubuf
, count
,
661 ((loff_t
)AA(poshi
) << 32) | AA(poslo
));
665 asmlinkage
long sys32_personality(unsigned long personality
)
669 if (personality(current
->personality
) == PER_LINUX32
&&
670 personality
== PER_LINUX
)
671 personality
= PER_LINUX32
;
672 ret
= sys_personality(personality
);
673 if (ret
== PER_LINUX32
)
678 asmlinkage
long sys32_sendfile(int out_fd
, int in_fd
,
679 compat_off_t __user
*offset
, s32 count
)
681 mm_segment_t old_fs
= get_fs();
685 if (offset
&& get_user(of
, offset
))
689 ret
= sys_sendfile(out_fd
, in_fd
, offset
? (off_t __user
*)&of
: NULL
,
693 if (offset
&& put_user(of
, offset
))
698 asmlinkage
long sys32_mmap2(unsigned long addr
, unsigned long len
,
699 unsigned long prot
, unsigned long flags
,
700 unsigned long fd
, unsigned long pgoff
)
702 struct mm_struct
*mm
= current
->mm
;
704 struct file
*file
= NULL
;
706 flags
&= ~(MAP_EXECUTABLE
| MAP_DENYWRITE
);
707 if (!(flags
& MAP_ANONYMOUS
)) {
713 down_write(&mm
->mmap_sem
);
714 error
= do_mmap_pgoff(file
, addr
, len
, prot
, flags
, pgoff
);
715 up_write(&mm
->mmap_sem
);
722 asmlinkage
long sys32_olduname(struct oldold_utsname __user
*name
)
724 char *arch
= "x86_64";
729 if (!access_ok(VERIFY_WRITE
, name
, sizeof(struct oldold_utsname
)))
734 err
= __copy_to_user(&name
->sysname
, &utsname()->sysname
,
736 err
|= __put_user(0, name
->sysname
+__OLD_UTS_LEN
);
737 err
|= __copy_to_user(&name
->nodename
, &utsname()->nodename
,
739 err
|= __put_user(0, name
->nodename
+__OLD_UTS_LEN
);
740 err
|= __copy_to_user(&name
->release
, &utsname()->release
,
742 err
|= __put_user(0, name
->release
+__OLD_UTS_LEN
);
743 err
|= __copy_to_user(&name
->version
, &utsname()->version
,
745 err
|= __put_user(0, name
->version
+__OLD_UTS_LEN
);
747 if (personality(current
->personality
) == PER_LINUX32
)
750 err
|= __copy_to_user(&name
->machine
, arch
, strlen(arch
) + 1);
754 err
= err
? -EFAULT
: 0;
759 long sys32_uname(struct old_utsname __user
*name
)
766 err
= copy_to_user(name
, utsname(), sizeof(*name
));
768 if (personality(current
->personality
) == PER_LINUX32
)
769 err
|= copy_to_user(&name
->machine
, "i686", 5);
771 return err
? -EFAULT
: 0;
774 long sys32_ustat(unsigned dev
, struct ustat32 __user
*u32p
)
782 ret
= sys_ustat(dev
, (struct ustat __user
*)&u
);
787 if (!access_ok(VERIFY_WRITE
, u32p
, sizeof(struct ustat32
)) ||
788 __put_user((__u32
) u
.f_tfree
, &u32p
->f_tfree
) ||
789 __put_user((__u32
) u
.f_tinode
, &u32p
->f_tfree
) ||
790 __copy_to_user(&u32p
->f_fname
, u
.f_fname
, sizeof(u
.f_fname
)) ||
791 __copy_to_user(&u32p
->f_fpack
, u
.f_fpack
, sizeof(u
.f_fpack
)))
796 asmlinkage
long sys32_execve(char __user
*name
, compat_uptr_t __user
*argv
,
797 compat_uptr_t __user
*envp
, struct pt_regs
*regs
)
802 filename
= getname(name
);
803 error
= PTR_ERR(filename
);
804 if (IS_ERR(filename
))
806 error
= compat_do_execve(filename
, argv
, envp
, regs
);
809 current
->ptrace
&= ~PT_DTRACE
;
810 task_unlock(current
);
816 asmlinkage
long sys32_clone(unsigned int clone_flags
, unsigned int newsp
,
817 struct pt_regs
*regs
)
819 void __user
*parent_tid
= (void __user
*)regs
->dx
;
820 void __user
*child_tid
= (void __user
*)regs
->di
;
824 return do_fork(clone_flags
, newsp
, regs
, 0, parent_tid
, child_tid
);
828 * Some system calls that need sign extended arguments. This could be
829 * done by a generic wrapper.
831 long sys32_lseek(unsigned int fd
, int offset
, unsigned int whence
)
833 return sys_lseek(fd
, offset
, whence
);
836 long sys32_kill(int pid
, int sig
)
838 return sys_kill(pid
, sig
);
841 long sys32_fadvise64_64(int fd
, __u32 offset_low
, __u32 offset_high
,
842 __u32 len_low
, __u32 len_high
, int advice
)
844 return sys_fadvise64_64(fd
,
845 (((u64
)offset_high
)<<32) | offset_low
,
846 (((u64
)len_high
)<<32) | len_low
,
850 long sys32_vm86_warning(void)
852 struct task_struct
*me
= current
;
853 static char lastcomm
[sizeof(me
->comm
)];
855 if (strncmp(lastcomm
, me
->comm
, sizeof(lastcomm
))) {
856 compat_printk(KERN_INFO
857 "%s: vm86 mode not supported on 64 bit kernel\n",
859 strncpy(lastcomm
, me
->comm
, sizeof(lastcomm
));
864 long sys32_lookup_dcookie(u32 addr_low
, u32 addr_high
,
865 char __user
*buf
, size_t len
)
867 return sys_lookup_dcookie(((u64
)addr_high
<< 32) | addr_low
, buf
, len
);
870 asmlinkage ssize_t
sys32_readahead(int fd
, unsigned off_lo
, unsigned off_hi
,
873 return sys_readahead(fd
, ((u64
)off_hi
<< 32) | off_lo
, count
);
876 asmlinkage
long sys32_sync_file_range(int fd
, unsigned off_low
, unsigned off_hi
,
877 unsigned n_low
, unsigned n_hi
, int flags
)
879 return sys_sync_file_range(fd
,
880 ((u64
)off_hi
<< 32) | off_low
,
881 ((u64
)n_hi
<< 32) | n_low
, flags
);
884 asmlinkage
long sys32_fadvise64(int fd
, unsigned offset_lo
, unsigned offset_hi
,
885 size_t len
, int advice
)
887 return sys_fadvise64_64(fd
, ((u64
)offset_hi
<< 32) | offset_lo
,
891 asmlinkage
long sys32_fallocate(int fd
, int mode
, unsigned offset_lo
,
892 unsigned offset_hi
, unsigned len_lo
,
895 return sys_fallocate(fd
, mode
, ((u64
)offset_hi
<< 32) | offset_lo
,
896 ((u64
)len_hi
<< 32) | len_lo
);