Module Name: src Committed By: kamil Date: Sat Oct 12 10:55:23 UTC 2019
Modified Files: src/sys/kern: kern_exec.c kern_fork.c kern_proc.c kern_sig.c Log Message: Remove p_oppid from struct proc This field is not needed as it duplicated p_opptr that is alread safe to use, unless proven otherwise. eventswitch() already contained a check for != initproc (pid1). Ride ABI bump for 9.99.16. To generate a diff of this commit: cvs rdiff -u -r1.482 -r1.483 src/sys/kern/kern_exec.c cvs rdiff -u -r1.214 -r1.215 src/sys/kern/kern_fork.c cvs rdiff -u -r1.235 -r1.236 src/sys/kern/kern_proc.c cvs rdiff -u -r1.367 -r1.368 src/sys/kern/kern_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.482 src/sys/kern/kern_exec.c:1.483 --- src/sys/kern/kern_exec.c:1.482 Mon Sep 30 21:13:33 2019 +++ src/sys/kern/kern_exec.c Sat Oct 12 10:55:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.482 2019/09/30 21:13:33 kamil Exp $ */ +/* $NetBSD: kern_exec.c,v 1.483 2019/10/12 10:55:23 kamil Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.482 2019/09/30 21:13:33 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.483 2019/10/12 10:55:23 kamil Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -2249,7 +2249,7 @@ spawn_return(void *arg) } mutex_enter(p->p_lock); - eventswitch(TRAP_CHLD, PTRACE_POSIX_SPAWN, p->p_oppid); + eventswitch(TRAP_CHLD, PTRACE_POSIX_SPAWN, p->p_opptr->p_pid); } cpu_return: @@ -2630,7 +2630,6 @@ do_posix_spawn(struct lwp *l1, pid_t *pi if ((p1->p_slflag & (PSL_TRACEPOSIX_SPAWN|PSL_TRACED)) == (PSL_TRACEPOSIX_SPAWN|PSL_TRACED)) { proc_changeparent(p2, p1->p_pptr); - p2->p_oppid = p1->p_pid; } LIST_INSERT_AFTER(p1, p2, p_pglist); Index: src/sys/kern/kern_fork.c diff -u src/sys/kern/kern_fork.c:1.214 src/sys/kern/kern_fork.c:1.215 --- src/sys/kern/kern_fork.c:1.214 Mon Sep 30 21:13:33 2019 +++ src/sys/kern/kern_fork.c Sat Oct 12 10:55:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.214 2019/09/30 21:13:33 kamil Exp $ */ +/* $NetBSD: kern_fork.c,v 1.215 2019/10/12 10:55:23 kamil Exp $ */ /*- * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.214 2019/09/30 21:13:33 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.215 2019/10/12 10:55:23 kamil Exp $"); #include "opt_ktrace.h" #include "opt_dtrace.h" @@ -510,10 +510,8 @@ fork1(struct lwp *l1, int flags, int exi /* * Trace fork(2) and vfork(2)-like events on demand in a debugger. */ - if (tracefork(p1, flags) || tracevfork(p1, flags)) { + if (tracefork(p1, flags) || tracevfork(p1, flags)) proc_changeparent(p2, p1->p_pptr); - p2->p_oppid = p1->p_pid; - } LIST_INSERT_AFTER(p1, p2, p_pglist); LIST_INSERT_HEAD(&allproc, p2, p_list); @@ -640,7 +638,7 @@ child_return(void *arg) mutex_enter(p->p_lock); eventswitch(TRAP_CHLD, ISSET(p->p_lflag, PL_PPWAIT) ? PTRACE_VFORK : PTRACE_FORK, - p->p_oppid); + p->p_opptr->p_pid); } my_tracer_is_gone: Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.235 src/sys/kern/kern_proc.c:1.236 --- src/sys/kern/kern_proc.c:1.235 Mon Sep 30 21:13:33 2019 +++ src/sys/kern/kern_proc.c Sat Oct 12 10:55:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.235 2019/09/30 21:13:33 kamil Exp $ */ +/* $NetBSD: kern_proc.c,v 1.236 2019/10/12 10:55:23 kamil Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.235 2019/09/30 21:13:33 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.236 2019/10/12 10:55:23 kamil Exp $"); #ifdef _KERNEL_OPT #include "opt_kstack.h" @@ -2263,7 +2263,6 @@ fill_proc(const struct proc *psrc, struc COND_SET_VALUE(p->p_sigpend, psrc->p_sigpend, allowaddr); COND_SET_VALUE(p->p_lwpctl, psrc->p_lwpctl, allowaddr); p->p_ppid = psrc->p_ppid; - p->p_oppid = psrc->p_oppid; COND_SET_VALUE(p->p_path, psrc->p_path, allowaddr); COND_SET_VALUE(p->p_sigctx, psrc->p_sigctx, allowaddr); p->p_nice = psrc->p_nice; Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.367 src/sys/kern/kern_sig.c:1.368 --- src/sys/kern/kern_sig.c:1.367 Tue Oct 8 18:02:46 2019 +++ src/sys/kern/kern_sig.c Sat Oct 12 10:55:23 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.367 2019/10/08 18:02:46 kamil Exp $ */ +/* $NetBSD: kern_sig.c,v 1.368 2019/10/12 10:55:23 kamil Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.367 2019/10/08 18:02:46 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.368 2019/10/12 10:55:23 kamil Exp $"); #include "opt_ptrace.h" #include "opt_dtrace.h" @@ -1599,6 +1599,8 @@ eventswitch(int code, int pe_report_even KASSERT(p->p_nrlwps > 0); KASSERT((code == TRAP_CHLD) || (code == TRAP_LWP) || (code == TRAP_EXEC)); + KASSERT((code != TRAP_CHLD) || (entity > 1)); /* prevent pid1 */ + KASSERT((code != TRAP_LWP) || (entity > 0)); repeat: /*