Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386/i386 Do not dereference user pointer in ptrace...



details:   https://anonhg.NetBSD.org/src/rev/26a3f48b0489
branches:  trunk
changeset: 964521:26a3f48b0489
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Aug 06 02:04:43 2019 +0000

description:
Do not dereference user pointer in ptrace_machdep_dorequest()/i386

Always use copyin(9) for reading user memory.

diffstat:

 sys/arch/i386/i386/process_machdep.c |  12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r 9aab17731a72 -r 26a3f48b0489 sys/arch/i386/i386/process_machdep.c
--- a/sys/arch/i386/i386/process_machdep.c      Tue Aug 06 01:53:47 2019 +0000
+++ b/sys/arch/i386/i386/process_machdep.c      Tue Aug 06 02:04:43 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process_machdep.c,v 1.93 2019/06/26 12:30:12 mgorny Exp $      */
+/*     $NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $       */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.93 2019/06/26 12:30:12 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.94 2019/08/06 02:04:43 kamil Exp $");
 
 #include "opt_ptrace.h"
 
@@ -281,7 +281,7 @@
 {
        struct uio uio;
        struct iovec iov;
-       struct iovec *user_iov = (struct iovec*)addr;
+       struct iovec user_iov;
        struct vmspace *vm;
        int error;
        int write = 0;
@@ -319,12 +319,14 @@
                /* write = 0 done above. */
                if (!process_machdep_validxstate(lt->l_proc))
                        return EINVAL;
+               if ((error = copyin(addr, &user_iov, sizeof(user_iov))) != 0)
+                       return error;
                error = proc_vmspace_getref(l->l_proc, &vm);
                if (error) {
                        return error;
                }
-               iov.iov_base = user_iov->iov_base;
-               iov.iov_len = user_iov->iov_len;
+               iov.iov_base = user_iov.iov_base;
+               iov.iov_len = user_iov.iov_len;
                if (iov.iov_len > sizeof(struct xstate))
                        iov.iov_len = sizeof(struct xstate);
                uio.uio_iov = &iov;



Home | Main Index | Thread Index | Old Index