From f1e82477747d259ffa18f9d418dd6eae1d440878 Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 15 Feb 2022 23:16:00 +0000 Subject: [PATCH] Reintroduce ps state flag 'c' indicating chrooted process (via PS_BITS). Ok deraat@ --- bin/ps/print.c | 4 +++- bin/ps/ps.1 | 6 ++++-- sys/kern/vfs_syscalls.c | 3 ++- sys/sys/proc.h | 5 +++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/ps/print.c b/bin/ps/print.c index 7b54ae7d13d..4afa30f70fc 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.81 2022/02/14 18:09:08 rob Exp $ */ +/* $OpenBSD: print.c,v 1.82 2022/02/15 23:16:00 rob Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -289,6 +289,8 @@ printstate(const struct kinfo_proc *kp, VARENT *ve) else *cp++ = 'u'; } + if (kp->p_psflags & PS_CHROOT) + *cp++ = 'c'; *cp = '\0'; if (state == 'R' && kp->p_cpuid != KI_NOCPU) { diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 4ada43512a4..1e64816e754 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ps.1,v 1.123 2022/02/14 18:09:08 rob Exp $ +.\" $OpenBSD: ps.1,v 1.124 2022/02/15 23:16:00 rob Exp $ .\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 @@ -30,7 +30,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd $Mdocdate: February 14 2022 $ +.Dd $Mdocdate: February 15 2022 $ .Dt PS 1 .Os .Sh NAME @@ -451,6 +451,8 @@ swapped. .\" for example, .\" .Xr lisp 1 .\" in a garbage collect). +.It c +The process is chrooted. .It E The process is trying to exit. .It K diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 3f7403980d0..bfce966733e 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.354 2021/12/23 18:50:31 guenther Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.355 2022/02/15 23:16:00 rob Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -829,6 +829,7 @@ sys_chroot(struct proc *p, void *v, register_t *retval) vrele(old_cdir); } else fdp->fd_rdir = nd.ni_vp; + p->p_p->ps_flags |= PS_CHROOT; return (0); } diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 2ebe71d1728..ce1c451bbcd 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.325 2022/02/07 19:28:14 rob Exp $ */ +/* $OpenBSD: proc.h,v 1.326 2022/02/15 23:16:00 rob Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -277,6 +277,7 @@ struct process { #define PS_WXNEEDED 0x00200000 /* Process allowed to violate W^X */ #define PS_EXECPLEDGE 0x00400000 /* Has exec pledges */ #define PS_ORPHAN 0x00800000 /* Process is on an orphan list */ +#define PS_CHROOT 0x01000000 /* Process is chrooted */ #define PS_BITS \ ("\20" "\01CONTROLT" "\02EXEC" "\03INEXEC" "\04EXITING" "\05SUGID" \ @@ -284,7 +285,7 @@ struct process { "\013WAITED" "\014COREDUMP" "\015SINGLEEXIT" "\016SINGLEUNWIND" \ "\017NOZOMBIE" "\020STOPPED" "\021SYSTEM" "\022EMBRYO" "\023ZOMBIE" \ "\024NOBROADCASTKILL" "\025PLEDGE" "\026WXNEEDED" "\027EXECPLEDGE" \ - "\030ORPHAN") + "\030ORPHAN" "\031CHROOT") struct kcov_dev; -- 2.20.1