From 51c8e26b00381f7458cc9504ca2132ab08f80be8 Mon Sep 17 00:00:00 2001 From: claudio Date: Mon, 30 Sep 2024 12:32:26 +0000 Subject: [PATCH] Use ps_ppid instead of ps_pptr->ps_pid in all places. OK mpi@ --- sys/kern/kern_exit.c | 8 ++++---- sys/kern/kern_sysctl.c | 4 +--- sys/kern/sys_process.c | 6 +++--- sys/kern/tty_tty.c | 6 +++--- sys/sys/sysctl.h | 5 +++-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 68830a47326..fd2d05778fc 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.233 2024/09/06 08:21:21 mpi Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.234 2024/09/30 12:32:26 claudio Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -746,7 +746,7 @@ proc_finish_wait(struct proc *waiter, struct process *pr) * If we got the child via a ptrace 'attach', * we need to give it back to the old parent. */ - if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_pptr->ps_pid) && + if (pr->ps_oppid != 0 && (pr->ps_oppid != pr->ps_ppid) && (tr = prfind(pr->ps_oppid))) { pr->ps_oppid = 0; atomic_clearbits_int(&pr->ps_flags, PS_TRACED); @@ -774,7 +774,7 @@ process_untrace(struct process *pr) KASSERT(pr->ps_flags & PS_TRACED); if (pr->ps_oppid != 0 && - (pr->ps_oppid != pr->ps_pptr->ps_pid)) + (pr->ps_oppid != pr->ps_ppid)) ppr = prfind(pr->ps_oppid); /* not being traced any more */ @@ -803,7 +803,7 @@ process_reparent(struct process *child, struct process *parent) return; KASSERT(child->ps_oppid == 0 || - child->ps_oppid == child->ps_pptr->ps_pid); + child->ps_oppid == child->ps_ppid); LIST_REMOVE(child, ps_sibling); LIST_INSERT_HEAD(&parent->ps_children, child, ps_sibling); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index c02866c4e95..0ed7badbc63 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.447 2024/09/24 12:37:11 bluhm Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.448 2024/09/30 12:32:26 claudio Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1996,8 +1996,6 @@ fill_kproc(struct process *pr, struct kinfo_proc *ki, struct proc *p, show_pointers); /* stuff that's too painful to generalize into the macros */ - if (pr->ps_pptr) - ki->p_ppid = pr->ps_ppid; if (s->s_leader) ki->p_sid = s->s_leader->ps_pid; diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 3e2b4586f59..9520d0ddc79 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.98 2024/06/03 12:48:25 claudio Exp $ */ +/* $OpenBSD: sys_process.c,v 1.99 2024/09/30 12:32:26 claudio Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -291,7 +291,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data) if (ISSET(tr->ps_flags, PS_TRACED)) return EBUSY; atomic_setbits_int(&tr->ps_flags, PS_TRACED); - tr->ps_oppid = tr->ps_pptr->ps_pid; + tr->ps_oppid = tr->ps_ppid; if (tr->ps_ptstat == NULL) tr->ps_ptstat = malloc(sizeof(*tr->ps_ptstat), M_SUBPROC, M_WAITOK); @@ -520,7 +520,7 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data) * Stop the target. */ atomic_setbits_int(&tr->ps_flags, PS_TRACED); - tr->ps_oppid = tr->ps_pptr->ps_pid; + tr->ps_oppid = tr->ps_ppid; process_reparent(tr, p->p_p); if (tr->ps_ptstat == NULL) tr->ps_ptstat = malloc(sizeof(*tr->ps_ptstat), diff --git a/sys/kern/tty_tty.c b/sys/kern/tty_tty.c index d34aa0cee9f..cace0c39376 100644 --- a/sys/kern/tty_tty.c +++ b/sys/kern/tty_tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty_tty.c,v 1.32 2022/08/14 01:58:28 jsg Exp $ */ +/* $OpenBSD: tty_tty.c,v 1.33 2024/09/30 12:32:26 claudio Exp $ */ /* $NetBSD: tty_tty.c,v 1.13 1996/03/30 22:24:46 christos Exp $ */ /*- @@ -117,7 +117,7 @@ cttyioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) return EINVAL; sess = p->p_p->ps_pgrp->pg_session; sess->s_verauthuid = p->p_ucred->cr_ruid; - sess->s_verauthppid = p->p_p->ps_pptr->ps_pid; + sess->s_verauthppid = p->p_p->ps_ppid; timeout_add_sec(&sess->s_verauthto, secs); return 0; case TIOCCLRVERAUTH: @@ -135,7 +135,7 @@ cttyioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) */ sess = p->p_p->ps_pgrp->pg_session; if (sess->s_verauthuid == p->p_ucred->cr_ruid && - sess->s_verauthppid == p->p_p->ps_pptr->ps_pid) + sess->s_verauthppid == p->p_p->ps_ppid) return 0; return EPERM; } diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 37bdfbb0dcf..b460f92f6fd 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.237 2024/08/02 14:34:45 mvs Exp $ */ +/* $OpenBSD: sysctl.h,v 1.238 2024/09/30 12:32:26 claudio Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -568,7 +568,7 @@ struct kinfo_vmentry { * lim - source struct plimits * sa - source struct sigacts * There are some members that are not handled by these macros - * because they're too painful to generalize: p_ppid, p_sid, p_tdev, + * because they're too painful to generalize: p_sid, p_tdev, * p_tpgid, p_tsess, p_vm_rssize, p_u[us]time_{sec,usec}, p_cpuid */ @@ -645,6 +645,7 @@ do { \ (kp)->p_sigmask = (p)->p_sigmask; \ \ PR_LOCK(pr); \ + (kp)->p_ppid = (pr)->ps_ppid; \ (kp)->p_sigignore = (sa) ? (sa)->ps_sigignore : 0; \ (kp)->p_sigcatch = (sa) ? (sa)->ps_sigcatch : 0; \ \ -- 2.20.1