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>
26 #include <asm/uaccess.h>
28 int get_compat_timespec(struct timespec
*ts
, const struct compat_timespec __user
*cts
)
30 return (!access_ok(VERIFY_READ
, cts
, sizeof(*cts
)) ||
31 __get_user(ts
->tv_sec
, &cts
->tv_sec
) ||
32 __get_user(ts
->tv_nsec
, &cts
->tv_nsec
)) ? -EFAULT
: 0;
35 int put_compat_timespec(const struct timespec
*ts
, struct compat_timespec __user
*cts
)
37 return (!access_ok(VERIFY_WRITE
, cts
, sizeof(*cts
)) ||
38 __put_user(ts
->tv_sec
, &cts
->tv_sec
) ||
39 __put_user(ts
->tv_nsec
, &cts
->tv_nsec
)) ? -EFAULT
: 0;
42 static long compat_nanosleep_restart(struct restart_block
*restart
)
44 unsigned long expire
= restart
->arg0
, now
= jiffies
;
45 struct compat_timespec __user
*rmtp
;
47 /* Did it expire while we handled signals? */
48 if (!time_after(expire
, now
))
51 expire
= schedule_timeout_interruptible(expire
- now
);
55 rmtp
= (struct compat_timespec __user
*)restart
->arg1
;
57 struct compat_timespec ct
;
60 jiffies_to_timespec(expire
, &t
);
62 ct
.tv_nsec
= t
.tv_nsec
;
63 if (copy_to_user(rmtp
, &ct
, sizeof(ct
)))
66 /* The 'restart' block is already filled in */
67 return -ERESTART_RESTARTBLOCK
;
70 asmlinkage
long compat_sys_nanosleep(struct compat_timespec __user
*rqtp
,
71 struct compat_timespec __user
*rmtp
)
74 struct restart_block
*restart
;
77 if (get_compat_timespec(&t
, rqtp
))
80 if ((t
.tv_nsec
>= 1000000000L) || (t
.tv_nsec
< 0) || (t
.tv_sec
< 0))
83 expire
= timespec_to_jiffies(&t
) + (t
.tv_sec
|| t
.tv_nsec
);
84 expire
= schedule_timeout_interruptible(expire
);
89 jiffies_to_timespec(expire
, &t
);
90 if (put_compat_timespec(&t
, rmtp
))
93 restart
= ¤t_thread_info()->restart_block
;
94 restart
->fn
= compat_nanosleep_restart
;
95 restart
->arg0
= jiffies
+ expire
;
96 restart
->arg1
= (unsigned long) rmtp
;
97 return -ERESTART_RESTARTBLOCK
;
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 static int get_compat_itimerspec(struct itimerspec
*dst
,
478 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 static int put_compat_itimerspec(struct compat_itimerspec __user
*dst
,
487 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 long compat_sys_clock_nanosleep(clockid_t which_clock
, int flags
,
605 struct compat_timespec __user
*rqtp
,
606 struct compat_timespec __user
*rmtp
)
610 struct timespec in
, out
;
612 if (get_compat_timespec(&in
, rqtp
))
617 err
= sys_clock_nanosleep(which_clock
, flags
,
618 (struct timespec __user
*) &in
,
619 (struct timespec __user
*) &out
);
621 if ((err
== -ERESTART_RESTARTBLOCK
) && rmtp
&&
622 put_compat_timespec(&out
, rmtp
))
628 * We currently only need the following fields from the sigevent
629 * structure: sigev_value, sigev_signo, sig_notify and (sometimes
630 * sigev_notify_thread_id). The others are handled in user mode.
631 * We also assume that copying sigev_value.sival_int is sufficient
632 * to keep all the bits of sigev_value.sival_ptr intact.
634 int get_compat_sigevent(struct sigevent
*event
,
635 const struct compat_sigevent __user
*u_event
)
637 memset(event
, 0, sizeof(*event
));
638 return (!access_ok(VERIFY_READ
, u_event
, sizeof(*u_event
)) ||
639 __get_user(event
->sigev_value
.sival_int
,
640 &u_event
->sigev_value
.sival_int
) ||
641 __get_user(event
->sigev_signo
, &u_event
->sigev_signo
) ||
642 __get_user(event
->sigev_notify
, &u_event
->sigev_notify
) ||
643 __get_user(event
->sigev_notify_thread_id
,
644 &u_event
->sigev_notify_thread_id
))
648 long compat_get_bitmap(unsigned long *mask
, compat_ulong_t __user
*umask
,
649 unsigned long bitmap_size
)
654 unsigned long nr_compat_longs
;
656 /* align bitmap up to nearest compat_long_t boundary */
657 bitmap_size
= ALIGN(bitmap_size
, BITS_PER_COMPAT_LONG
);
659 if (!access_ok(VERIFY_READ
, umask
, bitmap_size
/ 8))
662 nr_compat_longs
= BITS_TO_COMPAT_LONGS(bitmap_size
);
664 for (i
= 0; i
< BITS_TO_LONGS(bitmap_size
); i
++) {
667 for (j
= 0; j
< sizeof(m
)/sizeof(um
); j
++) {
669 * We dont want to read past the end of the userspace
670 * bitmap. We must however ensure the end of the
671 * kernel bitmap is zeroed.
673 if (nr_compat_longs
-- > 0) {
674 if (__get_user(um
, umask
))
681 m
|= (long)um
<< (j
* BITS_PER_COMPAT_LONG
);
689 long compat_put_bitmap(compat_ulong_t __user
*umask
, unsigned long *mask
,
690 unsigned long bitmap_size
)
695 unsigned long nr_compat_longs
;
697 /* align bitmap up to nearest compat_long_t boundary */
698 bitmap_size
= ALIGN(bitmap_size
, BITS_PER_COMPAT_LONG
);
700 if (!access_ok(VERIFY_WRITE
, umask
, bitmap_size
/ 8))
703 nr_compat_longs
= BITS_TO_COMPAT_LONGS(bitmap_size
);
705 for (i
= 0; i
< BITS_TO_LONGS(bitmap_size
); i
++) {
708 for (j
= 0; j
< sizeof(m
)/sizeof(um
); j
++) {
712 * We dont want to write past the end of the userspace
715 if (nr_compat_longs
-- > 0) {
716 if (__put_user(um
, umask
))
730 sigset_from_compat (sigset_t
*set
, compat_sigset_t
*compat
)
732 switch (_NSIG_WORDS
) {
733 #if defined (__COMPAT_ENDIAN_SWAP__)
734 case 4: set
->sig
[3] = compat
->sig
[7] | (((long)compat
->sig
[6]) << 32 );
735 case 3: set
->sig
[2] = compat
->sig
[5] | (((long)compat
->sig
[4]) << 32 );
736 case 2: set
->sig
[1] = compat
->sig
[3] | (((long)compat
->sig
[2]) << 32 );
737 case 1: set
->sig
[0] = compat
->sig
[1] | (((long)compat
->sig
[0]) << 32 );
739 case 4: set
->sig
[3] = compat
->sig
[6] | (((long)compat
->sig
[7]) << 32 );
740 case 3: set
->sig
[2] = compat
->sig
[4] | (((long)compat
->sig
[5]) << 32 );
741 case 2: set
->sig
[1] = compat
->sig
[2] | (((long)compat
->sig
[3]) << 32 );
742 case 1: set
->sig
[0] = compat
->sig
[0] | (((long)compat
->sig
[1]) << 32 );
748 compat_sys_rt_sigtimedwait (compat_sigset_t __user
*uthese
,
749 struct compat_siginfo __user
*uinfo
,
750 struct compat_timespec __user
*uts
, compat_size_t sigsetsize
)
757 long ret
, timeout
= 0;
759 if (sigsetsize
!= sizeof(sigset_t
))
762 if (copy_from_user(&s32
, uthese
, sizeof(compat_sigset_t
)))
764 sigset_from_compat(&s
, &s32
);
765 sigdelsetmask(&s
,sigmask(SIGKILL
)|sigmask(SIGSTOP
));
769 if (get_compat_timespec (&t
, uts
))
771 if (t
.tv_nsec
>= 1000000000L || t
.tv_nsec
< 0
776 spin_lock_irq(¤t
->sighand
->siglock
);
777 sig
= dequeue_signal(current
, &s
, &info
);
779 timeout
= MAX_SCHEDULE_TIMEOUT
;
781 timeout
= timespec_to_jiffies(&t
)
782 +(t
.tv_sec
|| t
.tv_nsec
);
784 current
->real_blocked
= current
->blocked
;
785 sigandsets(¤t
->blocked
, ¤t
->blocked
, &s
);
788 spin_unlock_irq(¤t
->sighand
->siglock
);
790 timeout
= schedule_timeout_interruptible(timeout
);
792 spin_lock_irq(¤t
->sighand
->siglock
);
793 sig
= dequeue_signal(current
, &s
, &info
);
794 current
->blocked
= current
->real_blocked
;
795 siginitset(¤t
->real_blocked
, 0);
799 spin_unlock_irq(¤t
->sighand
->siglock
);
804 if (copy_siginfo_to_user32(uinfo
, &info
))
808 ret
= timeout
?-EINTR
:-EAGAIN
;
814 #ifdef __ARCH_WANT_COMPAT_SYS_TIME
816 /* compat_time_t is a 32 bit "long" and needs to get converted. */
818 asmlinkage
long compat_sys_time(compat_time_t __user
* tloc
)
823 do_gettimeofday(&tv
);
827 if (put_user(i
,tloc
))
833 asmlinkage
long compat_sys_stime(compat_time_t __user
*tptr
)
838 if (get_user(tv
.tv_sec
, tptr
))
843 err
= security_settime(&tv
, NULL
);
847 do_settimeofday(&tv
);
851 #endif /* __ARCH_WANT_COMPAT_SYS_TIME */
853 #ifdef __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
854 asmlinkage
long compat_sys_rt_sigsuspend(compat_sigset_t __user
*unewset
, compat_size_t sigsetsize
)
857 compat_sigset_t newset32
;
859 /* XXX: Don't preclude handling different sized sigset_t's. */
860 if (sigsetsize
!= sizeof(sigset_t
))
863 if (copy_from_user(&newset32
, unewset
, sizeof(compat_sigset_t
)))
865 sigset_from_compat(&newset
, &newset32
);
866 sigdelsetmask(&newset
, sigmask(SIGKILL
)|sigmask(SIGSTOP
));
868 spin_lock_irq(¤t
->sighand
->siglock
);
869 current
->saved_sigmask
= current
->blocked
;
870 current
->blocked
= newset
;
872 spin_unlock_irq(¤t
->sighand
->siglock
);
874 current
->state
= TASK_INTERRUPTIBLE
;
876 set_thread_flag(TIF_RESTORE_SIGMASK
);
877 return -ERESTARTNOHAND
;
879 #endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */
881 asmlinkage
long compat_sys_adjtimex(struct compat_timex __user
*utp
)
886 memset(&txc
, 0, sizeof(struct timex
));
888 if (!access_ok(VERIFY_READ
, utp
, sizeof(struct compat_timex
)) ||
889 __get_user(txc
.modes
, &utp
->modes
) ||
890 __get_user(txc
.offset
, &utp
->offset
) ||
891 __get_user(txc
.freq
, &utp
->freq
) ||
892 __get_user(txc
.maxerror
, &utp
->maxerror
) ||
893 __get_user(txc
.esterror
, &utp
->esterror
) ||
894 __get_user(txc
.status
, &utp
->status
) ||
895 __get_user(txc
.constant
, &utp
->constant
) ||
896 __get_user(txc
.precision
, &utp
->precision
) ||
897 __get_user(txc
.tolerance
, &utp
->tolerance
) ||
898 __get_user(txc
.time
.tv_sec
, &utp
->time
.tv_sec
) ||
899 __get_user(txc
.time
.tv_usec
, &utp
->time
.tv_usec
) ||
900 __get_user(txc
.tick
, &utp
->tick
) ||
901 __get_user(txc
.ppsfreq
, &utp
->ppsfreq
) ||
902 __get_user(txc
.jitter
, &utp
->jitter
) ||
903 __get_user(txc
.shift
, &utp
->shift
) ||
904 __get_user(txc
.stabil
, &utp
->stabil
) ||
905 __get_user(txc
.jitcnt
, &utp
->jitcnt
) ||
906 __get_user(txc
.calcnt
, &utp
->calcnt
) ||
907 __get_user(txc
.errcnt
, &utp
->errcnt
) ||
908 __get_user(txc
.stbcnt
, &utp
->stbcnt
))
911 ret
= do_adjtimex(&txc
);
913 if (!access_ok(VERIFY_WRITE
, utp
, sizeof(struct compat_timex
)) ||
914 __put_user(txc
.modes
, &utp
->modes
) ||
915 __put_user(txc
.offset
, &utp
->offset
) ||
916 __put_user(txc
.freq
, &utp
->freq
) ||
917 __put_user(txc
.maxerror
, &utp
->maxerror
) ||
918 __put_user(txc
.esterror
, &utp
->esterror
) ||
919 __put_user(txc
.status
, &utp
->status
) ||
920 __put_user(txc
.constant
, &utp
->constant
) ||
921 __put_user(txc
.precision
, &utp
->precision
) ||
922 __put_user(txc
.tolerance
, &utp
->tolerance
) ||
923 __put_user(txc
.time
.tv_sec
, &utp
->time
.tv_sec
) ||
924 __put_user(txc
.time
.tv_usec
, &utp
->time
.tv_usec
) ||
925 __put_user(txc
.tick
, &utp
->tick
) ||
926 __put_user(txc
.ppsfreq
, &utp
->ppsfreq
) ||
927 __put_user(txc
.jitter
, &utp
->jitter
) ||
928 __put_user(txc
.shift
, &utp
->shift
) ||
929 __put_user(txc
.stabil
, &utp
->stabil
) ||
930 __put_user(txc
.jitcnt
, &utp
->jitcnt
) ||
931 __put_user(txc
.calcnt
, &utp
->calcnt
) ||
932 __put_user(txc
.errcnt
, &utp
->errcnt
) ||
933 __put_user(txc
.stbcnt
, &utp
->stbcnt
))
940 asmlinkage
long compat_sys_move_pages(pid_t pid
, unsigned long nr_pages
,
941 compat_uptr_t __user
*pages32
,
942 const int __user
*nodes
,
946 const void __user
* __user
*pages
;
949 pages
= compat_alloc_user_space(nr_pages
* sizeof(void *));
950 for (i
= 0; i
< nr_pages
; i
++) {
953 if (get_user(p
, pages32
+ i
) ||
954 put_user(compat_ptr(p
), pages
+ i
))
957 return sys_move_pages(pid
, nr_pages
, pages
, nodes
, status
, flags
);