]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[S390] uaccess error handling.
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Fri, 27 Oct 2006 10:39:22 +0000 (12:39 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 27 Oct 2006 10:39:22 +0000 (12:39 +0200)
Consider return values for all user space access function and
return -EFAULT on error.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/kernel/compat_linux.c
arch/s390/kernel/compat_signal.c
arch/s390/kernel/signal.c
arch/s390/kernel/traps.c

index 2001767e1dc7aa2fa40020f1874f84d3b7055173..5b33f823863aa5af69c4c99de0d1b2b8afc84b99 100644 (file)
@@ -757,7 +757,9 @@ asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
                            put_user(oldlen, (u32 __user *)compat_ptr(tmp.oldlenp)))
                                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;
 }
index d49b876a83bf5af6995aae9f0237185f19f42eee..861888ab8c13d6cbb18ae89bc716577db5370f1e 100644 (file)
@@ -169,12 +169,12 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
                compat_old_sigset_t mask;
                if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
                    __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;
                new_ka.sa.sa_handler = (__sighandler_t) sa_handler;
                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);
         }
 
@@ -185,10 +185,10 @@ sys32_sigaction(int sig, const struct old_sigaction32 __user *act,
                sa_restorer = (unsigned long) old_ka.sa.sa_restorer;
                if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
                    __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;
-               __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
-               __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
         }
 
        return ret;
index 4392a77cbae88bc735f28c44d903b175b7652d1e..4c8a7954ef48b28274cdf61833e9f31609f2ff70 100644 (file)
@@ -80,10 +80,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
                old_sigset_t mask;
                if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
                    __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;
-               __get_user(new_ka.sa.sa_flags, &act->sa_flags);
-               __get_user(mask, &act->sa_mask);
                siginitset(&new_ka.sa.sa_mask, mask);
        }
 
@@ -92,10 +92,10 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
        if (!ret && 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_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;
-               __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
-               __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
        }
 
        return ret;
index 66375a5e3d12f0d11020f4465afa97a7084452e8..92ecffbc8d8233352589b700f5eefa4f165fe832 100644 (file)
@@ -462,7 +462,8 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
                local_irq_enable();
 
        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 (current->ptrace & PT_PTRACED)
                                force_sig(SIGTRAP, current);
@@ -470,20 +471,25 @@ asmlinkage void illegal_op(struct pt_regs * regs, long interruption_code)
                                signal = SIGILL;
 #ifdef CONFIG_MATHEMU
                } 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);
                 } else if (opcode[0] == 0xed) {
-                       get_user(*((__u32 *) (opcode+2)),
-                                (__u32 __user *)(location+1));
+                       if (get_user(*((__u32 *) (opcode+2)),
+                                    (__u32 __user *)(location+1)))
+                               return;
                        signal = math_emu_ed(opcode, regs);
                } 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);
                } 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);
                } 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);
 #endif
                } else