Fri Oct 14 08:38:31 2016 UTC ()
Trailing whitespace


(skrll)
diff -r1.171 -r1.172 src/sys/kern/sys_process.c

cvs diff -r1.171 -r1.172 src/sys/kern/sys_process.c (expand / switch to unified diff)

--- src/sys/kern/sys_process.c 2016/10/14 08:37:05 1.171
+++ src/sys/kern/sys_process.c 2016/10/14 08:38:31 1.172
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: sys_process.c,v 1.171 2016/10/14 08:37:05 skrll Exp $ */ 1/* $NetBSD: sys_process.c,v 1.172 2016/10/14 08:38:31 skrll 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_process.c,v 1.171 2016/10/14 08:37:05 skrll Exp $"); 121__KERNEL_RCSID(0, "$NetBSD: sys_process.c,v 1.172 2016/10/14 08:38:31 skrll Exp $");
122 122
123#include "opt_ptrace.h" 123#include "opt_ptrace.h"
124#include "opt_ktrace.h" 124#include "opt_ktrace.h"
125#include "opt_pax.h" 125#include "opt_pax.h"
126 126
127#include <sys/param.h> 127#include <sys/param.h>
128#include <sys/systm.h> 128#include <sys/systm.h>
129#include <sys/proc.h> 129#include <sys/proc.h>
130#include <sys/errno.h> 130#include <sys/errno.h>
131#include <sys/exec.h> 131#include <sys/exec.h>
132#include <sys/pax.h> 132#include <sys/pax.h>
133#include <sys/ptrace.h> 133#include <sys/ptrace.h>
134#include <sys/uio.h> 134#include <sys/uio.h>
@@ -651,43 +651,43 @@ sys_ptrace(struct lwp *l, const struct s @@ -651,43 +651,43 @@ sys_ptrace(struct lwp *l, const struct s
651 tmp = SCARG(uap, data); 651 tmp = SCARG(uap, data);
652 if (tmp >= 0) { 652 if (tmp >= 0) {
653#ifdef PT_STEP 653#ifdef PT_STEP
654 if (req == PT_STEP) 654 if (req == PT_STEP)
655 signo = 0; 655 signo = 0;
656 else 656 else
657#endif 657#endif
658 { 658 {
659 signo = tmp; 659 signo = tmp;
660 tmp = 0; /* don't search for LWP */ 660 tmp = 0; /* don't search for LWP */
661 } 661 }
662 } else 662 } else
663 tmp = -tmp; 663 tmp = -tmp;
664  664
665 if (tmp > 0) { 665 if (tmp > 0) {
666 if (req == PT_DETACH) { 666 if (req == PT_DETACH) {
667 error = EINVAL; 667 error = EINVAL;
668 break; 668 break;
669 } 669 }
670 lwp_delref2 (lt); 670 lwp_delref2 (lt);
671 lt = lwp_find(t, tmp); 671 lt = lwp_find(t, tmp);
672 if (lt == NULL) { 672 if (lt == NULL) {
673 error = ESRCH; 673 error = ESRCH;
674 break; 674 break;
675 } 675 }
676 lwp_addref(lt); 676 lwp_addref(lt);
677 resume_all = 0; 677 resume_all = 0;
678 signo = 0; 678 signo = 0;
679 } 679 }
680  680
681 /* 681 /*
682 * From the 4.4BSD PRM: 682 * From the 4.4BSD PRM:
683 * "The data argument is taken as a signal number and the 683 * "The data argument is taken as a signal number and the
684 * child's execution continues at location addr as if it 684 * child's execution continues at location addr as if it
685 * incurred that signal. Normally the signal number will 685 * incurred that signal. Normally the signal number will
686 * be either 0 to indicate that the signal that caused the 686 * be either 0 to indicate that the signal that caused the
687 * stop should be ignored, or that value fetched out of 687 * stop should be ignored, or that value fetched out of
688 * the process's image indicating which signal caused 688 * the process's image indicating which signal caused
689 * the stop. If addr is (int *)1 then execution continues 689 * the stop. If addr is (int *)1 then execution continues
690 * from where it stopped." 690 * from where it stopped."
691 */ 691 */
692 692
693 /* Check that the data is a valid signal number or zero. */ 693 /* Check that the data is a valid signal number or zero. */
@@ -794,27 +794,27 @@ sys_ptrace(struct lwp *l, const struct s @@ -794,27 +794,27 @@ sys_ptrace(struct lwp *l, const struct s
794 } 794 }
795 SET(t->p_slflag, PSL_TRACED); 795 SET(t->p_slflag, PSL_TRACED);
796 signo = SIGSTOP; 796 signo = SIGSTOP;
797 goto sendsig; 797 goto sendsig;
798 798
799 case PT_GET_EVENT_MASK: 799 case PT_GET_EVENT_MASK:
800 if (SCARG(uap, data) != sizeof(pe)) { 800 if (SCARG(uap, data) != sizeof(pe)) {
801 DPRINTF(("ptrace(%d): %d != %zu\n", req, 801 DPRINTF(("ptrace(%d): %d != %zu\n", req,
802 SCARG(uap, data), sizeof(pe))); 802 SCARG(uap, data), sizeof(pe)));
803 error = EINVAL; 803 error = EINVAL;
804 break; 804 break;
805 } 805 }
806 memset(&pe, 0, sizeof(pe)); 806 memset(&pe, 0, sizeof(pe));
807 pe.pe_set_event = ISSET(t->p_slflag, PSL_TRACEFORK) ?  807 pe.pe_set_event = ISSET(t->p_slflag, PSL_TRACEFORK) ?
808 PTRACE_FORK : 0; 808 PTRACE_FORK : 0;
809 error = copyout(&pe, SCARG(uap, addr), sizeof(pe)); 809 error = copyout(&pe, SCARG(uap, addr), sizeof(pe));
810 break; 810 break;
811 811
812 case PT_SET_EVENT_MASK: 812 case PT_SET_EVENT_MASK:
813 if (SCARG(uap, data) != sizeof(pe)) { 813 if (SCARG(uap, data) != sizeof(pe)) {
814 DPRINTF(("ptrace(%d): %d != %zu\n", req, 814 DPRINTF(("ptrace(%d): %d != %zu\n", req,
815 SCARG(uap, data), sizeof(pe))); 815 SCARG(uap, data), sizeof(pe)));
816 error = EINVAL; 816 error = EINVAL;
817 break; 817 break;
818 } 818 }
819 if ((error = copyin(SCARG(uap, addr), &pe, sizeof(pe))) != 0) 819 if ((error = copyin(SCARG(uap, addr), &pe, sizeof(pe))) != 0)
820 return error; 820 return error;