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/export.h>
25 #include <linux/migrate.h>
26 #include <linux/posix-timers.h>
27 #include <linux/times.h>
28 #include <linux/ptrace.h>
29 #include <linux/gfp.h>
31 #include <linux/uaccess.h>
33 int compat_get_timex(struct timex *txc, const struct compat_timex __user *utp)
35 struct compat_timex tx32;
37 if (copy_from_user(&tx32, utp, sizeof(struct compat_timex)))
40 txc->modes = tx32.modes;
41 txc->offset = tx32.offset;
42 txc->freq = tx32.freq;
43 txc->maxerror = tx32.maxerror;
44 txc->esterror = tx32.esterror;
45 txc->status = tx32.status;
46 txc->constant = tx32.constant;
47 txc->precision = tx32.precision;
48 txc->tolerance = tx32.tolerance;
49 txc->time.tv_sec = tx32.time.tv_sec;
50 txc->time.tv_usec = tx32.time.tv_usec;
51 txc->tick = tx32.tick;
52 txc->ppsfreq = tx32.ppsfreq;
53 txc->jitter = tx32.jitter;
54 txc->shift = tx32.shift;
55 txc->stabil = tx32.stabil;
56 txc->jitcnt = tx32.jitcnt;
57 txc->calcnt = tx32.calcnt;
58 txc->errcnt = tx32.errcnt;
59 txc->stbcnt = tx32.stbcnt;
64 int compat_put_timex(struct compat_timex __user *utp, const struct timex *txc)
66 struct compat_timex tx32;
68 memset(&tx32, 0, sizeof(struct compat_timex));
69 tx32.modes = txc->modes;
70 tx32.offset = txc->offset;
71 tx32.freq = txc->freq;
72 tx32.maxerror = txc->maxerror;
73 tx32.esterror = txc->esterror;
74 tx32.status = txc->status;
75 tx32.constant = txc->constant;
76 tx32.precision = txc->precision;
77 tx32.tolerance = txc->tolerance;
78 tx32.time.tv_sec = txc->time.tv_sec;
79 tx32.time.tv_usec = txc->time.tv_usec;
80 tx32.tick = txc->tick;
81 tx32.ppsfreq = txc->ppsfreq;
82 tx32.jitter = txc->jitter;
83 tx32.shift = txc->shift;
84 tx32.stabil = txc->stabil;
85 tx32.jitcnt = txc->jitcnt;
86 tx32.calcnt = txc->calcnt;
87 tx32.errcnt = txc->errcnt;
88 tx32.stbcnt = txc->stbcnt;
90 if (copy_to_user(utp, &tx32, sizeof(struct compat_timex)))
95 COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
96 struct timezone __user *, tz)
100 do_gettimeofday(&ktv);
101 if (compat_put_timeval(&ktv, tv))
105 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
112 COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
113 struct timezone __user *, tz)
115 struct timespec64 new_ts;
116 struct timeval user_tv;
117 struct timezone new_tz;
120 if (compat_get_timeval(&user_tv, tv))
122 new_ts.tv_sec = user_tv.tv_sec;
123 new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
126 if (copy_from_user(&new_tz, tz, sizeof(*tz)))
130 return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
133 static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv)
135 return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) ||
136 __get_user(tv->tv_sec, &ctv->tv_sec) ||
137 __get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
140 static int __compat_put_timeval(const struct timeval *tv, struct compat_timeval __user *ctv)
142 return (!access_ok(VERIFY_WRITE, ctv, sizeof(*ctv)) ||
143 __put_user(tv->tv_sec, &ctv->tv_sec) ||
144 __put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
147 static int __compat_get_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
149 return (!access_ok(VERIFY_READ, cts, sizeof(*cts)) ||
150 __get_user(ts->tv_sec, &cts->tv_sec) ||
151 __get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
154 static int __compat_put_timespec(const struct timespec *ts, struct compat_timespec __user *cts)
156 return (!access_ok(VERIFY_WRITE, cts, sizeof(*cts)) ||
157 __put_user(ts->tv_sec, &cts->tv_sec) ||
158 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
161 int compat_get_timeval(struct timeval *tv, const void __user *utv)
163 if (COMPAT_USE_64BIT_TIME)
164 return copy_from_user(tv, utv, sizeof(*tv)) ? -EFAULT : 0;
166 return __compat_get_timeval(tv, utv);
168 EXPORT_SYMBOL_GPL(compat_get_timeval);
170 int compat_put_timeval(const struct timeval *tv, void __user *utv)
172 if (COMPAT_USE_64BIT_TIME)
173 return copy_to_user(utv, tv, sizeof(*tv)) ? -EFAULT : 0;
175 return __compat_put_timeval(tv, utv);
177 EXPORT_SYMBOL_GPL(compat_put_timeval);
179 int compat_get_timespec(struct timespec *ts, const void __user *uts)
181 if (COMPAT_USE_64BIT_TIME)
182 return copy_from_user(ts, uts, sizeof(*ts)) ? -EFAULT : 0;
184 return __compat_get_timespec(ts, uts);
186 EXPORT_SYMBOL_GPL(compat_get_timespec);
188 int compat_put_timespec(const struct timespec *ts, void __user *uts)
190 if (COMPAT_USE_64BIT_TIME)
191 return copy_to_user(uts, ts, sizeof(*ts)) ? -EFAULT : 0;
193 return __compat_put_timespec(ts, uts);
195 EXPORT_SYMBOL_GPL(compat_put_timespec);
197 int compat_convert_timespec(struct timespec __user **kts,
198 const void __user *cts)
201 struct timespec __user *uts;
203 if (!cts || COMPAT_USE_64BIT_TIME) {
204 *kts = (struct timespec __user *)cts;
208 uts = compat_alloc_user_space(sizeof(ts));
211 if (compat_get_timespec(&ts, cts))
213 if (copy_to_user(uts, &ts, sizeof(ts)))
220 int get_compat_itimerval(struct itimerval *o, const struct compat_itimerval __user *i)
222 struct compat_itimerval v32;
224 if (copy_from_user(&v32, i, sizeof(struct compat_itimerval)))
226 o->it_interval.tv_sec = v32.it_interval.tv_sec;
227 o->it_interval.tv_usec = v32.it_interval.tv_usec;
228 o->it_value.tv_sec = v32.it_value.tv_sec;
229 o->it_value.tv_usec = v32.it_value.tv_usec;
233 int put_compat_itimerval(struct compat_itimerval __user *o, const struct itimerval *i)
235 struct compat_itimerval v32;
237 v32.it_interval.tv_sec = i->it_interval.tv_sec;
238 v32.it_interval.tv_usec = i->it_interval.tv_usec;
239 v32.it_value.tv_sec = i->it_value.tv_sec;
240 v32.it_value.tv_usec = i->it_value.tv_usec;
241 return copy_to_user(o, &v32, sizeof(struct compat_itimerval)) ? -EFAULT : 0;
244 static compat_clock_t clock_t_to_compat_clock_t(clock_t x)
246 return compat_jiffies_to_clock_t(clock_t_to_jiffies(x));
249 COMPAT_SYSCALL_DEFINE1(times, struct compat_tms __user *, tbuf)
253 struct compat_tms tmp;
256 /* Convert our struct tms to the compat version. */
257 tmp.tms_utime = clock_t_to_compat_clock_t(tms.tms_utime);
258 tmp.tms_stime = clock_t_to_compat_clock_t(tms.tms_stime);
259 tmp.tms_cutime = clock_t_to_compat_clock_t(tms.tms_cutime);
260 tmp.tms_cstime = clock_t_to_compat_clock_t(tms.tms_cstime);
261 if (copy_to_user(tbuf, &tmp, sizeof(tmp)))
264 force_successful_syscall_return();
265 return compat_jiffies_to_clock_t(jiffies);
268 #ifdef __ARCH_WANT_SYS_SIGPENDING
271 * Assumption: old_sigset_t and compat_old_sigset_t are both
272 * types that can be passed to put_user()/get_user().
275 COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set)
279 mm_segment_t old_fs = get_fs();
282 ret = sys_sigpending((old_sigset_t __user *) &s);
285 ret = put_user(s, set);
291 #ifdef __ARCH_WANT_SYS_SIGPROCMASK
294 * sys_sigprocmask SIG_SETMASK sets the first (compat) word of the
295 * blocked set of signals to the supplied signal set
297 static inline void compat_sig_setmask(sigset_t *blocked, compat_sigset_word set)
299 memcpy(blocked->sig, &set, sizeof(set));
302 COMPAT_SYSCALL_DEFINE3(sigprocmask, int, how,
303 compat_old_sigset_t __user *, nset,
304 compat_old_sigset_t __user *, oset)
306 old_sigset_t old_set, new_set;
307 sigset_t new_blocked;
309 old_set = current->blocked.sig[0];
312 if (get_user(new_set, nset))
314 new_set &= ~(sigmask(SIGKILL) | sigmask(SIGSTOP));
316 new_blocked = current->blocked;
320 sigaddsetmask(&new_blocked, new_set);
323 sigdelsetmask(&new_blocked, new_set);
326 compat_sig_setmask(&new_blocked, new_set);
332 set_current_blocked(&new_blocked);
336 if (put_user(old_set, oset))
345 COMPAT_SYSCALL_DEFINE2(setrlimit, unsigned int, resource,
346 struct compat_rlimit __user *, rlim)
350 if (!access_ok(VERIFY_READ, rlim, sizeof(*rlim)) ||
351 __get_user(r.rlim_cur, &rlim->rlim_cur) ||
352 __get_user(r.rlim_max, &rlim->rlim_max))
355 if (r.rlim_cur == COMPAT_RLIM_INFINITY)
356 r.rlim_cur = RLIM_INFINITY;
357 if (r.rlim_max == COMPAT_RLIM_INFINITY)
358 r.rlim_max = RLIM_INFINITY;
359 return do_prlimit(current, resource, &r, NULL);
362 #ifdef COMPAT_RLIM_OLD_INFINITY
364 COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
365 struct compat_rlimit __user *, rlim)
369 mm_segment_t old_fs = get_fs();
372 ret = sys_old_getrlimit(resource, (struct rlimit __user *)&r);
376 if (r.rlim_cur > COMPAT_RLIM_OLD_INFINITY)
377 r.rlim_cur = COMPAT_RLIM_INFINITY;
378 if (r.rlim_max > COMPAT_RLIM_OLD_INFINITY)
379 r.rlim_max = COMPAT_RLIM_INFINITY;
381 if (!access_ok(VERIFY_WRITE, rlim, sizeof(*rlim)) ||
382 __put_user(r.rlim_cur, &rlim->rlim_cur) ||
383 __put_user(r.rlim_max, &rlim->rlim_max))
391 COMPAT_SYSCALL_DEFINE2(getrlimit, unsigned int, resource,
392 struct compat_rlimit __user *, rlim)
397 ret = do_prlimit(current, resource, NULL, &r);
399 if (r.rlim_cur > COMPAT_RLIM_INFINITY)
400 r.rlim_cur = COMPAT_RLIM_INFINITY;
401 if (r.rlim_max > COMPAT_RLIM_INFINITY)
402 r.rlim_max = COMPAT_RLIM_INFINITY;
404 if (!access_ok(VERIFY_WRITE, rlim, sizeof(*rlim)) ||
405 __put_user(r.rlim_cur, &rlim->rlim_cur) ||
406 __put_user(r.rlim_max, &rlim->rlim_max))
412 int put_compat_rusage(const struct rusage *r, struct compat_rusage __user *ru)
414 if (!access_ok(VERIFY_WRITE, ru, sizeof(*ru)) ||
415 __put_user(r->ru_utime.tv_sec, &ru->ru_utime.tv_sec) ||
416 __put_user(r->ru_utime.tv_usec, &ru->ru_utime.tv_usec) ||
417 __put_user(r->ru_stime.tv_sec, &ru->ru_stime.tv_sec) ||
418 __put_user(r->ru_stime.tv_usec, &ru->ru_stime.tv_usec) ||
419 __put_user(r->ru_maxrss, &ru->ru_maxrss) ||
420 __put_user(r->ru_ixrss, &ru->ru_ixrss) ||
421 __put_user(r->ru_idrss, &ru->ru_idrss) ||
422 __put_user(r->ru_isrss, &ru->ru_isrss) ||
423 __put_user(r->ru_minflt, &ru->ru_minflt) ||
424 __put_user(r->ru_majflt, &ru->ru_majflt) ||
425 __put_user(r->ru_nswap, &ru->ru_nswap) ||
426 __put_user(r->ru_inblock, &ru->ru_inblock) ||
427 __put_user(r->ru_oublock, &ru->ru_oublock) ||
428 __put_user(r->ru_msgsnd, &ru->ru_msgsnd) ||
429 __put_user(r->ru_msgrcv, &ru->ru_msgrcv) ||
430 __put_user(r->ru_nsignals, &ru->ru_nsignals) ||
431 __put_user(r->ru_nvcsw, &ru->ru_nvcsw) ||
432 __put_user(r->ru_nivcsw, &ru->ru_nivcsw))
437 COMPAT_SYSCALL_DEFINE4(wait4,
439 compat_uint_t __user *, stat_addr,
441 struct compat_rusage __user *, ru)
444 return sys_wait4(pid, stat_addr, options, NULL);
449 mm_segment_t old_fs = get_fs();
454 (unsigned int __user *) &status : NULL),
455 options, (struct rusage __user *) &r);
459 if (put_compat_rusage(&r, ru))
461 if (stat_addr && put_user(status, stat_addr))
468 COMPAT_SYSCALL_DEFINE5(waitid,
469 int, which, compat_pid_t, pid,
470 struct compat_siginfo __user *, uinfo, int, options,
471 struct compat_rusage __user *, uru)
476 mm_segment_t old_fs = get_fs();
478 memset(&info, 0, sizeof(info));
481 ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
482 uru ? (struct rusage __user *)&ru : NULL);
485 if ((ret < 0) || (info.si_signo == 0))
489 /* sys_waitid() overwrites everything in ru */
490 if (COMPAT_USE_64BIT_TIME)
491 ret = copy_to_user(uru, &ru, sizeof(ru));
493 ret = put_compat_rusage(&ru, uru);
498 BUG_ON(info.si_code & __SI_MASK);
499 info.si_code |= __SI_CHLD;
500 return copy_siginfo_to_user32(uinfo, &info);
503 static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,
504 unsigned len, struct cpumask *new_mask)
508 if (len < cpumask_size())
509 memset(new_mask, 0, cpumask_size());
510 else if (len > cpumask_size())
511 len = cpumask_size();
513 k = cpumask_bits(new_mask);
514 return compat_get_bitmap(k, user_mask_ptr, len * 8);
517 COMPAT_SYSCALL_DEFINE3(sched_setaffinity, compat_pid_t, pid,
519 compat_ulong_t __user *, user_mask_ptr)
521 cpumask_var_t new_mask;
524 if (!alloc_cpumask_var(&new_mask, GFP_KERNEL))
527 retval = compat_get_user_cpu_mask(user_mask_ptr, len, new_mask);
531 retval = sched_setaffinity(pid, new_mask);
533 free_cpumask_var(new_mask);
537 COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len,
538 compat_ulong_t __user *, user_mask_ptr)
543 if ((len * BITS_PER_BYTE) < nr_cpu_ids)
545 if (len & (sizeof(compat_ulong_t)-1))
548 if (!alloc_cpumask_var(&mask, GFP_KERNEL))
551 ret = sched_getaffinity(pid, mask);
553 size_t retlen = min_t(size_t, len, cpumask_size());
555 if (compat_put_bitmap(user_mask_ptr, cpumask_bits(mask), retlen * 8))
560 free_cpumask_var(mask);
565 int get_compat_itimerspec(struct itimerspec *dst,
566 const struct compat_itimerspec __user *src)
568 if (__compat_get_timespec(&dst->it_interval, &src->it_interval) ||
569 __compat_get_timespec(&dst->it_value, &src->it_value))
574 int put_compat_itimerspec(struct compat_itimerspec __user *dst,
575 const struct itimerspec *src)
577 if (__compat_put_timespec(&src->it_interval, &dst->it_interval) ||
578 __compat_put_timespec(&src->it_value, &dst->it_value))
584 * We currently only need the following fields from the sigevent
585 * structure: sigev_value, sigev_signo, sig_notify and (sometimes
586 * sigev_notify_thread_id). The others are handled in user mode.
587 * We also assume that copying sigev_value.sival_int is sufficient
588 * to keep all the bits of sigev_value.sival_ptr intact.
590 int get_compat_sigevent(struct sigevent *event,
591 const struct compat_sigevent __user *u_event)
593 memset(event, 0, sizeof(*event));
594 return (!access_ok(VERIFY_READ, u_event, sizeof(*u_event)) ||
595 __get_user(event->sigev_value.sival_int,
596 &u_event->sigev_value.sival_int) ||
597 __get_user(event->sigev_signo, &u_event->sigev_signo) ||
598 __get_user(event->sigev_notify, &u_event->sigev_notify) ||
599 __get_user(event->sigev_notify_thread_id,
600 &u_event->sigev_notify_thread_id))
604 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
605 unsigned long bitmap_size)
610 unsigned long nr_compat_longs;
612 /* align bitmap up to nearest compat_long_t boundary */
613 bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
615 if (!access_ok(VERIFY_READ, umask, bitmap_size / 8))
618 nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
620 for (i = 0; i < BITS_TO_LONGS(bitmap_size); i++) {
623 for (j = 0; j < sizeof(m)/sizeof(um); j++) {
625 * We dont want to read past the end of the userspace
626 * bitmap. We must however ensure the end of the
627 * kernel bitmap is zeroed.
629 if (nr_compat_longs) {
631 if (__get_user(um, umask))
638 m |= (long)um << (j * BITS_PER_COMPAT_LONG);
646 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
647 unsigned long bitmap_size)
652 unsigned long nr_compat_longs;
654 /* align bitmap up to nearest compat_long_t boundary */
655 bitmap_size = ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
657 if (!access_ok(VERIFY_WRITE, umask, bitmap_size / 8))
660 nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
662 for (i = 0; i < BITS_TO_LONGS(bitmap_size); i++) {
665 for (j = 0; j < sizeof(m)/sizeof(um); j++) {
669 * We dont want to write past the end of the userspace
672 if (nr_compat_longs) {
674 if (__put_user(um, umask))
688 sigset_from_compat(sigset_t *set, const compat_sigset_t *compat)
690 switch (_NSIG_WORDS) {
691 case 4: set->sig[3] = compat->sig[6] | (((long)compat->sig[7]) << 32 );
692 case 3: set->sig[2] = compat->sig[4] | (((long)compat->sig[5]) << 32 );
693 case 2: set->sig[1] = compat->sig[2] | (((long)compat->sig[3]) << 32 );
694 case 1: set->sig[0] = compat->sig[0] | (((long)compat->sig[1]) << 32 );
697 EXPORT_SYMBOL_GPL(sigset_from_compat);
700 sigset_to_compat(compat_sigset_t *compat, const sigset_t *set)
702 switch (_NSIG_WORDS) {
703 case 4: compat->sig[7] = (set->sig[3] >> 32); compat->sig[6] = set->sig[3];
704 case 3: compat->sig[5] = (set->sig[2] >> 32); compat->sig[4] = set->sig[2];
705 case 2: compat->sig[3] = (set->sig[1] >> 32); compat->sig[2] = set->sig[1];
706 case 1: compat->sig[1] = (set->sig[0] >> 32); compat->sig[0] = set->sig[0];
710 COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese,
711 struct compat_siginfo __user *, uinfo,
712 struct compat_timespec __user *, uts, compat_size_t, sigsetsize)
720 if (sigsetsize != sizeof(sigset_t))
723 if (copy_from_user(&s32, uthese, sizeof(compat_sigset_t)))
725 sigset_from_compat(&s, &s32);
728 if (compat_get_timespec(&t, uts))
732 ret = do_sigtimedwait(&s, &info, uts ? &t : NULL);
734 if (ret > 0 && uinfo) {
735 if (copy_siginfo_to_user32(uinfo, &info))
742 #ifdef __ARCH_WANT_COMPAT_SYS_TIME
744 /* compat_time_t is a 32 bit "long" and needs to get converted. */
746 COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc)
751 do_gettimeofday(&tv);
755 if (put_user(i,tloc))
758 force_successful_syscall_return();
762 COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr)
767 if (get_user(tv.tv_sec, tptr))
772 err = security_settime(&tv, NULL);
776 do_settimeofday(&tv);
780 #endif /* __ARCH_WANT_COMPAT_SYS_TIME */
783 COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages,
784 compat_uptr_t __user *, pages32,
785 const int __user *, nodes,
786 int __user *, status,
789 const void __user * __user *pages;
792 pages = compat_alloc_user_space(nr_pages * sizeof(void *));
793 for (i = 0; i < nr_pages; i++) {
796 if (get_user(p, pages32 + i) ||
797 put_user(compat_ptr(p), pages + i))
800 return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
803 COMPAT_SYSCALL_DEFINE4(migrate_pages, compat_pid_t, pid,
804 compat_ulong_t, maxnode,
805 const compat_ulong_t __user *, old_nodes,
806 const compat_ulong_t __user *, new_nodes)
808 unsigned long __user *old = NULL;
809 unsigned long __user *new = NULL;
811 unsigned long nr_bits;
814 nr_bits = min_t(unsigned long, maxnode - 1, MAX_NUMNODES);
815 size = ALIGN(nr_bits, BITS_PER_LONG) / 8;
817 if (compat_get_bitmap(nodes_addr(tmp_mask), old_nodes, nr_bits))
819 old = compat_alloc_user_space(new_nodes ? size * 2 : size);
821 new = old + size / sizeof(unsigned long);
822 if (copy_to_user(old, nodes_addr(tmp_mask), size))
826 if (compat_get_bitmap(nodes_addr(tmp_mask), new_nodes, nr_bits))
829 new = compat_alloc_user_space(size);
830 if (copy_to_user(new, nodes_addr(tmp_mask), size))
833 return sys_migrate_pages(pid, nr_bits + 1, old, new);
837 COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
839 struct compat_timespec __user *, interval)
843 mm_segment_t old_fs = get_fs();
846 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
848 if (compat_put_timespec(&t, interval))
854 * Allocate user-space memory for the duration of a single system call,
855 * in order to marshall parameters inside a compat thunk.
857 void __user *compat_alloc_user_space(unsigned long len)
861 /* If len would occupy more than half of the entire compat space... */
862 if (unlikely(len > (((compat_uptr_t)~0) >> 1)))
865 ptr = arch_compat_alloc_user_space(len);
867 if (unlikely(!access_ok(VERIFY_WRITE, ptr, len)))
872 EXPORT_SYMBOL_GPL(compat_alloc_user_space);