Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys/arch/arm/arm Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/d058e17deab0
branches:  netbsd-8
changeset: 435007:d058e17deab0
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Jun 05 08:04:34 2018 +0000

description:
Pull up following revision(s) (requested by martin in ticket #859):
        sys/arch/arm/arm/syscall.c: revision 1.65
PR kern/53261: handle SYS_syscall indirection in MD code - the generic
version would misalign the argument array.

diffstat:

 sys/arch/arm/arm/syscall.c |  31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)

diffs (66 lines):

diff -r 1cc800a60e64 -r d058e17deab0 sys/arch/arm/arm/syscall.c
--- a/sys/arch/arm/arm/syscall.c        Tue May 22 17:51:55 2018 +0000
+++ b/sys/arch/arm/arm/syscall.c        Tue Jun 05 08:04:34 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: syscall.c,v 1.60 2014/08/13 21:41:32 matt Exp $        */
+/*     $NetBSD: syscall.c,v 1.60.12.1 2018/06/05 08:04:34 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2000, 2003 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.60 2014/08/13 21:41:32 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.60.12.1 2018/06/05 08:04:34 bouyer Exp $");
 
 #include <sys/cpu.h>
 #include <sys/device.h>
@@ -202,9 +202,10 @@
        struct proc * const p = l->l_proc;
        const struct sysent *callp;
        int error;
-       u_int nargs;
+       u_int nargs, off = 0;
        register_t *args;
-       uint64_t copyargs64[sizeof(register_t)*(2+SYS_MAXSYSARGS+1)/sizeof(uint64_t)];
+       uint64_t copyargs64[sizeof(register_t) *
+                           (2+SYS_MAXSYSARGS+1)/sizeof(uint64_t)];
        register_t *copyargs = (register_t *)copyargs64;
        register_t rval[2];
        ksiginfo_t ksi;
@@ -237,17 +238,29 @@
        }
 
        code &= (SYS_NSYSENT - 1);
+
+       if (__predict_false(code == SYS_syscall)) {
+               off = 1;
+               code = tf->tf_r0;
+               code &= (SYS_NSYSENT - 1);
+               if (__predict_false(code == SYS_syscall)) {
+                       error = EINVAL;
+                       goto bad;
+               }
+       }
+
        callp = p->p_emul->e_sysent + code;
        nargs = callp->sy_narg;
-       if (nargs > 4) {
+
+       if ((nargs+off) > 4) {
                args = copyargs;
-               memcpy(args, &tf->tf_r0, 4 * sizeof(register_t));
-               error = copyin((void *)tf->tf_usr_sp, args + 4,
-                   (nargs - 4) * sizeof(register_t));
+               memcpy(args, &tf->tf_r0+off, (4-off) * sizeof(register_t));
+               error = copyin((void *)tf->tf_usr_sp, args + 4 - off,
+                   (nargs - 4 + off) * sizeof(register_t));
                if (error)
                        goto bad;
        } else {
-               args = &tf->tf_r0;
+               args = &tf->tf_r0 + off;
        }
 
        error = sy_invoke(callp, l, args, rval, code);



Home | Main Index | Thread Index | Old Index