Thu Jan 26 03:54:01 2017 UTC ()
don't return early holding a lock!


(christos)
diff -r1.11 -r1.12 src/sys/kern/sys_ptrace_common.c

cvs diff -r1.11 -r1.12 src/sys/kern/sys_ptrace_common.c (expand / switch to unified diff)

--- src/sys/kern/sys_ptrace_common.c 2017/01/25 17:55:47 1.11
+++ src/sys/kern/sys_ptrace_common.c 2017/01/26 03:54:01 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sys_ptrace_common.c,v 1.11 2017/01/25 17:55:47 christos Exp $ */ 1/* $NetBSD: sys_ptrace_common.c,v 1.12 2017/01/26 03:54:01 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -108,27 +108,27 @@ @@ -108,27 +108,27 @@
108 108
109/* 109/*
110 * References: 110 * References:
111 * (1) Bach's "The Design of the UNIX Operating System", 111 * (1) Bach's "The Design of the UNIX Operating System",
112 * (2) sys/miscfs/procfs from UCB's 4.4BSD-Lite distribution, 112 * (2) sys/miscfs/procfs from UCB's 4.4BSD-Lite distribution,
113 * (3) the "4.4BSD Programmer's Reference Manual" published 113 * (3) the "4.4BSD Programmer's Reference Manual" published
114 * by USENIX and O'Reilly & Associates. 114 * by USENIX and O'Reilly & Associates.
115 * The 4.4BSD PRM does a reasonably good job of documenting what the various 115 * The 4.4BSD PRM does a reasonably good job of documenting what the various
116 * ptrace() requests should actually do, and its text is quoted several times 116 * ptrace() requests should actually do, and its text is quoted several times
117 * in this file. 117 * in this file.
118 */ 118 */
119 119
120#include <sys/cdefs.h> 120#include <sys/cdefs.h>
121__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.11 2017/01/25 17:55:47 christos Exp $"); 121__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.12 2017/01/26 03:54:01 christos Exp $");
122 122
123#ifdef _KERNEL_OPT 123#ifdef _KERNEL_OPT
124#include "opt_ptrace.h" 124#include "opt_ptrace.h"
125#include "opt_ktrace.h" 125#include "opt_ktrace.h"
126#include "opt_pax.h" 126#include "opt_pax.h"
127#endif 127#endif
128 128
129#include <sys/param.h> 129#include <sys/param.h>
130#include <sys/systm.h> 130#include <sys/systm.h>
131#include <sys/proc.h> 131#include <sys/proc.h>
132#include <sys/errno.h> 132#include <sys/errno.h>
133#include <sys/exec.h> 133#include <sys/exec.h>
134#include <sys/pax.h> 134#include <sys/pax.h>
@@ -616,28 +616,26 @@ do_ptrace(struct ptrace_methods *ptm, st @@ -616,28 +616,26 @@ do_ptrace(struct ptrace_methods *ptm, st
616 } 616 }
617 uio.uio_rw = UIO_WRITE; 617 uio.uio_rw = UIO_WRITE;
618 break; 618 break;
619 case PIOD_READ_AUXV: 619 case PIOD_READ_AUXV:
620 req = PT_READ_D; 620 req = PT_READ_D;
621 uio.uio_rw = UIO_READ; 621 uio.uio_rw = UIO_READ;
622 tmp = t->p_execsw->es_arglen; 622 tmp = t->p_execsw->es_arglen;
623 if (uio.uio_offset > tmp) 623 if (uio.uio_offset > tmp)
624 return EIO; 624 return EIO;
625 if (uio.uio_resid > tmp - uio.uio_offset) 625 if (uio.uio_resid > tmp - uio.uio_offset)
626 uio.uio_resid = tmp - uio.uio_offset; 626 uio.uio_resid = tmp - uio.uio_offset;
627 piod.piod_len = iov.iov_len = uio.uio_resid; 627 piod.piod_len = iov.iov_len = uio.uio_resid;
628 error = process_auxv_offset(t, &uio); 628 error = process_auxv_offset(t, &uio);
629 if (error) 
630 return error; 
631 break; 629 break;
632 default: 630 default:
633 error = EINVAL; 631 error = EINVAL;
634 break; 632 break;
635 } 633 }
636 if (error) 634 if (error)
637 break; 635 break;
638 error = proc_vmspace_getref(l->l_proc, &vm); 636 error = proc_vmspace_getref(l->l_proc, &vm);
639 if (error) 637 if (error)
640 break; 638 break;
641 uio.uio_vmspace = vm; 639 uio.uio_vmspace = vm;
642 640
643 error = process_domem(l, lt, &uio); 641 error = process_domem(l, lt, &uio);