Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Reject ptrace(2) PIOD_READ/WRITE operations with le...



details:   https://anonhg.NetBSD.org/src/rev/b1e3b77d4a71
branches:  trunk
changeset: 841144:b1e3b77d4a71
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue Apr 30 22:32:01 2019 +0000

description:
Reject ptrace(2) PIOD_READ/WRITE operations with length 0

Return EINVAL for such invalid requests.

diffstat:

 sys/kern/sys_ptrace_common.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r 87f60f8e67b5 -r b1e3b77d4a71 sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c      Tue Apr 30 22:24:27 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c      Tue Apr 30 22:32:01 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_ptrace_common.c,v 1.49 2019/04/30 20:50:30 kamil Exp $     */
+/*     $NetBSD: sys_ptrace_common.c,v 1.50 2019/04/30 22:32:01 kamil Exp $     */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.49 2019/04/30 20:50:30 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.50 2019/04/30 22:32:01 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ptrace.h"
@@ -1117,6 +1117,10 @@
        case PT_IO:
                if ((error = ptm->ptm_copyin_piod(&piod, addr, data)) != 0)
                        break;
+               if (piod.piod_len < 1) {
+                       error = EINVAL;
+                       break;
+               }
                if ((error = ptrace_doio(l, t, lt, &piod, addr, false)) != 0)
                        break;
                if (piod.piod_len < 1) {



Home | Main Index | Thread Index | Old Index