1 /* sys_sparc32.c: Conversion between 32bit and 64bit native syscalls.
3 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
4 * Copyright (C) 1997, 2007 David S. Miller (davem@davemloft.net)
6 * These routines maintain argument size conversion between 32bit and 64bit
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <linux/capability.h>
15 #include <linux/file.h>
16 #include <linux/signal.h>
17 #include <linux/resource.h>
18 #include <linux/times.h>
19 #include <linux/utsname.h>
20 #include <linux/smp.h>
21 #include <linux/smp_lock.h>
22 #include <linux/sem.h>
23 #include <linux/msg.h>
24 #include <linux/shm.h>
25 #include <linux/slab.h>
26 #include <linux/uio.h>
27 #include <linux/nfs_fs.h>
28 #include <linux/quota.h>
29 #include <linux/module.h>
30 #include <linux/sunrpc/svc.h>
31 #include <linux/nfsd/nfsd.h>
32 #include <linux/nfsd/cache.h>
33 #include <linux/nfsd/xdr.h>
34 #include <linux/nfsd/syscall.h>
35 #include <linux/poll.h>
36 #include <linux/personality.h>
37 #include <linux/stat.h>
38 #include <linux/filter.h>
39 #include <linux/highmem.h>
40 #include <linux/highuid.h>
41 #include <linux/mman.h>
42 #include <linux/ipv6.h>
44 #include <linux/icmpv6.h>
45 #include <linux/syscalls.h>
46 #include <linux/sysctl.h>
47 #include <linux/binfmts.h>
48 #include <linux/dnotify.h>
49 #include <linux/security.h>
50 #include <linux/compat.h>
51 #include <linux/vfs.h>
52 #include <linux/netfilter_ipv4/ip_tables.h>
53 #include <linux/ptrace.h>
54 #include <linux/highuid.h>
56 #include <asm/types.h>
57 #include <asm/uaccess.h>
58 #include <asm/fpumacro.h>
59 #include <asm/semaphore.h>
60 #include <asm/mmu_context.h>
61 #include <asm/a.out.h>
62 #include <asm/compat_signal.h>
64 asmlinkage long sys32_chown16(const char __user * filename, u16 user, u16 group)
66 return sys_chown(filename, low2highuid(user), low2highgid(group));
69 asmlinkage long sys32_lchown16(const char __user * filename, u16 user, u16 group)
71 return sys_lchown(filename, low2highuid(user), low2highgid(group));
74 asmlinkage long sys32_fchown16(unsigned int fd, u16 user, u16 group)
76 return sys_fchown(fd, low2highuid(user), low2highgid(group));
79 asmlinkage long sys32_setregid16(u16 rgid, u16 egid)
81 return sys_setregid(low2highgid(rgid), low2highgid(egid));
84 asmlinkage long sys32_setgid16(u16 gid)
86 return sys_setgid((gid_t)gid);
89 asmlinkage long sys32_setreuid16(u16 ruid, u16 euid)
91 return sys_setreuid(low2highuid(ruid), low2highuid(euid));
94 asmlinkage long sys32_setuid16(u16 uid)
96 return sys_setuid((uid_t)uid);
99 asmlinkage long sys32_setresuid16(u16 ruid, u16 euid, u16 suid)
101 return sys_setresuid(low2highuid(ruid), low2highuid(euid),
105 asmlinkage long sys32_getresuid16(u16 __user *ruid, u16 __user *euid, u16 __user *suid)
109 if (!(retval = put_user(high2lowuid(current->uid), ruid)) &&
110 !(retval = put_user(high2lowuid(current->euid), euid)))
111 retval = put_user(high2lowuid(current->suid), suid);
116 asmlinkage long sys32_setresgid16(u16 rgid, u16 egid, u16 sgid)
118 return sys_setresgid(low2highgid(rgid), low2highgid(egid),
122 asmlinkage long sys32_getresgid16(u16 __user *rgid, u16 __user *egid, u16 __user *sgid)
126 if (!(retval = put_user(high2lowgid(current->gid), rgid)) &&
127 !(retval = put_user(high2lowgid(current->egid), egid)))
128 retval = put_user(high2lowgid(current->sgid), sgid);
133 asmlinkage long sys32_setfsuid16(u16 uid)
135 return sys_setfsuid((uid_t)uid);
138 asmlinkage long sys32_setfsgid16(u16 gid)
140 return sys_setfsgid((gid_t)gid);
143 static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info)
148 for (i = 0; i < group_info->ngroups; i++) {
149 group = (u16)GROUP_AT(group_info, i);
150 if (put_user(group, grouplist+i))
157 static int groups16_from_user(struct group_info *group_info, u16 __user *grouplist)
162 for (i = 0; i < group_info->ngroups; i++) {
163 if (get_user(group, grouplist+i))
165 GROUP_AT(group_info, i) = (gid_t)group;
171 asmlinkage long sys32_getgroups16(int gidsetsize, u16 __user *grouplist)
178 get_group_info(current->group_info);
179 i = current->group_info->ngroups;
181 if (i > gidsetsize) {
185 if (groups16_to_user(grouplist, current->group_info)) {
191 put_group_info(current->group_info);
195 asmlinkage long sys32_setgroups16(int gidsetsize, u16 __user *grouplist)
197 struct group_info *group_info;
200 if (!capable(CAP_SETGID))
202 if ((unsigned)gidsetsize > NGROUPS_MAX)
205 group_info = groups_alloc(gidsetsize);
208 retval = groups16_from_user(group_info, grouplist);
210 put_group_info(group_info);
214 retval = set_current_groups(group_info);
215 put_group_info(group_info);
220 asmlinkage long sys32_getuid16(void)
222 return high2lowuid(current->uid);
225 asmlinkage long sys32_geteuid16(void)
227 return high2lowuid(current->euid);
230 asmlinkage long sys32_getgid16(void)
232 return high2lowgid(current->gid);
235 asmlinkage long sys32_getegid16(void)
237 return high2lowgid(current->egid);
240 /* 32-bit timeval and related flotsam. */
242 static long get_tv32(struct timeval *o, struct compat_timeval __user *i)
244 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
245 (__get_user(o->tv_sec, &i->tv_sec) |
246 __get_user(o->tv_usec, &i->tv_usec)));
249 static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
251 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
252 (__put_user(i->tv_sec, &o->tv_sec) |
253 __put_user(i->tv_usec, &o->tv_usec)));
256 #ifdef CONFIG_SYSVIPC
257 asmlinkage long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr, u32 fifth)
261 version = call >> 16; /* hack for backward compatibility */
267 /* sign extend semid */
268 return compat_sys_semtimedop((int)first,
269 compat_ptr(ptr), second,
271 /* else fall through for normal semop() */
273 /* struct sembuf is the same on 32 and 64bit :)) */
274 /* sign extend semid */
275 return sys_semtimedop((int)first, compat_ptr(ptr), second,
278 /* sign extend key, nsems */
279 return sys_semget((int)first, (int)second, third);
281 /* sign extend semid, semnum */
282 return compat_sys_semctl((int)first, (int)second, third,
286 /* sign extend msqid */
287 return compat_sys_msgsnd((int)first, (int)second, third,
290 /* sign extend msqid, msgtyp */
291 return compat_sys_msgrcv((int)first, second, (int)fifth,
292 third, version, compat_ptr(ptr));
294 /* sign extend key */
295 return sys_msgget((int)first, second);
297 /* sign extend msqid */
298 return compat_sys_msgctl((int)first, second, compat_ptr(ptr));
301 /* sign extend shmid */
302 return compat_sys_shmat((int)first, second, third, version,
305 return sys_shmdt(compat_ptr(ptr));
307 /* sign extend key_t */
308 return sys_shmget((int)first, second, third);
310 /* sign extend shmid */
311 return compat_sys_shmctl((int)first, second, compat_ptr(ptr));
321 asmlinkage long sys32_truncate64(const char __user * path, unsigned long high, unsigned long low)
326 return sys_truncate(path, (high << 32) | low);
329 asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long high, unsigned long low)
334 return sys_ftruncate(fd, (high << 32) | low);
337 int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
342 if (stat->size > MAX_NON_LFS || !old_valid_dev(stat->dev) ||
343 !old_valid_dev(stat->rdev))
347 if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
350 err = put_user(old_encode_dev(stat->dev), &statbuf->st_dev);
351 err |= put_user(stat->ino, &statbuf->st_ino);
352 err |= put_user(stat->mode, &statbuf->st_mode);
353 err |= put_user(stat->nlink, &statbuf->st_nlink);
354 err |= put_user(high2lowuid(stat->uid), &statbuf->st_uid);
355 err |= put_user(high2lowgid(stat->gid), &statbuf->st_gid);
356 err |= put_user(old_encode_dev(stat->rdev), &statbuf->st_rdev);
357 err |= put_user(stat->size, &statbuf->st_size);
358 err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
359 err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
360 err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
361 err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
362 err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
363 err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
364 err |= put_user(stat->blksize, &statbuf->st_blksize);
365 err |= put_user(stat->blocks, &statbuf->st_blocks);
366 err |= put_user(0, &statbuf->__unused4[0]);
367 err |= put_user(0, &statbuf->__unused4[1]);
372 int cp_compat_stat64(struct kstat *stat, struct compat_stat64 __user *statbuf)
376 err = put_user(huge_encode_dev(stat->dev), &statbuf->st_dev);
377 err |= put_user(stat->ino, &statbuf->st_ino);
378 err |= put_user(stat->mode, &statbuf->st_mode);
379 err |= put_user(stat->nlink, &statbuf->st_nlink);
380 err |= put_user(stat->uid, &statbuf->st_uid);
381 err |= put_user(stat->gid, &statbuf->st_gid);
382 err |= put_user(huge_encode_dev(stat->rdev), &statbuf->st_rdev);
383 err |= put_user(0, (unsigned long __user *) &statbuf->__pad3[0]);
384 err |= put_user(stat->size, &statbuf->st_size);
385 err |= put_user(stat->blksize, &statbuf->st_blksize);
386 err |= put_user(0, (unsigned int __user *) &statbuf->__pad4[0]);
387 err |= put_user(0, (unsigned int __user *) &statbuf->__pad4[4]);
388 err |= put_user(stat->blocks, &statbuf->st_blocks);
389 err |= put_user(stat->atime.tv_sec, &statbuf->st_atime);
390 err |= put_user(stat->atime.tv_nsec, &statbuf->st_atime_nsec);
391 err |= put_user(stat->mtime.tv_sec, &statbuf->st_mtime);
392 err |= put_user(stat->mtime.tv_nsec, &statbuf->st_mtime_nsec);
393 err |= put_user(stat->ctime.tv_sec, &statbuf->st_ctime);
394 err |= put_user(stat->ctime.tv_nsec, &statbuf->st_ctime_nsec);
395 err |= put_user(0, &statbuf->__unused4);
396 err |= put_user(0, &statbuf->__unused5);
401 asmlinkage long compat_sys_stat64(char __user * filename,
402 struct compat_stat64 __user *statbuf)
405 int error = vfs_stat(filename, &stat);
408 error = cp_compat_stat64(&stat, statbuf);
412 asmlinkage long compat_sys_lstat64(char __user * filename,
413 struct compat_stat64 __user *statbuf)
416 int error = vfs_lstat(filename, &stat);
419 error = cp_compat_stat64(&stat, statbuf);
423 asmlinkage long compat_sys_fstat64(unsigned int fd,
424 struct compat_stat64 __user * statbuf)
427 int error = vfs_fstat(fd, &stat);
430 error = cp_compat_stat64(&stat, statbuf);
434 asmlinkage long compat_sys_fstatat64(unsigned int dfd, char __user *filename,
435 struct compat_stat64 __user * statbuf, int flag)
440 if ((flag & ~AT_SYMLINK_NOFOLLOW) != 0)
443 if (flag & AT_SYMLINK_NOFOLLOW)
444 error = vfs_lstat_fd(dfd, filename, &stat);
446 error = vfs_stat_fd(dfd, filename, &stat);
449 error = cp_compat_stat64(&stat, statbuf);
455 asmlinkage long compat_sys_sysfs(int option, u32 arg1, u32 arg2)
457 return sys_sysfs(option, arg1, arg2);
460 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *interval)
464 mm_segment_t old_fs = get_fs ();
467 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *) &t);
469 if (put_compat_timespec(&t, interval))
474 asmlinkage long compat_sys_rt_sigprocmask(int how,
475 compat_sigset_t __user *set,
476 compat_sigset_t __user *oset,
477 compat_size_t sigsetsize)
482 mm_segment_t old_fs = get_fs();
485 if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
487 switch (_NSIG_WORDS) {
488 case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
489 case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);
490 case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);
491 case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);
495 ret = sys_rt_sigprocmask(how,
496 set ? (sigset_t __user *) &s : NULL,
497 oset ? (sigset_t __user *) &s : NULL,
502 switch (_NSIG_WORDS) {
503 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
504 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
505 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
506 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
508 if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
514 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
515 compat_size_t sigsetsize)
520 mm_segment_t old_fs = get_fs();
523 ret = sys_rt_sigpending((sigset_t __user *) &s, sigsetsize);
526 switch (_NSIG_WORDS) {
527 case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];
528 case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];
529 case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
530 case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
532 if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
538 asmlinkage long compat_sys_rt_sigqueueinfo(int pid, int sig,
539 struct compat_siginfo __user *uinfo)
543 mm_segment_t old_fs = get_fs();
545 if (copy_siginfo_from_user32(&info, uinfo))
549 ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *) &info);
554 asmlinkage long compat_sys_sigaction(int sig, struct old_sigaction32 __user *act,
555 struct old_sigaction32 __user *oact)
557 struct k_sigaction new_ka, old_ka;
561 set_thread_flag(TIF_NEWSIGNALS);
566 compat_old_sigset_t mask;
567 u32 u_handler, u_restorer;
569 ret = get_user(u_handler, &act->sa_handler);
570 new_ka.sa.sa_handler = compat_ptr(u_handler);
571 ret |= __get_user(u_restorer, &act->sa_restorer);
572 new_ka.sa.sa_restorer = compat_ptr(u_restorer);
573 ret |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
574 ret |= __get_user(mask, &act->sa_mask);
577 new_ka.ka_restorer = NULL;
578 siginitset(&new_ka.sa.sa_mask, mask);
581 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
584 ret = put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler);
585 ret |= __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer);
586 ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
587 ret |= __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
593 asmlinkage long compat_sys_rt_sigaction(int sig,
594 struct sigaction32 __user *act,
595 struct sigaction32 __user *oact,
596 void __user *restorer,
597 compat_size_t sigsetsize)
599 struct k_sigaction new_ka, old_ka;
601 compat_sigset_t set32;
603 /* XXX: Don't preclude handling different sized sigset_t's. */
604 if (sigsetsize != sizeof(compat_sigset_t))
607 /* All tasks which use RT signals (effectively) use
610 set_thread_flag(TIF_NEWSIGNALS);
613 u32 u_handler, u_restorer;
615 new_ka.ka_restorer = restorer;
616 ret = get_user(u_handler, &act->sa_handler);
617 new_ka.sa.sa_handler = compat_ptr(u_handler);
618 ret |= __copy_from_user(&set32, &act->sa_mask, sizeof(compat_sigset_t));
619 switch (_NSIG_WORDS) {
620 case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6] | (((long)set32.sig[7]) << 32);
621 case 3: new_ka.sa.sa_mask.sig[2] = set32.sig[4] | (((long)set32.sig[5]) << 32);
622 case 2: new_ka.sa.sa_mask.sig[1] = set32.sig[2] | (((long)set32.sig[3]) << 32);
623 case 1: new_ka.sa.sa_mask.sig[0] = set32.sig[0] | (((long)set32.sig[1]) << 32);
625 ret |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
626 ret |= __get_user(u_restorer, &act->sa_restorer);
627 new_ka.sa.sa_restorer = compat_ptr(u_restorer);
632 ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
635 switch (_NSIG_WORDS) {
636 case 4: set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32); set32.sig[6] = old_ka.sa.sa_mask.sig[3];
637 case 3: set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32); set32.sig[4] = old_ka.sa.sa_mask.sig[2];
638 case 2: set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32); set32.sig[2] = old_ka.sa.sa_mask.sig[1];
639 case 1: set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32); set32.sig[0] = old_ka.sa.sa_mask.sig[0];
641 ret = put_user(ptr_to_compat(old_ka.sa.sa_handler), &oact->sa_handler);
642 ret |= __copy_to_user(&oact->sa_mask, &set32, sizeof(compat_sigset_t));
643 ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
644 ret |= __put_user(ptr_to_compat(old_ka.sa.sa_restorer), &oact->sa_restorer);
653 * sparc32_execve() executes a new program after the asm stub has set
654 * things up for us. This should basically do what I want it to.
656 asmlinkage long sparc32_execve(struct pt_regs *regs)
661 /* User register window flush is done by entry.S */
663 /* Check for indirect call. */
664 if ((u32)regs->u_regs[UREG_G1] == 0)
667 filename = getname(compat_ptr(regs->u_regs[base + UREG_I0]));
668 error = PTR_ERR(filename);
669 if (IS_ERR(filename))
672 error = compat_do_execve(filename,
673 compat_ptr(regs->u_regs[base + UREG_I1]),
674 compat_ptr(regs->u_regs[base + UREG_I2]), regs);
680 current_thread_info()->xfsr[0] = 0;
681 current_thread_info()->fpsaved[0] = 0;
682 regs->tstate &= ~TSTATE_PEF;
684 current->ptrace &= ~PT_DTRACE;
685 task_unlock(current);
691 #ifdef CONFIG_MODULES
693 asmlinkage long sys32_init_module(void __user *umod, u32 len,
694 const char __user *uargs)
696 return sys_init_module(umod, len, uargs);
699 asmlinkage long sys32_delete_module(const char __user *name_user,
702 return sys_delete_module(name_user, flags);
705 #else /* CONFIG_MODULES */
707 asmlinkage long sys32_init_module(const char __user *name_user,
708 struct module __user *mod_user)
713 asmlinkage long sys32_delete_module(const char __user *name_user)
718 #endif /* CONFIG_MODULES */
720 /* Translations due to time_t size differences. Which affects all
721 sorts of things, like timeval and itimerval. */
723 extern struct timezone sys_tz;
725 asmlinkage long sys32_gettimeofday(struct compat_timeval __user *tv,
726 struct timezone __user *tz)
730 do_gettimeofday(&ktv);
731 if (put_tv32(tv, &ktv))
735 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
741 static inline long get_ts32(struct timespec *o, struct compat_timeval __user *i)
745 if (!access_ok(VERIFY_READ, i, sizeof(*i)))
747 if (__get_user(o->tv_sec, &i->tv_sec))
749 if (__get_user(usec, &i->tv_usec))
751 o->tv_nsec = usec * 1000;
755 asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv,
756 struct timezone __user *tz)
762 if (get_ts32(&kts, tv))
766 if (copy_from_user(&ktz, tz, sizeof(ktz)))
770 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
773 asmlinkage long sys32_utimes(char __user *filename,
774 struct compat_timeval __user *tvs)
776 struct timespec tv[2];
779 struct timeval ktvs[2];
780 if (get_tv32(&ktvs[0], tvs) ||
781 get_tv32(&ktvs[1], 1+tvs))
784 if (ktvs[0].tv_usec < 0 || ktvs[0].tv_usec >= 1000000 ||
785 ktvs[1].tv_usec < 0 || ktvs[1].tv_usec >= 1000000)
788 tv[0].tv_sec = ktvs[0].tv_sec;
789 tv[0].tv_nsec = 1000 * ktvs[0].tv_usec;
790 tv[1].tv_sec = ktvs[1].tv_sec;
791 tv[1].tv_nsec = 1000 * ktvs[1].tv_usec;
794 return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
797 /* These are here just in case some old sparc32 binary calls it. */
798 asmlinkage long sys32_pause(void)
800 current->state = TASK_INTERRUPTIBLE;
802 return -ERESTARTNOHAND;
805 asmlinkage compat_ssize_t sys32_pread64(unsigned int fd,
811 return sys_pread64(fd, ubuf, count, (poshi << 32) | poslo);
814 asmlinkage compat_ssize_t sys32_pwrite64(unsigned int fd,
820 return sys_pwrite64(fd, ubuf, count, (poshi << 32) | poslo);
823 asmlinkage long compat_sys_readahead(int fd,
828 return sys_readahead(fd, (offhi << 32) | offlo, count);
831 long compat_sys_fadvise64(int fd,
834 compat_size_t len, int advice)
836 return sys_fadvise64_64(fd, (offhi << 32) | offlo, len, advice);
839 long compat_sys_fadvise64_64(int fd,
840 unsigned long offhi, unsigned long offlo,
841 unsigned long lenhi, unsigned long lenlo,
844 return sys_fadvise64_64(fd,
845 (offhi << 32) | offlo,
846 (lenhi << 32) | lenlo,
850 asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
851 compat_off_t __user *offset,
854 mm_segment_t old_fs = get_fs();
858 if (offset && get_user(of, offset))
862 ret = sys_sendfile(out_fd, in_fd,
863 offset ? (off_t __user *) &of : NULL,
867 if (offset && put_user(of, offset))
873 asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
874 compat_loff_t __user *offset,
877 mm_segment_t old_fs = get_fs();
881 if (offset && get_user(lof, offset))
885 ret = sys_sendfile64(out_fd, in_fd,
886 offset ? (loff_t __user *) &lof : NULL,
890 if (offset && put_user(lof, offset))
896 /* This is just a version for 32-bit applications which does
897 * not force O_LARGEFILE on.
900 asmlinkage long sparc32_open(const char __user *filename,
903 return do_sys_open(AT_FDCWD, filename, flags, mode);
906 extern unsigned long do_mremap(unsigned long addr,
907 unsigned long old_len, unsigned long new_len,
908 unsigned long flags, unsigned long new_addr);
910 asmlinkage unsigned long sys32_mremap(unsigned long addr,
911 unsigned long old_len, unsigned long new_len,
912 unsigned long flags, u32 __new_addr)
914 struct vm_area_struct *vma;
915 unsigned long ret = -EINVAL;
916 unsigned long new_addr = __new_addr;
918 if (old_len > STACK_TOP32 || new_len > STACK_TOP32)
920 if (addr > STACK_TOP32 - old_len)
922 down_write(¤t->mm->mmap_sem);
923 if (flags & MREMAP_FIXED) {
924 if (new_addr > STACK_TOP32 - new_len)
926 } else if (addr > STACK_TOP32 - new_len) {
927 unsigned long map_flags = 0;
928 struct file *file = NULL;
931 if (!(flags & MREMAP_MAYMOVE))
934 vma = find_vma(current->mm, addr);
936 if (vma->vm_flags & VM_SHARED)
937 map_flags |= MAP_SHARED;
941 /* MREMAP_FIXED checked above. */
942 new_addr = get_unmapped_area(file, addr, new_len,
943 vma ? vma->vm_pgoff : 0,
946 if (new_addr & ~PAGE_MASK)
948 flags |= MREMAP_FIXED;
950 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
952 up_write(¤t->mm->mmap_sem);
957 struct __sysctl_args32 {
967 asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
969 #ifndef CONFIG_SYSCTL_SYSCALL
972 struct __sysctl_args32 tmp;
974 size_t oldlen, __user *oldlenp = NULL;
975 unsigned long addr = (((unsigned long)&args->__unused[0]) + 7UL) & ~7UL;
977 if (copy_from_user(&tmp, args, sizeof(tmp)))
980 if (tmp.oldval && tmp.oldlenp) {
981 /* Duh, this is ugly and might not work if sysctl_args
982 is in read-only memory, but do_sysctl does indirectly
983 a lot of uaccess in both directions and we'd have to
984 basically copy the whole sysctl.c here, and
985 glibc's __sysctl uses rw memory for the structure
987 if (get_user(oldlen, (u32 __user *)(unsigned long)tmp.oldlenp) ||
988 put_user(oldlen, (size_t __user *)addr))
990 oldlenp = (size_t __user *)addr;
994 error = do_sysctl((int __user *)(unsigned long) tmp.name,
996 (void __user *)(unsigned long) tmp.oldval,
998 (void __user *)(unsigned long) tmp.newval,
1003 if (get_user(oldlen, (size_t __user *)addr) ||
1004 put_user(oldlen, (u32 __user *)(unsigned long) tmp.oldlenp))
1007 if (copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused)))
1014 long sys32_lookup_dcookie(unsigned long cookie_high,
1015 unsigned long cookie_low,
1016 char __user *buf, size_t len)
1018 return sys_lookup_dcookie((cookie_high << 32) | cookie_low,
1022 long compat_sync_file_range(int fd, unsigned long off_high, unsigned long off_low, unsigned long nb_high, unsigned long nb_low, int flags)
1024 return sys_sync_file_range(fd,
1025 (off_high << 32) | off_low,
1026 (nb_high << 32) | nb_low,
1030 asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
1031 u32 lenhi, u32 lenlo)
1033 return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
1034 ((loff_t)lenhi << 32) | lenlo);