From 3a00c7e499cc5f64e60e3f9447620abe24076cf8 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 12 Oct 2015 00:00:00 -0500 Subject: [PATCH] top: exploit enhancement for control group name [ but stay tuned! there is a commit coming soon that ] [ represents a rather major internal redesign, which ] [ was prompted by the ps and top adaptation testing. ] Signed-off-by: Jim Warner --- top/top.1 | 107 +++++++++++++++++++++++++++----------------------- top/top.c | 17 ++++---- top/top.h | 2 +- top/top_nls.c | 3 ++ 4 files changed, 72 insertions(+), 57 deletions(-) diff --git a/top/top.1 b/top/top.1 index 9d5c0530..f5dd9ddb 100644 --- a/top/top.1 +++ b/top/top.1 @@ -68,7 +68,7 @@ . .\" Document ///////////////////////////////////////////////////////////// .\" ---------------------------------------------------------------------- -.TH TOP 1 "August 2015" "procps-ng" "User Commands" +.TH TOP 1 "October 2015" "procps-ng" "User Commands" .\" ---------------------------------------------------------------------- .\" ---------------------------------------------------------------------- @@ -553,7 +553,16 @@ You toggle Irix/Solaris modes with the `I' \*(CI. A task's currently used share of available \*(MP. .TP 4 - 3.\fB CGROUPS \*(Em Control Groups \fR + 3.\fB CGNAME \*(Em Control Group Name \fR +The name of the control group to which a process belongs, +or `\-' if not applicable for that process. + +This will typically be the last entry in the full list of control +groups as shown under the next heading (CGROUPS). +And as is true there, this field is also variable width. + +.TP 4 + 4.\fB CGROUPS \*(Em Control Groups \fR The names of the control group(s) to which a process belongs, or `\-' if not applicable for that process. @@ -574,12 +583,12 @@ Even so, such variable width fields could still suffer truncation. any truncated data. .TP 4 - 4.\fB CODE \*(Em Code Size (KiB) \fR + 5.\fB CODE \*(Em Code Size (KiB) \fR The amount of \*(MP devoted to executable code, also known as the Text Resident Set size or TRS. .TP 4 - 5.\fB COMMAND \*(Em Command\fB Name\fR or Command\fB Line \fR + 6.\fB COMMAND \*(Em Command\fB Name\fR or Command\fB Line \fR Display the command line used to start a task or the name of the associated program. You toggle between command\fI line\fR and\fI name\fR with `c', which is both @@ -603,12 +612,12 @@ displayed (the `c' \*(CI.) any truncated data. .TP 4 - 6.\fB DATA \*(Em Data + Stack Size (KiB) \fR + 7.\fB DATA \*(Em Data + Stack Size (KiB) \fR The amount of \*(MP devoted to other than executable code, also known as the Data Resident Set size or DRS. .TP 4 - 7.\fB ENVIRON \*(Em Environment variables \fR + 8.\fB ENVIRON \*(Em Environment variables \fR Display all of the environment variables, if any, as seen by the respective processes. These variables will be displayed in their raw native order, not the @@ -623,26 +632,26 @@ This is especially true for this field. any truncated data. .TP 4 - 8.\fB Flags \*(Em Task Flags \fR + 9.\fB Flags \*(Em Task Flags \fR This column represents the task's current scheduling flags which are expressed in hexadecimal notation and with zeros suppressed. These flags are officially documented in . .TP 4 - 9.\fB GID \*(Em Group Id \fR +10.\fB GID \*(Em Group Id \fR The\fI effective\fR group ID. .TP 4 -10.\fB GROUP \*(Em Group Name \fR +11.\fB GROUP \*(Em Group Name \fR The\fI effective\fR group name. .TP 4 -11.\fB LXC \*(Em Lxc Container Name \fR +12.\fB LXC \*(Em Lxc Container Name \fR The name of the lxc container within which a task is running. If a process is not running inside a container, a dash (`\-') will be shown. .TP 4 -12.\fB NI \*(Em Nice Value \fR +13.\fB NI \*(Em Nice Value \fR The nice value of the task. A negative nice value means higher priority, whereas a positive nice value means lower priority. @@ -650,7 +659,7 @@ Zero in this field simply means priority will not be adjusted in determining a task's dispatch-ability. .TP 4 -13.\fB P \*(Em Last used \*(PU (SMP) \fR +14.\fB P \*(Em Last used \*(PU (SMP) \fR A number representing the last used processor. In a true SMP environment this will likely change frequently since the kernel intentionally uses weak affinity. @@ -659,7 +668,7 @@ processes to change \*(PUs more often (because of the extra demand for \*(Pu time). .TP 4 -14.\fB PGRP \*(Em Process Group Id \fR +15.\fB PGRP \*(Em Process Group Id \fR Every process is member of a unique process group which is used for distribution of signals and by terminals to arbitrate requests for their input and output. @@ -669,7 +678,7 @@ By convention, this value equals the process ID (\*(Xa PID) of the first member of a process group, called the process group leader. .TP 4 -15.\fB PID \*(Em Process Id \fR +16.\fB PID \*(Em Process Id \fR The task's unique process ID, which periodically wraps, though never restarting at zero. In kernel terms, it is a dispatchable entity defined by a task_struct. @@ -680,11 +689,11 @@ a thread group ID for the thread group leader (\*(Xa TGID); and a TTY process group ID for the process group leader (\*(Xa TPGID). .TP 4 -16.\fB PPID \*(Em Parent Process Id \fR +17.\fB PPID \*(Em Parent Process Id \fR The process ID (pid) of a task's parent. .TP 4 -17.\fB PR \*(Em Priority \fR +18.\fB PR \*(Em Priority \fR The scheduling priority of the task. If you see `rt' in this field, it means the task is running under real time scheduling priority. @@ -694,19 +703,19 @@ the operating itself was not preemptible. And while the 2.6 kernel can be made mostly preemptible, it is not always so. .TP 4 -18.\fB RES \*(Em Resident Memory Size (KiB) \fR +19.\fB RES \*(Em Resident Memory Size (KiB) \fR The non-swapped \*(MP a task is using. .TP 4 -19.\fB RUID \*(Em Real User Id \fR +20.\fB RUID \*(Em Real User Id \fR The\fI real\fR user ID. .TP 4 -20.\fB RUSER \*(Em Real User Name \fR +21.\fB RUSER \*(Em Real User Name \fR The\fI real\fR user name. .TP 4 -21.\fB S \*(Em Process Status \fR +22.\fB S \*(Em Process Status \fR The status of the task which can be one of: \fBD\fR = uninterruptible sleep \fBR\fR = running @@ -721,14 +730,14 @@ Even without a true SMP machine, you may see numerous tasks in this state depending on \*(We's delay interval and nice value. .TP 4 -22.\fB SHR \*(Em Shared Memory Size (KiB) \fR +23.\fB SHR \*(Em Shared Memory Size (KiB) \fR The amount of \*(MS available to a task, not all of which is typically resident. It simply reflects memory that could be potentially shared with other processes. .TP 4 -23.\fB SID \*(Em Session Id \fR +24.\fB SID \*(Em Session Id \fR A session is a collection of process groups (\*(Xa PGRP), usually established by the login shell. A newly forked process joins the session of its creator. @@ -737,11 +746,11 @@ member of the session, called the session leader, which is usually the login shell. .TP 4 -24.\fB SUID \*(Em Saved User Id \fR +25.\fB SUID \*(Em Saved User Id \fR The\fI saved\fR user ID. .TP 4 -25.\fB SUPGIDS \*(Em Supplementary Group IDs \fR +26.\fB SUPGIDS \*(Em Supplementary Group IDs \fR The IDs of any supplementary group(s) established at login or inherited from a task's parent. They are displayed in a comma delimited list. @@ -754,7 +763,7 @@ Even so, such variable width fields could still suffer truncation. any truncated data. .TP 4 -26.\fB SUPGRPS \*(Em Supplementary Group Names \fR +27.\fB SUPGRPS \*(Em Supplementary Group Names \fR The names of any supplementary group(s) established at login or inherited from a task's parent. They are displayed in a comma delimited list. @@ -767,21 +776,21 @@ Even so, such variable width fields could still suffer truncation. any truncated data. .TP 4 -27.\fB SUSER \*(Em Saved User Name \fR +28.\fB SUSER \*(Em Saved User Name \fR The\fI saved\fR user name. .TP 4 -28.\fB SWAP \*(Em Swapped Size (KiB) \fR +29.\fB SWAP \*(Em Swapped Size (KiB) \fR The non-resident portion of a task's address space. .TP 4 -29.\fB TGID \*(Em Thread Group Id \fR +30.\fB TGID \*(Em Thread Group Id \fR The ID of the thread group to which a task belongs. It is the PID of the thread group leader. In kernel terms, it represents those tasks that share an mm_struct. .TP 4 -30.\fB TIME \*(Em \*(PU Time \fR +31.\fB TIME \*(Em \*(PU Time \fR Total \*(PU time the task has used since it started. When Cumulative mode is \*O, each process is listed with the \*(Pu time that it and its dead children have used. @@ -789,19 +798,19 @@ You toggle Cumulative mode with `S', which is both a \*(CO and an \*(CI. \*(XC `S' \*(CI for additional information regarding this mode. .TP 4 -31.\fB TIME+ \*(Em \*(PU Time, hundredths \fR +32.\fB TIME+ \*(Em \*(PU Time, hundredths \fR The same as TIME, but reflecting more granularity through hundredths of a second. .TP 4 -32.\fB TPGID \*(Em Tty Process Group Id \fR +33.\fB TPGID \*(Em Tty Process Group Id \fR The process group ID of the foreground process for the connected tty, or \-1 if a process is not connected to a terminal. By convention, this value equals the process ID (\*(Xa PID) of the process group leader (\*(Xa PGRP). .TP 4 -33.\fB TTY \*(Em Controlling Tty \fR +34.\fB TTY \*(Em Controlling Tty \fR The name of the controlling terminal. This is usually the device (serial port, pty, etc.) from which the process was started, and which it uses for input or output. @@ -809,39 +818,39 @@ However, a task need not be associated with a terminal, in which case you'll see `?' displayed. .TP 4 -34.\fB UID \*(Em User Id \fR +35.\fB UID \*(Em User Id \fR The\fI effective\fR user ID of the task's owner. .TP 4 -35.\fB USED \*(Em Memory in Use (KiB) \fR +36.\fB USED \*(Em Memory in Use (KiB) \fR This field represents the non-swapped \*(MP a task has used (RES) plus the non-resident portion of its address space (SWAP). .TP 4 -36.\fB USER \*(Em User Name \fR +37.\fB USER \*(Em User Name \fR The\fI effective\fR user name of the task's owner. .TP 4 -37.\fB VIRT \*(Em Virtual Memory Size (KiB) \fR +38.\fB VIRT \*(Em Virtual Memory Size (KiB) \fR The total amount of \*(MV used by the task. It includes all code, data and shared libraries plus pages that have been swapped out and pages that have been mapped but not used. .TP 4 -38.\fB WCHAN \*(Em Sleeping in Function \fR +39.\fB WCHAN \*(Em Sleeping in Function \fR This field will show the name of the kernel function in which the task is currently sleeping. Running tasks will display a dash (`\-') in this column. .TP 4 -39.\fB nDRT \*(Em Dirty Pages Count \fR +40.\fB nDRT \*(Em Dirty Pages Count \fR The number of pages that have been modified since they were last written to \*(AS. Dirty pages must be written to \*(AS before the corresponding physical memory location can be used for some other virtual page. .TP 4 -40.\fB nMaj \*(Em Major Page Fault Count \fR +41.\fB nMaj \*(Em Major Page Fault Count \fR The number of\fB major\fR page faults that have occurred for a task. A page fault occurs when a process attempts to read from or write to a virtual page that is not currently present in its address space. @@ -849,7 +858,7 @@ A major page fault is when \*(AS access is involved in making that page available. .TP 4 -41.\fB nMin \*(Em Minor Page Fault count \fR +42.\fB nMin \*(Em Minor Page Fault count \fR The number of\fB minor\fR page faults that have occurred for a task. A page fault occurs when a process attempts to read from or write to a virtual page that is not currently present in its address space. @@ -857,50 +866,50 @@ A minor page fault does not involve \*(AS access in making that page available. .TP 4 -42.\fB nTH \*(Em Number of Threads \fR +43.\fB nTH \*(Em Number of Threads \fR The number of threads associated with a process. .TP 4 -43.\fB nsIPC \*(Em IPC namespace \fR +44.\fB nsIPC \*(Em IPC namespace \fR The Inode of the namespace used to isolate interprocess communication (IPC) resources such as System V IPC objects and POSIX message queues. .TP 4 -44.\fB nsMNT \*(Em MNT namespace \fR +45.\fB nsMNT \*(Em MNT namespace \fR The Inode of the namespace used to isolate filesystem mount points thus offering different views of the filesystem hierarchy. .TP 4 -45.\fB nsNET \*(Em NET namespace \fR +46.\fB nsNET \*(Em NET namespace \fR The Inode of the namespace used to isolate resources such as network devices, IP addresses, IP routing, port numbers, etc. .TP 4 -46.\fB nsPID \*(Em PID namespace \fR +47.\fB nsPID \*(Em PID namespace \fR The Inode of the namespace used to isolate process ID numbers meaning they need not remain unique. Thus, each such namespace could have its own `init/systemd' (PID #1) to manage various initialization tasks and reap orphaned child processes. .TP 4 -47.\fB nsUSER \*(Em USER namespace \fR +48.\fB nsUSER \*(Em USER namespace \fR The Inode of the namespace used to isolate the user and group ID numbers. Thus, a process could have a normal unprivileged user ID outside a user namespace while having a user ID of 0, with full root privileges, inside that namespace. .TP 4 -48.\fB nsUTS \*(Em UTS namespace \fR +49.\fB nsUTS \*(Em UTS namespace \fR The Inode of the namespace used to isolate hostname and NIS domain name. UTS simply means "UNIX Time-sharing System". .TP 4 -49.\fB vMj \*(Em Major Page Fault Count Delta\fR +50.\fB vMj \*(Em Major Page Fault Count Delta\fR The number of\fB major\fR page faults that have occurred since the last update (see nMaj). .TP 4 -50.\fB vMn \*(Em Minor Page Fault Count Delta\fR +51.\fB vMn \*(Em Minor Page Fault Count Delta\fR The number of\fB minor\fR page faults that have occurred since the last update (see nMin). diff --git a/top/top.c b/top/top.c index 90e3297e..3345daf5 100644 --- a/top/top.c +++ b/top/top.c @@ -1576,13 +1576,15 @@ static struct { { 10, -1, A_right, -1, PROCPS_PIDS_NS_PID }, // ul_int EU_NS4 { 10, -1, A_right, -1, PROCPS_PIDS_NS_USER }, // ul_int EU_NS5 { 10, -1, A_right, -1, PROCPS_PIDS_NS_UTS }, // ul_int EU_NS6 - { 8, -1, A_left, -1, PROCPS_PIDS_LXCNAME }, // str EU_LXC ( the last real pflag ) -// xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . ------------------------------------------ -#define eu_CMDLINE EU_LXC +1 -#define eu_TICS_ALL_C EU_LXC +2 -#define eu_TIME_START EU_LXC +3 -#define eu_ID_FUID EU_LXC +4 -#define eu_XTRA EU_LXC +5 + { 8, -1, A_left, -1, PROCPS_PIDS_LXCNAME }, // str EU_LXC + { -1, -1, A_left, -1, PROCPS_PIDS_CGNAME }, // str EU_CGN +#define eu_LAST EU_CGN // ( the last real pflag, currently ) +// xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . ---------------------------------- +#define eu_CMDLINE eu_LAST +1 +#define eu_TICS_ALL_C eu_LAST +2 +#define eu_TIME_START eu_LAST +3 +#define eu_ID_FUID eu_LAST +4 +#define eu_XTRA eu_LAST +5 { -1, -1, -1, -1, PROCPS_PIDS_CMDLINE }, // str ( if Show_CMDLIN ) { -1, -1, -1, -1, PROCPS_PIDS_TICS_ALL_C }, // ull_int ( if Show_CTIMES ) { -1, -1, -1, -1, PROCPS_PIDS_TIME_START }, // ull_int ( if Show_FOREST ) @@ -5075,6 +5077,7 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) { cp = make_str(rSv(i, str), W, Js, i); break; /* str, make_str with varialbe width */ + case EU_CGN: case EU_CGR: case EU_ENV: case EU_SGD: diff --git a/top/top.h b/top/top.h index 14b6070f..b9dda6e2 100644 --- a/top/top.h +++ b/top/top.h @@ -185,7 +185,7 @@ enum pflag { EU_FV1, EU_FV2, EU_USE, EU_NS1, EU_NS2, EU_NS3, EU_NS4, EU_NS5, EU_NS6, - EU_LXC, + EU_LXC, EU_CGN, #ifdef USE_X_COLHDR // not really pflags, used with tbl indexing EU_MAXPFLGS diff --git a/top/top_nls.c b/top/top_nls.c index 75575863..0397e512 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -278,6 +278,9 @@ static void build_two_nlstabs (void) { /* Translation Hint: maximum 'LXC' = 7 */ Head_nlstab[EU_LXC] = _("LXC"); Desc_nlstab[EU_LXC] = _("LXC container name"); +/* Translation Hint: maximum 'CGNAME' = 7 */ + Head_nlstab[EU_CGN] = _("CGNAME"); + Desc_nlstab[EU_CGN] = _("Control Group name"); } -- 2.40.0