2 * linux/kernel/compat.c
4 * Kernel compatibililty routines for e.g. 32 bit syscall support
7 * Copyright (C) 2002-2003 Stephen Rothwell, IBM Corporation
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/linkage.h>
15 #include <linux/compat.h>
16 #include <linux/errno.h>
17 #include <linux/time.h>
18 #include <linux/signal.h>
19 #include <linux/sched.h> /* for MAX_SCHEDULE_TIMEOUT */
20 #include <linux/syscalls.h>
21 #include <linux/unistd.h>
22 #include <linux/security.h>
23 #include <linux/timex.h>
24 #include <linux/migrate.h>
25 #include <linux/posix-timers.h>
27 #include <asm/uaccess.h>
29 int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
31 return (!access_ok(VERIFY_READ, cts, sizeof(*cts)) ||
32 __get_user(ts->tv_sec, &cts->tv_sec) ||
33 __get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
36 int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user *cts)
38 return (!access_ok(VERIFY_WRITE, cts, sizeof(*cts)) ||
39 __put_user(ts->tv_sec, &cts->tv_sec) ||
40 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
43 static long compat_nanosleep_restart(struct restart_block *restart)
45 struct compat_timespec __user *rmtp;
50 restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
53 ret = hrtimer_nanosleep_restart(restart);
57 rmtp = restart->nanosleep.compat_rmtp;
59 if (rmtp && put_compat_timespec(&rmt, rmtp))
66 asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
67 struct compat_timespec __user *rmtp)
69 struct timespec tu, rmt;
73 if (get_compat_timespec(&tu, rqtp))
76 if (!timespec_valid(&tu))
81 ret = hrtimer_nanosleep(&tu,
82 rmtp ? (struct timespec __user *)&rmt : NULL,
83 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
87 struct restart_block *restart
88 = ¤t_thread_info()->restart_block;
90 restart->fn = compat_nanosleep_restart;
91 restart->nanosleep.compat_rmtp = rmtp;
93 if (rmtp && put_compat_timespec(&rmt, rmtp))
100 static inline long get_compat_itimerval(struct itimerval *o,
101 struct compat_itimerval __user *i)
103 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
104 (__get_user(o->it_interval.tv_sec, &i->it_interval.tv_sec) |
105 __get_user(o->it_interval.tv_usec, &i->it_interval.tv_usec) |
106 __get_user(o->it_value.tv_sec, &i->it_value.tv_sec) |
107 __get_user(o->it_value.tv_usec, &i->it_value.tv_usec)));
110 static inline long put_compat_itimerval(struct compat_itimerval __user *o,
113 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
114 (__put_user(i->it_interval.tv_sec, &o->it_interval.tv_sec) |
115 __put_user(i->it_interval.tv_usec, &o->it_interval.tv_usec) |
116 __put_user(i->it_value.tv_sec, &o->it_value.tv_sec) |
117 __put_user(i->it_value.tv_usec, &o->it_value.tv_usec)));
120 asmlinkage long compat_sys_getitimer(int which,
121 struct compat_itimerval __user *it)
123 struct itimerval kit;
126 error = do_getitimer(which, &kit);
127 if (!error && put_compat_itimerval(it, &kit))
132 asmlinkage long compat_sys_setitimer(int which,
133 struct compat_itimerval __user *in,
134 struct compat_itimerval __user *out)
136 struct itimerval kin, kout;
140 if (get_compat_itimerval(&kin, in))
143 memset(&kin, 0, sizeof(kin));
145 error = do_setitimer(which, &kin, out ? &kout : NULL);
148 if (put_compat_itimerval(out, &kout))
153 asmlinkage long compat_sys_times(struct compat_tms __user *tbuf)
156 * In the SMP world we might just be unlucky and have one of
157 * the times increment as we use it. Since the value is an
158 * atomically safe type this is just fine. Conceptually its
159 * as if the syscall took an instant longer to occur.
162 struct compat_tms tmp;
163 struct task_struct *tsk = current;
164 struct task_struct *t;
165 cputime_t utime, stime, cutime, cstime;
167 read_lock(&tasklist_lock);
168 utime = tsk->signal->utime;
169 stime = tsk->signal->stime;
172 utime = cputime_add(utime, t->utime);
173 stime = cputime_add(stime, t->stime);
178 * While we have tasklist_lock read-locked, no dying thread
179 * can be updating current->signal->[us]time. Instead,
180 * we got their counts included in the live thread loop.
181 * However, another thread can come in right now and
182 * do a wait call that updates current->signal->c[us]time.
183 * To make sure we always see that pair updated atomically,
184 * we take the siglock around fetching them.
186 spin_lock_irq(&tsk->sighand->siglock);
187 cutime = tsk->signal->cutime;
188 cstime = tsk->signal->cstime;
189 spin_unlock_irq(&tsk->sighand->siglock);
190 read_unlock(&tasklist_lock);
192 tmp.tms_utime = compat_jiffies_to_clock_t(cputime_to_jiffies(utime));
193 tmp.tms_stime = compat_jiffies_to_clock_t(cputime_to_jiffies(stime));
194 tmp.tms_cutime = compat_jiffies_to_clock_t(cputime_to_jiffies(cutime));
195 tmp.tms_cstime = compat_jiffies_to_clock_t(cputime_to_jiffies(cstime));
196 if (copy_to_user(tbuf, &tmp, sizeof(tmp)))
199 return compat_jiffies_to_clock_t(jiffies);
203 * Assumption: old_sigset_t and compat_old_sigset_t are both
204 * types that can be passed to put_user()/get_user().
207 asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
211 mm_segment_t old_fs = get_fs();
214 ret = sys_sigpending((old_sigset_t __user *) &s);
217 ret = put_user(s, set);
221 asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *set,
222 compat_old_sigset_t __user *oset)
228 if (set && get_user(s, set))
232 ret = sys_sigprocmask(how,
233 set ? (old_sigset_t __user *) &s : NULL,
234 oset ? (old_sigset_t __user *) &s : NULL);
238 ret = put_user(s, oset);
242 asmlinkage long compat_sys_setrlimit(unsigned int resource,
243 struct compat_rlimit __user *rlim)
247 mm_segment_t old_fs = get_fs ();
249 if (resource >= RLIM_NLIMITS)
252 if (!access_ok(VERIFY_READ, rlim, sizeof(*rlim)) ||
253 __get_user(r.rlim_cur, &rlim->rlim_cur) ||
254 __get_user(r.rlim_max, &rlim->rlim_max))
257 if (r.rlim_cur == COMPAT_RLIM_INFINITY)
258 r.rlim_cur = RLIM_INFINITY;
259 if (r.rlim_max == COMPAT_RLIM_INFINITY)
260 r.rlim_max = RLIM_INFINITY;
262 ret = sys_setrlimit(resource, (struct rlimit __user *) &r);
267 #ifdef COMPAT_RLIM_OLD_INFINITY
269 asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
270 struct compat_rlimit __user *rlim)
274 mm_segment_t old_fs = get_fs();
277 ret = sys_old_getrlimit(resource, &r);
281 if (r.rlim_cur > COMPAT_RLIM_OLD_INFINITY)
282 r.rlim_cur = COMPAT_RLIM_INFINITY;
283 if (r.rlim_max > COMPAT_RLIM_OLD_INFINITY)
284 r.rlim_max = COMPAT_RLIM_INFINITY;
286 if (!access_ok(VERIFY_WRITE, rlim, sizeof(*rlim)) ||
287 __put_user(r.rlim_cur, &rlim->rlim_cur) ||
288 __put_user(r.rlim_max, &rlim->rlim_max))
296 asmlinkage long compat_sys_getrlimit (unsigned int resource,
297 struct compat_rlimit __user *rlim)
301 mm_segment_t old_fs = get_fs();
304 ret = sys_getrlimit(resource, (struct rlimit __user *) &r);
307 if (r.rlim_cur > COMPAT_RLIM_INFINITY)
308 r.rlim_cur = COMPAT_RLIM_INFINITY;
309 if (r.rlim_max > COMPAT_RLIM_INFINITY)
310 r.rlim_max = COMPAT_RLIM_INFINITY;
312 if (!access_ok(VERIFY_WRITE, rlim, sizeof(*rlim)) ||
313 __put_user(r.rlim_cur, &rlim->rlim_cur) ||
314 __put_user(r.rlim_max, &rlim->rlim_max))
320 int put_compat_rusage(const struct rusage *r, struct compat_rusage __user *ru)
322 if (!access_ok(VERIFY_WRITE, ru, sizeof(*ru)) ||
323 __put_user(r->ru_utime.tv_sec, &ru->ru_utime.tv_sec) ||
324 __put_user(r->ru_utime.tv_usec, &ru->ru_utime.tv_usec) ||
325 __put_user(r->ru_stime.tv_sec, &ru->ru_stime.tv_sec) ||
326 __put_user(r->ru_stime.tv_usec, &ru->ru_stime.tv_usec) ||
327 __put_user(r->ru_maxrss, &ru->ru_maxrss) ||
328 __put_user(r->ru_ixrss, &ru->ru_ixrss) ||
329 __put_user(r->ru_idrss, &ru->ru_idrss) ||
330 __put_user(r->ru_isrss, &ru->ru_isrss) ||
331 __put_user(r->ru_minflt, &ru->ru_minflt) ||
332 __put_user(r->ru_majflt, &ru->ru_majflt) ||
333 __put_user(r->ru_nswap, &ru->ru_nswap) ||
334 __put_user(r->ru_inblock, &ru->ru_inblock) ||
335 __put_user(r->ru_oublock, &ru->ru_oublock) ||
336 __put_user(r->ru_msgsnd, &ru->ru_msgsnd) ||
337 __put_user(r->ru_msgrcv, &ru->ru_msgrcv) ||
338 __put_user(r->ru_nsignals, &ru->ru_nsignals) ||
339 __put_user(r->ru_nvcsw, &ru->ru_nvcsw) ||
340 __put_user(r->ru_nivcsw, &ru->ru_nivcsw))
345 asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
349 mm_segment_t old_fs = get_fs();
352 ret = sys_getrusage(who, (struct rusage __user *) &r);
358 if (put_compat_rusage(&r, ru))
365 compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options,
366 struct compat_rusage __user *ru)
369 return sys_wait4(pid, stat_addr, options, NULL);
374 mm_segment_t old_fs = get_fs();
379 (unsigned int __user *) &status : NULL),
380 options, (struct rusage __user *) &r);
384 if (put_compat_rusage(&r, ru))
386 if (stat_addr && put_user(status, stat_addr))
393 asmlinkage long compat_sys_waitid(int which, compat_pid_t pid,
394 struct compat_siginfo __user *uinfo, int options,
395 struct compat_rusage __user *uru)
400 mm_segment_t old_fs = get_fs();
402 memset(&info, 0, sizeof(info));
405 ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
406 uru ? (struct rusage __user *)&ru : NULL);
409 if ((ret < 0) || (info.si_signo == 0))
413 ret = put_compat_rusage(&ru, uru);
418 BUG_ON(info.si_code & __SI_MASK);
419 info.si_code |= __SI_CHLD;
420 return copy_siginfo_to_user32(uinfo, &info);
423 static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
424 unsigned len, cpumask_t *new_mask)
428 if (len < sizeof(cpumask_t))
429 memset(new_mask, 0, sizeof(cpumask_t));
430 else if (len > sizeof(cpumask_t))
431 len = sizeof(cpumask_t);
433 k = cpus_addr(*new_mask);
434 return compat_get_bitmap(k, user_mask_ptr, len * 8);
437 asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
439 compat_ulong_t __user *user_mask_ptr)
444 retval = compat_get_user_cpu_mask(user_mask_ptr, len, &new_mask);
448 return sched_setaffinity(pid, &new_mask);
451 asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, unsigned int len,
452 compat_ulong_t __user *user_mask_ptr)
457 unsigned int min_length = sizeof(cpumask_t);
459 if (NR_CPUS <= BITS_PER_COMPAT_LONG)
460 min_length = sizeof(compat_ulong_t);
462 if (len < min_length)
465 ret = sched_getaffinity(pid, &mask);
470 ret = compat_put_bitmap(user_mask_ptr, k, min_length * 8);
477 int get_compat_itimerspec(struct itimerspec *dst,
478 const struct compat_itimerspec __user *src)
480 if (get_compat_timespec(&dst->it_interval, &src->it_interval) ||
481 get_compat_timespec(&dst->it_value, &src->it_value))
486 int put_compat_itimerspec(struct compat_itimerspec __user *dst,
487 const struct itimerspec *src)
489 if (put_compat_timespec(&src->it_interval, &dst->it_interval) ||
490 put_compat_timespec(&src->it_value, &dst->it_value))
495 long compat_sys_timer_create(clockid_t which_clock,
496 struct compat_sigevent __user *timer_event_spec,
497 timer_t __user *created_timer_id)
499 struct sigevent __user *event = NULL;
501 if (timer_event_spec) {
502 struct sigevent kevent;
504 event = compat_alloc_user_space(sizeof(*event));
505 if (get_compat_sigevent(&kevent, timer_event_spec) ||
506 copy_to_user(event, &kevent, sizeof(*event)))
510 return sys_timer_create(which_clock, event, created_timer_id);
513 long compat_sys_timer_settime(timer_t timer_id, int flags,
514 struct compat_itimerspec __user *new,
515 struct compat_itimerspec __user *old)
519 struct itimerspec newts, oldts;
523 if (get_compat_itimerspec(&newts, new))
527 err = sys_timer_settime(timer_id, flags,
528 (struct itimerspec __user *) &newts,
529 (struct itimerspec __user *) &oldts);
531 if (!err && old && put_compat_itimerspec(old, &oldts))
536 long compat_sys_timer_gettime(timer_t timer_id,
537 struct compat_itimerspec __user *setting)
541 struct itimerspec ts;
545 err = sys_timer_gettime(timer_id,
546 (struct itimerspec __user *) &ts);
548 if (!err && put_compat_itimerspec(setting, &ts))
553 long compat_sys_clock_settime(clockid_t which_clock,
554 struct compat_timespec __user *tp)
560 if (get_compat_timespec(&ts, tp))
564 err = sys_clock_settime(which_clock,
565 (struct timespec __user *) &ts);
570 long compat_sys_clock_gettime(clockid_t which_clock,
571 struct compat_timespec __user *tp)
579 err = sys_clock_gettime(which_clock,
580 (struct timespec __user *) &ts);
582 if (!err && put_compat_timespec(&ts, tp))
587 long compat_sys_clock_getres(clockid_t which_clock,
588 struct compat_timespec __user *tp)
596 err = sys_clock_getres(which_clock,
597 (struct timespec __user *) &ts);
599 if (!err && tp && put_compat_timespec(&ts, tp))
604 static long compat_clock_nanosleep_restart(struct restart_block *restart)
609 struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
611 restart->nanosleep.rmtp = (struct timespec __user *) &tu;
614 err = clock_nanosleep_restart(restart);
617 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
618 put_compat_timespec(&tu, rmtp))
621 if (err == -ERESTART_RESTARTBLOCK) {
622 restart->fn = compat_clock_nanosleep_restart;
623 restart->nanosleep.compat_rmtp = rmtp;
628 long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
629 struct compat_timespec __user *rqtp,
630 struct compat_timespec __user *rmtp)
634 struct timespec in, out;
635 struct restart_block *restart;
637 if (get_compat_timespec(&in, rqtp))
642 err = sys_clock_nanosleep(which_clock, flags,
643 (struct timespec __user *) &in,
644 (struct timespec __user *) &out);
647 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
648 put_compat_timespec(&out, rmtp))
651 if (err == -ERESTART_RESTARTBLOCK) {
652 restart = ¤t_thread_info()->restart_block;
653 restart->fn = compat_clock_nanosleep_restart;
654 restart->nanosleep.compat_rmtp = rmtp;
660 * We currently only need the following fields from the sigevent
661 * structure: sigev_value, sigev_signo, sig_notify and (sometimes
662 * sigev_notify_thread_id). The others are handled in user mode.
663 * We also assume that copying sigev_value.sival_int is sufficient
664 * to keep all the bits of sigev_value.sival_ptr intact.
666 int get_compat_sigevent(struct sigevent *event,
667 const struct compat_sigevent __user *u_event)
669 memset(event, 0, sizeof(*event));
670 return (!access_ok(VERIFY_READ, u_event, sizeof(*u_event)) ||
671 __get_user(event->sigev_value.sival_int,
672 &u_event->sigev_value.sival_int) ||
673 __get_user(event->sigev_signo, &u_event->sigev_signo) ||
674 __get_user(event->sigev_notify, &u_event->sigev_notify) ||
675 __get_user(event->sigev_notify_thread_id,
676 &u_event->sigev_notify_thread_id))
680 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
681 unsigned long bitmap_size)
686 unsigned long nr_compat_longs;
688 /* align bitmap up to nearest compat_long_t boundary */
689 bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
691 if (!access_ok(VERIFY_READ, umask, bitmap_size / 8))
694 nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
696 for (i = 0; i < BITS_TO_LONGS(bitmap_size); i++) {
699 for (j = 0; j < sizeof(m)/sizeof(um); j++) {
701 * We dont want to read past the end of the userspace
702 * bitmap. We must however ensure the end of the
703 * kernel bitmap is zeroed.
705 if (nr_compat_longs-- > 0) {
706 if (__get_user(um, umask))
713 m |= (long)um << (j * BITS_PER_COMPAT_LONG);
721 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
722 unsigned long bitmap_size)
727 unsigned long nr_compat_longs;
729 /* align bitmap up to nearest compat_long_t boundary */
730 bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
732 if (!access_ok(VERIFY_WRITE, umask, bitmap_size / 8))
735 nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
737 for (i = 0; i < BITS_TO_LONGS(bitmap_size); i++) {
740 for (j = 0; j < sizeof(m)/sizeof(um); j++) {
744 * We dont want to write past the end of the userspace
747 if (nr_compat_longs-- > 0) {
748 if (__put_user(um, umask))
762 sigset_from_compat (sigset_t *set, compat_sigset_t *compat)
764 switch (_NSIG_WORDS) {
765 case 4: set->sig[3] = compat->sig[6] | (((long)compat->sig[7]) << 32 );
766 case 3: set->sig[2] = compat->sig[4] | (((long)compat->sig[5]) << 32 );
767 case 2: set->sig[1] = compat->sig[2] | (((long)compat->sig[3]) << 32 );
768 case 1: set->sig[0] = compat->sig[0] | (((long)compat->sig[1]) << 32 );
773 compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese,
774 struct compat_siginfo __user *uinfo,
775 struct compat_timespec __user *uts, compat_size_t sigsetsize)
782 long ret, timeout = 0;
784 if (sigsetsize != sizeof(sigset_t))
787 if (copy_from_user(&s32, uthese, sizeof(compat_sigset_t)))
789 sigset_from_compat(&s, &s32);
790 sigdelsetmask(&s,sigmask(SIGKILL)|sigmask(SIGSTOP));
794 if (get_compat_timespec (&t, uts))
796 if (t.tv_nsec >= 1000000000L || t.tv_nsec < 0
801 spin_lock_irq(¤t->sighand->siglock);
802 sig = dequeue_signal(current, &s, &info);
804 timeout = MAX_SCHEDULE_TIMEOUT;
806 timeout = timespec_to_jiffies(&t)
807 +(t.tv_sec || t.tv_nsec);
809 current->real_blocked = current->blocked;
810 sigandsets(¤t->blocked, ¤t->blocked, &s);
813 spin_unlock_irq(¤t->sighand->siglock);
815 timeout = schedule_timeout_interruptible(timeout);
817 spin_lock_irq(¤t->sighand->siglock);
818 sig = dequeue_signal(current, &s, &info);
819 current->blocked = current->real_blocked;
820 siginitset(¤t->real_blocked, 0);
824 spin_unlock_irq(¤t->sighand->siglock);
829 if (copy_siginfo_to_user32(uinfo, &info))
833 ret = timeout?-EINTR:-EAGAIN;
839 #ifdef __ARCH_WANT_COMPAT_SYS_TIME
841 /* compat_time_t is a 32 bit "long" and needs to get converted. */
843 asmlinkage long compat_sys_time(compat_time_t __user * tloc)
848 do_gettimeofday(&tv);
852 if (put_user(i,tloc))
858 asmlinkage long compat_sys_stime(compat_time_t __user *tptr)
863 if (get_user(tv.tv_sec, tptr))
868 err = security_settime(&tv, NULL);
872 do_settimeofday(&tv);
876 #endif /* __ARCH_WANT_COMPAT_SYS_TIME */
878 #ifdef __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
879 asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, compat_size_t sigsetsize)
882 compat_sigset_t newset32;
884 /* XXX: Don't preclude handling different sized sigset_t's. */
885 if (sigsetsize != sizeof(sigset_t))
888 if (copy_from_user(&newset32, unewset, sizeof(compat_sigset_t)))
890 sigset_from_compat(&newset, &newset32);
891 sigdelsetmask(&newset, sigmask(SIGKILL)|sigmask(SIGSTOP));
893 spin_lock_irq(¤t->sighand->siglock);
894 current->saved_sigmask = current->blocked;
895 current->blocked = newset;
897 spin_unlock_irq(¤t->sighand->siglock);
899 current->state = TASK_INTERRUPTIBLE;
901 set_thread_flag(TIF_RESTORE_SIGMASK);
902 return -ERESTARTNOHAND;
904 #endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */
906 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp)
911 memset(&txc, 0, sizeof(struct timex));
913 if (!access_ok(VERIFY_READ, utp, sizeof(struct compat_timex)) ||
914 __get_user(txc.modes, &utp->modes) ||
915 __get_user(txc.offset, &utp->offset) ||
916 __get_user(txc.freq, &utp->freq) ||
917 __get_user(txc.maxerror, &utp->maxerror) ||
918 __get_user(txc.esterror, &utp->esterror) ||
919 __get_user(txc.status, &utp->status) ||
920 __get_user(txc.constant, &utp->constant) ||
921 __get_user(txc.precision, &utp->precision) ||
922 __get_user(txc.tolerance, &utp->tolerance) ||
923 __get_user(txc.time.tv_sec, &utp->time.tv_sec) ||
924 __get_user(txc.time.tv_usec, &utp->time.tv_usec) ||
925 __get_user(txc.tick, &utp->tick) ||
926 __get_user(txc.ppsfreq, &utp->ppsfreq) ||
927 __get_user(txc.jitter, &utp->jitter) ||
928 __get_user(txc.shift, &utp->shift) ||
929 __get_user(txc.stabil, &utp->stabil) ||
930 __get_user(txc.jitcnt, &utp->jitcnt) ||
931 __get_user(txc.calcnt, &utp->calcnt) ||
932 __get_user(txc.errcnt, &utp->errcnt) ||
933 __get_user(txc.stbcnt, &utp->stbcnt))
936 ret = do_adjtimex(&txc);
938 if (!access_ok(VERIFY_WRITE, utp, sizeof(struct compat_timex)) ||
939 __put_user(txc.modes, &utp->modes) ||
940 __put_user(txc.offset, &utp->offset) ||
941 __put_user(txc.freq, &utp->freq) ||
942 __put_user(txc.maxerror, &utp->maxerror) ||
943 __put_user(txc.esterror, &utp->esterror) ||
944 __put_user(txc.status, &utp->status) ||
945 __put_user(txc.constant, &utp->constant) ||
946 __put_user(txc.precision, &utp->precision) ||
947 __put_user(txc.tolerance, &utp->tolerance) ||
948 __put_user(txc.time.tv_sec, &utp->time.tv_sec) ||
949 __put_user(txc.time.tv_usec, &utp->time.tv_usec) ||
950 __put_user(txc.tick, &utp->tick) ||
951 __put_user(txc.ppsfreq, &utp->ppsfreq) ||
952 __put_user(txc.jitter, &utp->jitter) ||
953 __put_user(txc.shift, &utp->shift) ||
954 __put_user(txc.stabil, &utp->stabil) ||
955 __put_user(txc.jitcnt, &utp->jitcnt) ||
956 __put_user(txc.calcnt, &utp->calcnt) ||
957 __put_user(txc.errcnt, &utp->errcnt) ||
958 __put_user(txc.stbcnt, &utp->stbcnt))
965 asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,
966 compat_uptr_t __user *pages32,
967 const int __user *nodes,
971 const void __user * __user *pages;
974 pages = compat_alloc_user_space(nr_pages * sizeof(void *));
975 for (i = 0; i < nr_pages; i++) {
978 if (get_user(p, pages32 + i) ||
979 put_user(compat_ptr(p), pages + i))
982 return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
985 asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
986 compat_ulong_t maxnode,
987 const compat_ulong_t __user *old_nodes,
988 const compat_ulong_t __user *new_nodes)
990 unsigned long __user *old = NULL;
991 unsigned long __user *new = NULL;
993 unsigned long nr_bits;
996 nr_bits = min_t(unsigned long, maxnode - 1, MAX_NUMNODES);
997 size = ALIGN(nr_bits, BITS_PER_LONG) / 8;
999 if (compat_get_bitmap(nodes_addr(tmp_mask), old_nodes, nr_bits))
1001 old = compat_alloc_user_space(new_nodes ? size * 2 : size);
1003 new = old + size / sizeof(unsigned long);
1004 if (copy_to_user(old, nodes_addr(tmp_mask), size))
1008 if (compat_get_bitmap(nodes_addr(tmp_mask), new_nodes, nr_bits))
1011 new = compat_alloc_user_space(size);
1012 if (copy_to_user(new, nodes_addr(tmp_mask), size))
1015 return sys_migrate_pages(pid, nr_bits + 1, old, new);
1019 struct compat_sysinfo {
1033 char _f[20-2*sizeof(u32)-sizeof(int)];
1037 compat_sys_sysinfo(struct compat_sysinfo __user *info)
1043 /* Check to see if any memory value is too large for 32-bit and scale
1046 if ((s.totalram >> 32) || (s.totalswap >> 32)) {
1049 while (s.mem_unit < PAGE_SIZE) {
1054 s.totalram >>= bitcount;
1055 s.freeram >>= bitcount;
1056 s.sharedram >>= bitcount;
1057 s.bufferram >>= bitcount;
1058 s.totalswap >>= bitcount;
1059 s.freeswap >>= bitcount;
1060 s.totalhigh >>= bitcount;
1061 s.freehigh >>= bitcount;
1064 if (!access_ok(VERIFY_WRITE, info, sizeof(struct compat_sysinfo)) ||
1065 __put_user (s.uptime, &info->uptime) ||
1066 __put_user (s.loads[0], &info->loads[0]) ||
1067 __put_user (s.loads[1], &info->loads[1]) ||
1068 __put_user (s.loads[2], &info->loads[2]) ||
1069 __put_user (s.totalram, &info->totalram) ||
1070 __put_user (s.freeram, &info->freeram) ||
1071 __put_user (s.sharedram, &info->sharedram) ||
1072 __put_user (s.bufferram, &info->bufferram) ||
1073 __put_user (s.totalswap, &info->totalswap) ||
1074 __put_user (s.freeswap, &info->freeswap) ||
1075 __put_user (s.procs, &info->procs) ||
1076 __put_user (s.totalhigh, &info->totalhigh) ||
1077 __put_user (s.freehigh, &info->freehigh) ||
1078 __put_user (s.mem_unit, &info->mem_unit))