diff --git a/bin/ps/Makefile b/bin/ps/Makefile --- a/bin/ps/Makefile +++ b/bin/ps/Makefile @@ -2,13 +2,6 @@ PROG= ps SRCS= fmt.c keyword.c nlist.c print.c ps.c -# -# To support "lazy" ps for non root/wheel users -# add -DLAZY_PS to the cflags. This helps -# keep ps from being an unnecessary load -# on large systems. -# -CFLAGS+=-DLAZY_PS LIBADD= m kvm jail xo .include diff --git a/bin/ps/print.c b/bin/ps/print.c --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -253,8 +253,6 @@ *cp = '?'; } cp++; - if (!(flag & P_INMEM)) - *cp++ = 'W'; if (k->ki_p->ki_nice < NZERO || k->ki_p->ki_pri.pri_class == PRI_REALTIME) *cp++ = '<'; else if (k->ki_p->ki_nice > NZERO || k->ki_p->ki_pri.pri_class == PRI_IDLE) @@ -633,7 +631,7 @@ #define fxtofl(fixpt) ((double)(fixpt) / fscale) /* XXX - I don't like this */ - if (k->ki_p->ki_swtime == 0 || (k->ki_p->ki_flag & P_INMEM) == 0) + if (k->ki_p->ki_swtime == 0) return (0.0); if (rawcpu) return (100.0 * fxtofl(k->ki_p->ki_pctcpu)); @@ -661,8 +659,6 @@ if (failure) return (0.0); - if ((k->ki_p->ki_flag & P_INMEM) == 0) - return (0.0); /* XXX want pmap ptpages, segtab, etc. (per architecture) */ /* XXX don't have info about shared */ fracmem = ((double)k->ki_p->ki_rssize) / mempages; diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -159,9 +159,6 @@ but works well with it. .It Fl e Display the environment as well. -.It Fl f -Show command-line and environment information about swapped out processes. -This option is honored only if the UID of the user is 0. .It Fl G Display information about processes which are running with the specified real group IDs. @@ -331,36 +328,34 @@ the include file .In sys/proc.h : .Bl -column P_SINGLE_BOUNDARY 0x40000000 -.It Dv "P_ADVLOCK" Ta No "0x00001" Ta "Process may hold a POSIX advisory lock" -.It Dv "P_CONTROLT" Ta No "0x00002" Ta "Has a controlling terminal" -.It Dv "P_KPROC" Ta No "0x00004" Ta "Kernel process" -.It Dv "P_PPWAIT" Ta No "0x00010" Ta "Parent is waiting for child to exec/exit" -.It Dv "P_PROFIL" Ta No "0x00020" Ta "Has started profiling" -.It Dv "P_STOPPROF" Ta No "0x00040" Ta "Has thread in requesting to stop prof" -.It Dv "P_HADTHREADS" Ta No "0x00080" Ta "Has had threads (no cleanup shortcuts)" -.It Dv "P_SUGID" Ta No "0x00100" Ta "Had set id privileges since last exec" -.It Dv "P_SYSTEM" Ta No "0x00200" Ta "System proc: no sigs, stats or swapping" -.It Dv "P_SINGLE_EXIT" Ta No "0x00400" Ta "Threads suspending should exit, not wait" -.It Dv "P_TRACED" Ta No "0x00800" Ta "Debugged process being traced" -.It Dv "P_WAITED" Ta No "0x01000" Ta "Someone is waiting for us" -.It Dv "P_WEXIT" Ta No "0x02000" Ta "Working on exiting" -.It Dv "P_EXEC" Ta No "0x04000" Ta "Process called exec" -.It Dv "P_WKILLED" Ta No "0x08000" Ta "Killed, shall go to kernel/user boundary ASAP" -.It Dv "P_CONTINUED" Ta No "0x10000" Ta "Proc has continued from a stopped state" -.It Dv "P_STOPPED_SIG" Ta No "0x20000" Ta "Stopped due to SIGSTOP/SIGTSTP" -.It Dv "P_STOPPED_TRACE" Ta No "0x40000" Ta "Stopped because of tracing" -.It Dv "P_STOPPED_SINGLE" Ta No "0x80000" Ta "Only one thread can continue" -.It Dv "P_PROTECTED" Ta No "0x100000" Ta "Do not kill on memory overcommit" -.It Dv "P_SIGEVENT" Ta No "0x200000" Ta "Process pending signals changed" -.It Dv "P_SINGLE_BOUNDARY" Ta No "0x400000" Ta "Threads should suspend at user boundary" -.It Dv "P_HWPMC" Ta No "0x800000" Ta "Process is using HWPMCs" -.It Dv "P_JAILED" Ta No "0x1000000" Ta "Process is in jail" -.It Dv "P_TOTAL_STOP" Ta No "0x2000000" Ta "Stopped for system suspend" -.It Dv "P_INEXEC" Ta No "0x4000000" Ta Process is in Xr execve 2 -.It Dv "P_STATCHILD" Ta No "0x8000000" Ta "Child process stopped or exited" -.It Dv "P_INMEM" Ta No "0x10000000" Ta "Loaded into memory" -.It Dv "P_SWAPPINGOUT" Ta No "0x20000000" Ta "Process is being swapped out" -.It Dv "P_SWAPPINGIN" Ta No "0x40000000" Ta "Process is being swapped in" +.It Dv "P_ADVLOCK" Ta No "0x00000001" Ta "Process may hold a POSIX advisory lock" +.It Dv "P_CONTROLT" Ta No "0x00000002" Ta "Has a controlling terminal" +.It Dv "P_KPROC" Ta No "0x00000004" Ta "Kernel process" +.It Dv "P_PPWAIT" Ta No "0x00000010" Ta "Parent is waiting for child to exec/exit" +.It Dv "P_PROFIL" Ta No "0x00000020" Ta "Has started profiling" +.It Dv "P_STOPPROF" Ta No "0x00000040" Ta "Has thread in requesting to stop prof" +.It Dv "P_HADTHREADS" Ta No "0x00000080" Ta "Has had threads (no cleanup shortcuts)" +.It Dv "P_SUGID" Ta No "0x00000100" Ta "Had set id privileges since last exec" +.It Dv "P_SYSTEM" Ta No "0x00000200" Ta "System proc: no sigs, stats or swapping" +.It Dv "P_SINGLE_EXIT" Ta No "0x00000400" Ta "Threads suspending should exit, not wait" +.It Dv "P_TRACED" Ta No "0x00000800" Ta "Debugged process being traced" +.It Dv "P_WAITED" Ta No "0x00001000" Ta "Someone is waiting for us" +.It Dv "P_WEXIT" Ta No "0x00002000" Ta "Working on exiting" +.It Dv "P_EXEC" Ta No "0x00004000" Ta "Process called exec" +.It Dv "P_WKILLED" Ta No "0x00008000" Ta "Killed, shall go to kernel/user boundary ASAP" +.It Dv "P_CONTINUED" Ta No "0x00010000" Ta "Proc has continued from a stopped state" +.It Dv "P_STOPPED_SIG" Ta No "0x00020000" Ta "Stopped due to SIGSTOP/SIGTSTP" +.It Dv "P_STOPPED_TRACE" Ta No "0x00040000" Ta "Stopped because of tracing" +.It Dv "P_STOPPED_SINGLE" Ta No "0x00080000" Ta "Only one thread can continue" +.It Dv "P_PROTECTED" Ta No "0x00100000" Ta "Do not kill on memory overcommit" +.It Dv "P_SIGEVENT" Ta No "0x00200000" Ta "Process pending signals changed" +.It Dv "P_SINGLE_BOUNDARY" Ta No "0x00400000" Ta "Threads should suspend at user boundary" +.It Dv "P_HWPMC" Ta No "0x00800000" Ta "Process is using HWPMCs" +.It Dv "P_JAILED" Ta No "0x01000000" Ta "Process is in jail" +.It Dv "P_TOTAL_STOP" Ta No "0x02000000" Ta "Stopped for system suspend" +.It Dv "P_INEXEC" Ta No "0x04000000" Ta Process is in Xr execve 2 +.It Dv "P_STATCHILD" Ta No "0x08000000" Ta "Child process stopped or exited" +.It Dv "P_INMEM" Ta No "0x10000000" Ta "Always set, unused" .It Dv "P_PPTRACE" Ta No "0x80000000" Ta "Vforked child issued ptrace(PT_TRACEME)" .El .It Cm flags2 @@ -375,6 +370,24 @@ .It Dv "P2_NOTRACE_EXEC" Ta No "0x00000004" Ta Keep P2_NOPTRACE on Xr execve 2 .It Dv "P2_AST_SU" Ta No "0x00000008" Ta "Handles SU ast for kthreads" .It Dv "P2_PTRACE_FSTP" Ta No "0x00000010" Ta "SIGSTOP from PT_ATTACH not yet handled" +.It Dv "P2_TRAPCAP" Ta No "0x00000020" Ta "SIGTRAP on ENOTCAPABLE" +.It Dv "P2_ASLR_ENABLE" Ta No "0x00000040" Ta "Force enable ASLR" +.It Dv "P2_ASLR_DISABLE" Ta No "0x00000080" Ta "Force disable ASLR" +.It Dv "P2_ASLR_IGNSTART" Ta No "0x00000100" Ta "Enable ASLR to consume sbrk area" +.It Dv "P2_PROTMAX_ENABLE" Ta No "0x00000200" Ta "Force enable implied PROT_MAX" +.It Dv "P2_PROTMAX_DISABLE" Ta No "0x00000400" Ta "Force disable implied PROT_MAX" +.It Dv "P2_STKGAP_DISABLE" Ta No "0x00000800" Ta "Disable stack gap for MAP_STACK" +.It Dv "P2_STKGAP_DISABLE_EXEC" Ta No " 0x00001000" Ta "Stack gap disabled after exec" +.It Dv "P2_ITSTOPPED" Ta No "0x00002000" Ta "itimers stopped (as part of process stop)" +.It Dv "P2_PTRACEREQ" Ta No "0x00004000" Ta "Active ptrace req" +.It Dv "P2_NO_NEW_PRIVS" Ta No "0x00008000" Ta "Ignore setuid on exec" +.It Dv "P2_WXORX_DISABLE" Ta No "0x00010000" Ta "WX mappings enabled" +.It Dv "P2_WXORX_ENABLE_EXEC" Ta No "0x00020000" Ta "WxorX enabled after exec" +.It Dv "P2_WEXIT" Ta No "0x00040000" Ta "Internal exit early state" +.It Dv "P2_REAPKILLED" Ta No "0x00080000" Ta "REAP_KILL pass handled the process" +.It Dv "P2_MEMBAR_PRIVE" Ta No "0x00100000" Ta "membarrier private expedited registered" +.It Dv "P2_MEMBAR_PRIVE_SYNCORE" Ta No "0x00200000" Ta "membarrier private expedited sync core registered" +.It Dv "P2_MEMBAR_GLOBE" Ta No "0x00400000" Ta "membar global expedited registered" .El .It Cm label The MAC label of the process. @@ -473,8 +486,6 @@ The process' parent is suspended during a .Xr vfork 2 , waiting for the process to exec or exit. -.It Li W -The process is swapped out. .It Li X The process is being traced or debugged. .El diff --git a/bin/ps/ps.c b/bin/ps/ps.c --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -68,14 +68,6 @@ #define W_SEP " \t" /* "Whitespace" list separators */ #define T_SEP "," /* "Terminate-element" list separators */ -#ifdef LAZY_PS -#define DEF_UREAD 0 -#define OPT_LAZY_f "f" -#else -#define DEF_UREAD 1 /* Always do the more-expensive read. */ -#define OPT_LAZY_f /* I.e., the `-f' option is not added. */ -#endif - /* * isdigit takes an `int', but expects values in the range of unsigned char. * This wrapper ensures that values from a 'char' end up in the correct range. @@ -92,7 +84,6 @@ struct velisthead varlist = STAILQ_HEAD_INITIALIZER(varlist); -static int forceuread = DEF_UREAD; /* Do extra work to get u-area. */ static kvm_t *kd; static int needcomm; /* -o "command" */ static int needenv; /* -e */ @@ -154,7 +145,7 @@ "%cpu,%mem,command"; static char Zfmt[] = "label"; -#define PS_ARGS "AaCcD:de" OPT_LAZY_f "G:gHhjJ:LlM:mN:O:o:p:rSTt:U:uvwXxZ" +#define PS_ARGS "AaCcD:defG:gHhjJ:LlM:mN:O:o:p:rSTt:U:uvwXxZ" int main(int argc, char *argv[]) @@ -272,12 +263,9 @@ case 'e': /* XXX set ufmt */ needenv = 1; break; -#ifdef LAZY_PS case 'f': - if (getuid() == 0 || getgid() == 0) - forceuread = 1; + /* compat */ break; -#endif case 'G': add_list(&gidlist, optarg); xkeep_implied = 1; @@ -1276,31 +1264,21 @@ return (s); } -#define UREADOK(ki) (forceuread || (ki->ki_p->ki_flag & P_INMEM)) - static void saveuser(KINFO *ki) { char tdname[COMMLEN + 1]; char *argsp; - if (ki->ki_p->ki_flag & P_INMEM) { - /* - * The u-area might be swapped out, and we can't get - * at it because we have a crashdump and no swap. - * If it's here fill in these fields, otherwise, just - * leave them 0. - */ - ki->ki_valid = 1; - } else - ki->ki_valid = 0; + ki->ki_valid = 1; + /* * save arguments if needed */ if (needcomm) { if (ki->ki_p->ki_stat == SZOMB) { ki->ki_args = strdup(""); - } else if (UREADOK(ki) || (ki->ki_p->ki_args != NULL)) { + } else if (ki->ki_p->ki_args != NULL) { (void)snprintf(tdname, sizeof(tdname), "%s%s", ki->ki_p->ki_tdname, ki->ki_p->ki_moretdname); ki->ki_args = fmt(kvm_getargv, ki, @@ -1315,11 +1293,8 @@ ki->ki_args = NULL; } if (needenv) { - if (UREADOK(ki)) - ki->ki_env = fmt(kvm_getenvv, ki, - (char *)NULL, (char *)NULL, 0); - else - ki->ki_env = strdup("()"); + ki->ki_env = fmt(kvm_getenvv, ki, (char *)NULL, + (char *)NULL, 0); if (ki->ki_env == NULL) xo_errx(1, "malloc failed"); } else { @@ -1479,7 +1454,7 @@ static void __dead2 usage(void) { -#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]" +#define SINGLE_OPTS "[-aCcdeHhjlmrSTuvwXxZ]" xo_error("%s\n%s\n%s\n%s\n%s\n", "usage: ps [--libxo] " SINGLE_OPTS " [-O fmt | -o fmt]", diff --git a/sys/sys/proc.h b/sys/sys/proc.h --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -868,7 +868,7 @@ MAP_STACK */ #define P2_STKGAP_DISABLE_EXEC 0x00001000 /* Stack gap disabled after exec */ -#define P2_ITSTOPPED 0x00002000 +#define P2_ITSTOPPED 0x00002000 /* itimers stopped */ #define P2_PTRACEREQ 0x00004000 /* Active ptrace req */ #define P2_NO_NEW_PRIVS 0x00008000 /* Ignore setuid */ #define P2_WXORX_DISABLE 0x00010000 /* WX mappings enabled */ @@ -876,7 +876,7 @@ #define P2_WEXIT 0x00040000 /* exit just started, no external thread_single() is permitted */ -#define P2_REAPKILLED 0x00080000 +#define P2_REAPKILLED 0x00080000 /* REAP_KILL pass touched me */ #define P2_MEMBAR_PRIVE 0x00100000 /* membar private expedited registered */ #define P2_MEMBAR_PRIVE_SYNCORE 0x00200000 /* membar private expedited