Commit e898a4d6 authored by Stephen Rothwell's avatar Stephen Rothwell Committed by Linus Torvalds

[PATCH] compat_{old_}sigset_t s390x part

With Martin's continuing approval, here is the s390x part of the patch.
parent bb186109
...@@ -1623,7 +1623,7 @@ asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid, ...@@ -1623,7 +1623,7 @@ asmlinkage int sys32_sched_rr_get_interval(compat_pid_t pid,
extern asmlinkage int sys_sigprocmask(int how, old_sigset_t *set, old_sigset_t *oset); extern asmlinkage int sys_sigprocmask(int how, old_sigset_t *set, old_sigset_t *oset);
asmlinkage int sys32_sigprocmask(int how, old_sigset_t32 *set, old_sigset_t32 *oset) asmlinkage int sys32_sigprocmask(int how, compat_old_sigset_t *set, compat_old_sigset_t *oset)
{ {
old_sigset_t s; old_sigset_t s;
int ret; int ret;
...@@ -1640,15 +1640,15 @@ asmlinkage int sys32_sigprocmask(int how, old_sigset_t32 *set, old_sigset_t32 *o ...@@ -1640,15 +1640,15 @@ asmlinkage int sys32_sigprocmask(int how, old_sigset_t32 *set, old_sigset_t32 *o
extern asmlinkage int sys_rt_sigprocmask(int how, sigset_t *set, sigset_t *oset, size_t sigsetsize); extern asmlinkage int sys_rt_sigprocmask(int how, sigset_t *set, sigset_t *oset, size_t sigsetsize);
asmlinkage int sys32_rt_sigprocmask(int how, sigset_t32 *set, sigset_t32 *oset, compat_size_t sigsetsize) asmlinkage int sys32_rt_sigprocmask(int how, compat_sigset_t *set, compat_sigset_t *oset, compat_size_t sigsetsize)
{ {
sigset_t s; sigset_t s;
sigset_t32 s32; compat_sigset_t s32;
int ret; int ret;
mm_segment_t old_fs = get_fs(); mm_segment_t old_fs = get_fs();
if (set) { if (set) {
if (copy_from_user (&s32, set, sizeof(sigset_t32))) if (copy_from_user (&s32, set, sizeof(compat_sigset_t)))
return -EFAULT; return -EFAULT;
switch (_NSIG_WORDS) { switch (_NSIG_WORDS) {
case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32); case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);
...@@ -1668,7 +1668,7 @@ asmlinkage int sys32_rt_sigprocmask(int how, sigset_t32 *set, sigset_t32 *oset, ...@@ -1668,7 +1668,7 @@ asmlinkage int sys32_rt_sigprocmask(int how, sigset_t32 *set, sigset_t32 *oset,
case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1]; case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0]; case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
} }
if (copy_to_user (oset, &s32, sizeof(sigset_t32))) if (copy_to_user (oset, &s32, sizeof(compat_sigset_t)))
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -1676,7 +1676,7 @@ asmlinkage int sys32_rt_sigprocmask(int how, sigset_t32 *set, sigset_t32 *oset, ...@@ -1676,7 +1676,7 @@ asmlinkage int sys32_rt_sigprocmask(int how, sigset_t32 *set, sigset_t32 *oset,
extern asmlinkage int sys_sigpending(old_sigset_t *set); extern asmlinkage int sys_sigpending(old_sigset_t *set);
asmlinkage int sys32_sigpending(old_sigset_t32 *set) asmlinkage int sys32_sigpending(compat_old_sigset_t *set)
{ {
old_sigset_t s; old_sigset_t s;
int ret; int ret;
...@@ -1691,10 +1691,10 @@ asmlinkage int sys32_sigpending(old_sigset_t32 *set) ...@@ -1691,10 +1691,10 @@ asmlinkage int sys32_sigpending(old_sigset_t32 *set)
extern asmlinkage int sys_rt_sigpending(sigset_t *set, size_t sigsetsize); extern asmlinkage int sys_rt_sigpending(sigset_t *set, size_t sigsetsize);
asmlinkage int sys32_rt_sigpending(sigset_t32 *set, compat_size_t sigsetsize) asmlinkage int sys32_rt_sigpending(compat_sigset_t *set, compat_size_t sigsetsize)
{ {
sigset_t s; sigset_t s;
sigset_t32 s32; compat_sigset_t s32;
int ret; int ret;
mm_segment_t old_fs = get_fs(); mm_segment_t old_fs = get_fs();
...@@ -1708,7 +1708,7 @@ asmlinkage int sys32_rt_sigpending(sigset_t32 *set, compat_size_t sigsetsize) ...@@ -1708,7 +1708,7 @@ asmlinkage int sys32_rt_sigpending(sigset_t32 *set, compat_size_t sigsetsize)
case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1]; case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];
case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0]; case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];
} }
if (copy_to_user (set, &s32, sizeof(sigset_t32))) if (copy_to_user (set, &s32, sizeof(compat_sigset_t)))
return -EFAULT; return -EFAULT;
} }
return ret; return ret;
...@@ -1718,12 +1718,12 @@ extern int ...@@ -1718,12 +1718,12 @@ extern int
copy_siginfo_to_user32(siginfo_t32 *to, siginfo_t *from); copy_siginfo_to_user32(siginfo_t32 *to, siginfo_t *from);
asmlinkage int asmlinkage int
sys32_rt_sigtimedwait(sigset_t32 *uthese, siginfo_t32 *uinfo, sys32_rt_sigtimedwait(compat_sigset_t *uthese, siginfo_t32 *uinfo,
struct compat_timespec *uts, compat_size_t sigsetsize) struct compat_timespec *uts, compat_size_t sigsetsize)
{ {
int ret, sig; int ret, sig;
sigset_t these; sigset_t these;
sigset_t32 these32; compat_sigset_t these32;
struct timespec ts; struct timespec ts;
siginfo_t info; siginfo_t info;
long timeout = 0; long timeout = 0;
...@@ -1732,7 +1732,7 @@ sys32_rt_sigtimedwait(sigset_t32 *uthese, siginfo_t32 *uinfo, ...@@ -1732,7 +1732,7 @@ sys32_rt_sigtimedwait(sigset_t32 *uthese, siginfo_t32 *uinfo,
if (sigsetsize != sizeof(sigset_t)) if (sigsetsize != sizeof(sigset_t))
return -EINVAL; return -EINVAL;
if (copy_from_user (&these32, uthese, sizeof(sigset_t32))) if (copy_from_user (&these32, uthese, sizeof(compat_sigset_t)))
return -EFAULT; return -EFAULT;
switch (_NSIG_WORDS) { switch (_NSIG_WORDS) {
......
...@@ -25,20 +25,13 @@ struct ipc_kludge_32 { ...@@ -25,20 +25,13 @@ struct ipc_kludge_32 {
#define F_SETLK64 13 #define F_SETLK64 13
#define F_SETLKW64 14 #define F_SETLKW64 14
typedef __u32 old_sigset_t32; /* at least 32 bits */
struct old_sigaction32 { struct old_sigaction32 {
__u32 sa_handler; /* Really a pointer, but need to deal with 32 bits */ __u32 sa_handler; /* Really a pointer, but need to deal with 32 bits */
old_sigset_t32 sa_mask; /* A 32 bit mask */ compat_old_sigset_t sa_mask; /* A 32 bit mask */
__u32 sa_flags; __u32 sa_flags;
__u32 sa_restorer; /* Another 32 bit pointer */ __u32 sa_restorer; /* Another 32 bit pointer */
}; };
#define _SIGCONTEXT_NSIG_WORDS32 2
typedef struct {
__u32 sig[_SIGCONTEXT_NSIG_WORDS32];
} sigset_t32;
typedef union sigval32 { typedef union sigval32 {
int sival_int; int sival_int;
__u32 sival_ptr; __u32 sival_ptr;
...@@ -174,7 +167,7 @@ typedef struct ...@@ -174,7 +167,7 @@ typedef struct
struct sigcontext32 struct sigcontext32
{ {
__u32 oldmask[_SIGCONTEXT_NSIG_WORDS32]; __u32 oldmask[_COMPAT_NSIG_WORDS];
__u32 sregs; /* pointer */ __u32 sregs; /* pointer */
}; };
...@@ -183,7 +176,7 @@ struct sigaction32 { ...@@ -183,7 +176,7 @@ struct sigaction32 {
__u32 sa_handler; /* pointer */ __u32 sa_handler; /* pointer */
__u32 sa_flags; __u32 sa_flags;
__u32 sa_restorer; /* pointer */ __u32 sa_restorer; /* pointer */
sigset_t32 sa_mask; /* mask last for extensibility */ compat_sigset_t sa_mask; /* mask last for extensibility */
}; };
typedef struct { typedef struct {
...@@ -198,7 +191,7 @@ struct ucontext32 { ...@@ -198,7 +191,7 @@ struct ucontext32 {
__u32 uc_link; /* pointer */ __u32 uc_link; /* pointer */
stack_t32 uc_stack; stack_t32 uc_stack;
_sigregs32 uc_mcontext; _sigregs32 uc_mcontext;
sigset_t32 uc_sigmask; /* mask last for extensibility */ compat_sigset_t uc_sigmask; /* mask last for extensibility */
}; };
#endif /* _ASM_S390X_S390_H */ #endif /* _ASM_S390X_S390_H */
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/compat.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/smp.h> #include <linux/smp.h>
...@@ -127,10 +128,10 @@ sys32_sigsuspend(struct pt_regs * regs,int history0, int history1, old_sigset_t ...@@ -127,10 +128,10 @@ sys32_sigsuspend(struct pt_regs * regs,int history0, int history1, old_sigset_t
} }
asmlinkage int asmlinkage int
sys32_rt_sigsuspend(struct pt_regs * regs,sigset_t32 *unewset, size_t sigsetsize) sys32_rt_sigsuspend(struct pt_regs * regs,compat_sigset_t *unewset, size_t sigsetsize)
{ {
sigset_t saveset, newset; sigset_t saveset, newset;
sigset_t32 set32; compat_sigset_t set32;
/* XXX: Don't preclude handling different sized sigset_t's. */ /* XXX: Don't preclude handling different sized sigset_t's. */
if (sigsetsize != sizeof(sigset_t)) if (sigsetsize != sizeof(sigset_t))
...@@ -169,7 +170,7 @@ sys32_sigaction(int sig, const struct old_sigaction32 *act, ...@@ -169,7 +170,7 @@ sys32_sigaction(int sig, const struct old_sigaction32 *act,
int ret; int ret;
if (act) { if (act) {
old_sigset_t32 mask; compat_old_sigset_t mask;
if (verify_area(VERIFY_READ, act, sizeof(*act)) || if (verify_area(VERIFY_READ, act, sizeof(*act)) ||
__get_user((unsigned long)new_ka.sa.sa_handler, &act->sa_handler) || __get_user((unsigned long)new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user((unsigned long)new_ka.sa.sa_restorer, &act->sa_restorer)) __get_user((unsigned long)new_ka.sa.sa_restorer, &act->sa_restorer))
...@@ -202,16 +203,16 @@ sys32_rt_sigaction(int sig, const struct sigaction32 *act, ...@@ -202,16 +203,16 @@ sys32_rt_sigaction(int sig, const struct sigaction32 *act,
{ {
struct k_sigaction new_ka, old_ka; struct k_sigaction new_ka, old_ka;
int ret; int ret;
sigset_t32 set32; compat_sigset_t set32;
/* XXX: Don't preclude handling different sized sigset_t's. */ /* XXX: Don't preclude handling different sized sigset_t's. */
if (sigsetsize != sizeof(sigset_t32)) if (sigsetsize != sizeof(compat_sigset_t))
return -EINVAL; return -EINVAL;
if (act) { if (act) {
ret = get_user((unsigned long)new_ka.sa.sa_handler, &act->sa_handler); ret = get_user((unsigned long)new_ka.sa.sa_handler, &act->sa_handler);
ret |= __copy_from_user(&set32, &act->sa_mask, ret |= __copy_from_user(&set32, &act->sa_mask,
sizeof(sigset_t32)); sizeof(compat_sigset_t));
switch (_NSIG_WORDS) { switch (_NSIG_WORDS) {
case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6] case 4: new_ka.sa.sa_mask.sig[3] = set32.sig[6]
| (((long)set32.sig[7]) << 32); | (((long)set32.sig[7]) << 32);
...@@ -247,7 +248,7 @@ sys32_rt_sigaction(int sig, const struct sigaction32 *act, ...@@ -247,7 +248,7 @@ sys32_rt_sigaction(int sig, const struct sigaction32 *act,
} }
ret = put_user((unsigned long)old_ka.sa.sa_handler, &oact->sa_handler); ret = put_user((unsigned long)old_ka.sa.sa_handler, &oact->sa_handler);
ret |= __copy_to_user(&oact->sa_mask, &set32, ret |= __copy_to_user(&oact->sa_mask, &set32,
sizeof(sigset_t32)); sizeof(compat_sigset_t));
ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags); ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
} }
......
...@@ -80,4 +80,11 @@ struct compat_statfs { ...@@ -80,4 +80,11 @@ struct compat_statfs {
s32 f_spare[6]; s32 f_spare[6];
}; };
typedef u32 compat_old_sigset_t; /* at least 32 bits */
#define _COMPAT_NSIG 64
#define _COMPAT_NSIG_BPW 32
typedef u32 compat_sigset_word;
#endif /* _ASM_S390X_COMPAT_H */ #endif /* _ASM_S390X_COMPAT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment