Commit 12bae235 authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky
Browse files

[S390] uaccess error handling.



Consider return values for all user space access function and
return -EFAULT on error.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent c2b1449b
...@@ -757,7 +757,9 @@ asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args) ...@@ -757,7 +757,9 @@ asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
put_user(oldlen, (u32 __user *)compat_ptr(tmp.oldlenp))) put_user(oldlen, (u32 __user *)compat_ptr(tmp.oldlenp)))
error = -EFAULT; error = -EFAULT;
} }
copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused)); if (copy_to_user(args->__unused, tmp.__unused,
sizeof(tmp.__unused)))
error = -EFAULT;
} }
return error; return error;
} }
......
...@@ -169,12 +169,12 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act, ...@@ -169,12 +169,12 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
compat_old_sigset_t mask; compat_old_sigset_t mask;
if (!access_ok(VERIFY_READ, act, sizeof(*act)) || if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(sa_handler, &act->sa_handler) || __get_user(sa_handler, &act->sa_handler) ||
__get_user(sa_restorer, &act->sa_restorer)) __get_user(sa_restorer, &act->sa_restorer) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
__get_user(mask, &act->sa_mask))
return -EFAULT; return -EFAULT;
new_ka.sa.sa_handler = (__sighandler_t) sa_handler; new_ka.sa.sa_handler = (__sighandler_t) sa_handler;
new_ka.sa.sa_restorer = (void (*)(void)) sa_restorer; new_ka.sa.sa_restorer = (void (*)(void)) sa_restorer;
__get_user(new_ka.sa.sa_flags, &act->sa_flags);
__get_user(mask, &act->sa_mask);
siginitset(&new_ka.sa.sa_mask, mask); siginitset(&new_ka.sa.sa_mask, mask);
} }
...@@ -185,10 +185,10 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act, ...@@ -185,10 +185,10 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
sa_restorer = (unsigned long) old_ka.sa.sa_restorer; sa_restorer = (unsigned long) old_ka.sa.sa_restorer;
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(sa_handler, &oact->sa_handler) || __put_user(sa_handler, &oact->sa_handler) ||
__put_user(sa_restorer, &oact->sa_restorer)) __put_user(sa_restorer, &oact->sa_restorer) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
return -EFAULT; return -EFAULT;
__put_user(old_ka.sa.sa_flags, &oact->sa_flags);
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
} }
return ret; return ret;
......
...@@ -80,10 +80,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, ...@@ -80,10 +80,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
old_sigset_t mask; old_sigset_t mask;
if (!access_ok(VERIFY_READ, act, sizeof(*act)) || if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) || __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) __get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
__get_user(mask, &act->sa_mask))
return -EFAULT; return -EFAULT;
__get_user(new_ka.sa.sa_flags, &act->sa_flags);
__get_user(mask, &act->sa_mask);
siginitset(&new_ka.sa.sa_mask, mask); siginitset(&new_ka.sa.sa_mask, mask);
} }
...@@ -92,10 +92,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act, ...@@ -92,10 +92,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
if (!ret && oact) { if (!ret && oact) {
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) || __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
__put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
return -EFAULT; return -EFAULT;
__put_user(old_ka.sa.sa_flags, &oact->sa_flags);
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
} }
return ret; return ret;
......
...@@ -462,7 +462,8 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code) ...@@ -462,7 +462,8 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
local_irq_enable(); local_irq_enable();
if (regs->psw.mask & PSW_MASK_PSTATE) { if (regs->psw.mask & PSW_MASK_PSTATE) {
get_user(*((__u16 *) opcode), (__u16 __user *) location); if (get_user(*((__u16 *) opcode), (__u16 __user *) location))
return;
if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) { if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
if (current->ptrace & PT_PTRACED) if (current->ptrace & PT_PTRACED)
force_sig(SIGTRAP, current); force_sig(SIGTRAP, current);
...@@ -470,20 +471,25 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code) ...@@ -470,20 +471,25 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
signal = SIGILL; signal = SIGILL;
#ifdef CONFIG_MATHEMU #ifdef CONFIG_MATHEMU
} else if (opcode[0] == 0xb3) { } else if (opcode[0] == 0xb3) {
get_user(*((__u16 *) (opcode+2)), location+1); if (get_user(*((__u16 *) (opcode+2)), location+1))
return;
signal = math_emu_b3(opcode, regs); signal = math_emu_b3(opcode, regs);
} else if (opcode[0] == 0xed) { } else if (opcode[0] == 0xed) {
get_user(*((__u32 *) (opcode+2)), if (get_user(*((__u32 *) (opcode+2)),
(__u32 __user *)(location+1)); (__u32 __user *)(location+1)))
return;
signal = math_emu_ed(opcode, regs); signal = math_emu_ed(opcode, regs);
} else if (*((__u16 *) opcode) == 0xb299) { } else if (*((__u16 *) opcode) == 0xb299) {
get_user(*((__u16 *) (opcode+2)), location+1); if (get_user(*((__u16 *) (opcode+2)), location+1))
return;
signal = math_emu_srnm(opcode, regs); signal = math_emu_srnm(opcode, regs);
} else if (*((__u16 *) opcode) == 0xb29c) { } else if (*((__u16 *) opcode) == 0xb29c) {
get_user(*((__u16 *) (opcode+2)), location+1); if (get_user(*((__u16 *) (opcode+2)), location+1))
return;
signal = math_emu_stfpc(opcode, regs); signal = math_emu_stfpc(opcode, regs);
} else if (*((__u16 *) opcode) == 0xb29d) { } else if (*((__u16 *) opcode) == 0xb29d) {
get_user(*((__u16 *) (opcode+2)), location+1); if (get_user(*((__u16 *) (opcode+2)), location+1))
return;
signal = math_emu_lfpc(opcode, regs); signal = math_emu_lfpc(opcode, regs);
#endif #endif
} else } else
......
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