]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
arm64: compat: Don't pull syscall number from regs in arm_compat_syscall
authorWill Deacon <will.deacon@arm.com>
Thu, 3 Jan 2019 18:00:39 +0000 (18:00 +0000)
committerWill Deacon <will.deacon@arm.com>
Fri, 4 Jan 2019 14:18:01 +0000 (14:18 +0000)
The syscall number may have been changed by a tracer, so we should pass
the actual number in from the caller instead of pulling it from the
saved r7 value directly.

Cc: <stable@vger.kernel.org>
Cc: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/kernel/sys_compat.c
arch/arm64/kernel/syscall.c

index a79db4e485a64f906a6ee920c7e448f8737ea839..bc348ab3dd6b41072f1b0e700f475a1a4523505f 100644 (file)
@@ -66,12 +66,11 @@ do_compat_cache_op(unsigned long start, unsigned long end, int flags)
 /*
  * Handle all unrecognised system calls.
  */
-long compat_arm_syscall(struct pt_regs *regs)
+long compat_arm_syscall(struct pt_regs *regs, int scno)
 {
-       unsigned int no = regs->regs[7];
        void __user *addr;
 
-       switch (no) {
+       switch (scno) {
        /*
         * Flush a region from virtual address 'r0' to virtual address 'r1'
         * _exclusive_.  There is no alignment requirement on either address;
@@ -107,7 +106,7 @@ long compat_arm_syscall(struct pt_regs *regs)
                 * way the calling program can gracefully determine whether
                 * a feature is supported.
                 */
-               if (no < __ARM_NR_COMPAT_END)
+               if (scno < __ARM_NR_COMPAT_END)
                        return -ENOSYS;
                break;
        }
@@ -116,6 +115,6 @@ long compat_arm_syscall(struct pt_regs *regs)
                (compat_thumb_mode(regs) ? 2 : 4);
 
        arm64_notify_die("Oops - bad compat syscall(2)", regs,
-                        SIGILL, ILL_ILLTRP, addr, no);
+                        SIGILL, ILL_ILLTRP, addr, scno);
        return 0;
 }
index 032d223128815bbfdf0b9f5e4b85a22ce2ab7e2f..5610ac01c1ec0212fe5bb4082c58b5e1f9f4dcb2 100644 (file)
 #include <asm/thread_info.h>
 #include <asm/unistd.h>
 
-long compat_arm_syscall(struct pt_regs *regs);
-
+long compat_arm_syscall(struct pt_regs *regs, int scno);
 long sys_ni_syscall(void);
 
-asmlinkage long do_ni_syscall(struct pt_regs *regs)
+static long do_ni_syscall(struct pt_regs *regs, int scno)
 {
 #ifdef CONFIG_COMPAT
        long ret;
        if (is_compat_task()) {
-               ret = compat_arm_syscall(regs);
+               ret = compat_arm_syscall(regs, scno);
                if (ret != -ENOSYS)
                        return ret;
        }
@@ -47,7 +46,7 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno,
                syscall_fn = syscall_table[array_index_nospec(scno, sc_nr)];
                ret = __invoke_syscall(regs, syscall_fn);
        } else {
-               ret = do_ni_syscall(regs);
+               ret = do_ni_syscall(regs, scno);
        }
 
        regs->regs[0] = ret;