14 #include <linux/linkage.h>
16 #include <linux/errno.h>
17 #include <linux/time.h>
18 #include <linux/signal.h>
19 #include <linux/sched.h>
23 #include <linux/timex.h>
24 #include <linux/export.h>
28 #include <linux/ptrace.h>
31 #include <asm/uaccess.h>
36 static int compat_get_timeval_convert(
struct timespec *o,
48 static int compat_put_timeval_convert(
struct compat_timeval __user *o,
55 static int compat_get_timex(
struct timex *txc,
struct compat_timex __user *utp)
85 static int compat_put_timex(
struct compat_timex __user *utp,
struct timex *txc)
119 if (compat_put_timeval_convert(tv, &ktv))
137 if (compat_get_timeval_convert(&kts, tv))
182 if (COMPAT_USE_64BIT_TIME)
191 if (COMPAT_USE_64BIT_TIME)
200 if (COMPAT_USE_64BIT_TIME)
209 if (COMPAT_USE_64BIT_TIME)
249 if (!timespec_valid(&tu))
263 restart->
fn = compat_nanosleep_restart;
273 static inline long get_compat_itimerval(
struct itimerval *o,
274 struct compat_itimerval __user *i)
283 static inline long put_compat_itimerval(
struct compat_itimerval __user *o,
294 struct compat_itimerval __user *it)
300 if (!error && put_compat_itimerval(it, &kit))
306 struct compat_itimerval __user *
in,
307 struct compat_itimerval __user *
out)
313 if (get_compat_itimerval(&kin, in))
316 memset(&kin, 0,
sizeof(kin));
321 if (put_compat_itimerval(out, &kout))
335 struct compat_tms tmp;
339 tmp.tms_utime = clock_t_to_compat_clock_t(tms.
tms_utime);
340 tmp.tms_stime = clock_t_to_compat_clock_t(tms.
tms_stime);
341 tmp.tms_cutime = clock_t_to_compat_clock_t(tms.
tms_cutime);
342 tmp.tms_cstime = clock_t_to_compat_clock_t(tms.
tms_cstime);
347 return compat_jiffies_to_clock_t(
jiffies);
350 #ifdef __ARCH_WANT_SYS_SIGPENDING
373 #ifdef __ARCH_WANT_SYS_SIGPROCMASK
384 asmlinkage long compat_sys_sigprocmask(
int how,
391 old_set =
current->blocked.sig[0];
398 new_blocked =
current->blocked;
402 sigaddsetmask(&new_blocked, new_set);
405 sigdelsetmask(&new_blocked, new_set);
408 compat_sig_setmask(&new_blocked, new_set);
428 struct compat_rlimit __user *rlim)
444 #ifdef COMPAT_RLIM_OLD_INFINITY
447 struct compat_rlimit __user *rlim)
474 struct compat_rlimit __user *rlim)
540 struct compat_rusage __user *ru)
553 (
unsigned int __user *) &status :
NULL),
554 options, (
struct rusage __user *) &r);
560 if (stat_addr &&
put_user(status, stat_addr))
569 struct compat_rusage __user *uru)
576 memset(&info, 0,
sizeof(info));
583 if ((ret < 0) || (info.
si_signo == 0))
597 static int compat_get_user_cpu_mask(
compat_ulong_t __user *user_mask_ptr,
598 unsigned len,
struct cpumask *new_mask)
602 if (len < cpumask_size())
603 memset(new_mask, 0, cpumask_size());
604 else if (len > cpumask_size())
605 len = cpumask_size();
618 if (!alloc_cpumask_var(&new_mask,
GFP_KERNEL))
621 retval = compat_get_user_cpu_mask(user_mask_ptr, len, new_mask);
627 free_cpumask_var(new_mask);
647 size_t retlen =
min_t(
size_t, len, cpumask_size());
654 free_cpumask_var(mask);
660 const struct compat_itimerspec __user *
src)
678 struct compat_sigevent __user *timer_event_spec,
679 timer_t __user *created_timer_id)
683 if (timer_event_spec) {
696 struct compat_itimerspec __user *
new,
697 struct compat_itimerspec __user *old)
719 struct compat_itimerspec __user *setting)
770 struct compat_timex __user *utp)
776 err = compat_get_timex(&txc, utp);
785 err = compat_put_timex(utp, &txc);
809 static long compat_clock_nanosleep_restart(
struct restart_block *restart)
827 restart->
fn = compat_clock_nanosleep_restart;
858 restart->
fn = compat_clock_nanosleep_restart;
872 const struct compat_sigevent __user *u_event)
874 memset(event, 0,
sizeof(*event));
877 &u_event->sigev_value.sival_int) ||
881 &u_event->sigev_notify_thread_id))
886 unsigned long bitmap_size)
891 unsigned long nr_compat_longs;
894 bitmap_size =
ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
899 nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
904 for (j = 0; j <
sizeof(
m)/
sizeof(um); j++) {
910 if (nr_compat_longs-- > 0) {
918 m |= (
long)um << (j * BITS_PER_COMPAT_LONG);
927 unsigned long bitmap_size)
932 unsigned long nr_compat_longs;
935 bitmap_size =
ALIGN(bitmap_size, BITS_PER_COMPAT_LONG);
940 nr_compat_longs = BITS_TO_COMPAT_LONGS(bitmap_size);
945 for (j = 0; j <
sizeof(
m)/
sizeof(um); j++) {
952 if (nr_compat_longs-- > 0) {
970 case 4:
set->sig[3] = compat->sig[6] | (((
long)compat->sig[7]) << 32 );
971 case 3:
set->sig[2] = compat->sig[4] | (((
long)compat->sig[5]) << 32 );
972 case 2:
set->sig[1] = compat->sig[2] | (((
long)compat->sig[3]) << 32 );
973 case 1:
set->sig[0] = compat->sig[0] | (((
long)compat->sig[1]) << 32 );
1003 if (ret > 0 && uinfo) {
1023 #ifdef __ARCH_WANT_COMPAT_SYS_TIME
1063 #ifdef __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
1067 compat_sigset_t newset32;
1070 if (sigsetsize !=
sizeof(
sigset_t))
1085 err = compat_get_timex(&txc, utp);
1091 err = compat_put_timex(utp, &txc);
1101 const int __user *nodes,
1105 const void __user * __user *
pages;
1109 for (i = 0; i < nr_pages; i++) {
1113 put_user(compat_ptr(p), pages + i))
1116 return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
1124 unsigned long __user *old =
NULL;
1125 unsigned long __user *
new =
NULL;
1127 unsigned long nr_bits;
1137 new = old + size /
sizeof(
unsigned long);
1230 ptr = arch_compat_alloc_user_space(len);