diff options
author | mvs <mvs@cvs.openbsd.org> | 2021-01-17 15:28:23 +0000 |
---|---|---|
committer | mvs <mvs@cvs.openbsd.org> | 2021-01-17 15:28:23 +0000 |
commit | 6a4f30308eefd922b7f297530d729f064fc0e517 (patch) | |
tree | 8732cd46cbc60c81451796d442406c3dacae919b | |
parent | 1214f8430a6c6a970a99c0af38ce050234e52714 (diff) |
Cache parent's pid as `ps_ppid' and use it instead of `ps_pptr->ps_pid'.
This allows us to unlock getppid(2).
ok mpi@
-rw-r--r-- | sys/kern/exec_elf.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 3 | ||||
-rw-r--r-- | sys/kern/kern_prot.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 4 | ||||
-rw-r--r-- | sys/sys/proc.h | 3 |
6 files changed, 12 insertions, 9 deletions
diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index 1dd14cb1b04..dff4c99c341 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.156 2020/12/07 16:55:28 mpi Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.157 2021/01/17 15:28:21 mvs Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -1257,7 +1257,7 @@ coredump_notes_elf(struct proc *p, void *iocookie, size_t *sizep) cpi.cpi_sigcatch = pr->ps_sigacts->ps_sigcatch; cpi.cpi_pid = pr->ps_pid; - cpi.cpi_ppid = pr->ps_pptr->ps_pid; + cpi.cpi_ppid = pr->ps_ppid; cpi.cpi_pgrp = pr->ps_pgid; if (pr->ps_session->s_leader) cpi.cpi_sid = pr->ps_session->s_leader->ps_pid; diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 4738000e10d..89326bd6fbc 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.193 2020/12/09 18:58:19 mpi Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.194 2021/01/17 15:28:21 mvs Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -694,6 +694,7 @@ process_reparent(struct process *child, struct process *parent) } child->ps_pptr = parent; + child->ps_ppid = parent->ps_pid; } void diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 34e5b45bcbc..a8d275907de 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.230 2020/12/07 16:55:28 mpi Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.231 2021/01/17 15:28:21 mvs Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -231,6 +231,7 @@ process_new(struct proc *p, struct process *parent, int flags) /* post-copy fixups */ pr->ps_pptr = parent; + pr->ps_ppid = parent->ps_pid; /* bump references to the text vnode (for sysctl) */ pr->ps_textvp = parent->ps_textvp; diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 67c6c1020d5..f6fff9d87bb 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_prot.c,v 1.76 2019/07/09 12:23:25 bluhm Exp $ */ +/* $OpenBSD: kern_prot.c,v 1.77 2021/01/17 15:28:22 mvs Exp $ */ /* $NetBSD: kern_prot.c,v 1.33 1996/02/09 18:59:42 christos Exp $ */ /* @@ -84,7 +84,7 @@ int sys_getppid(struct proc *p, void *v, register_t *retval) { - *retval = p->p_p->ps_pptr->ps_pid; + *retval = p->p_p->ps_ppid; return (0); } diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index fb5ee2cbf58..986f1a0b377 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.387 2021/01/09 23:33:18 gnezdo Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.388 2021/01/17 15:28:22 mvs Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1647,7 +1647,7 @@ fill_kproc(struct process *pr, struct kinfo_proc *ki, struct proc *p, /* stuff that's too painful to generalize into the macros */ if (pr->ps_pptr) - ki->p_ppid = pr->ps_pptr->ps_pid; + ki->p_ppid = pr->ps_ppid; if (s->s_leader) ki->p_sid = s->s_leader->ps_pid; diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 042c4f1aed8..0f2acb405a9 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.304 2021/01/11 13:55:53 claudio Exp $ */ +/* $OpenBSD: proc.h,v 1.305 2021/01/17 15:28:22 mvs Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -216,6 +216,7 @@ struct process { u_int ps_xexit; /* Exit status for wait */ int ps_xsig; /* Stopping or killing signal */ + pid_t ps_ppid; /* [a] Cached parent pid */ pid_t ps_oppid; /* Save parent pid during ptrace. */ int ps_ptmask; /* Ptrace event mask */ struct ptrace_state *ps_ptstat;/* Ptrace state */ |