aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-05 22:25:00 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-05 22:25:00 +0200
commit00c1811d87ea9019c2beda0d182150792c6bb053 (patch)
tree43f1af035419b1d197e24fa25486ccbfad3eb26a
parent99125c04950a7ba2ac90dc21c3d924fe9dd95651 (diff)
downloadbusybox-w32-00c1811d87ea9019c2beda0d182150792c6bb053.tar.gz
busybox-w32-00c1811d87ea9019c2beda0d182150792c6bb053.tar.bz2
busybox-w32-00c1811d87ea9019c2beda0d182150792c6bb053.zip
pstree: make it NOEXEC
While at it, documet why ps can't be NOEXEC. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--NOFORK_NOEXEC.lst4
-rw-r--r--procps/ps.c24
-rw-r--r--procps/pstree.c3
3 files changed, 16 insertions, 15 deletions
diff --git a/NOFORK_NOEXEC.lst b/NOFORK_NOEXEC.lst
index 0b6528d94..fbba3adb3 100644
--- a/NOFORK_NOEXEC.lst
+++ b/NOFORK_NOEXEC.lst
@@ -269,9 +269,9 @@ poweroff - rare
269powertop - interactive, longterm 269powertop - interactive, longterm
270printenv - NOFORK 270printenv - NOFORK
271printf - NOFORK 271printf - NOFORK
272ps - noexec candidate 272ps - looks for AT_CLKTCK elf aux vector, therefore can't be noexec
273pscan - longterm 273pscan - longterm
274pstree 274pstree - noexec
275pwd - NOFORK 275pwd - NOFORK
276pwdx - NOFORK 276pwdx - NOFORK
277raidautorun 277raidautorun
diff --git a/procps/ps.c b/procps/ps.c
index 081479b33..afd981313 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -15,7 +15,7 @@
15//config: ps gives a snapshot of the current processes. 15//config: ps gives a snapshot of the current processes.
16//config: 16//config:
17//config:config FEATURE_PS_WIDE 17//config:config FEATURE_PS_WIDE
18//config: bool "Enable wide output option (-w)" 18//config: bool "Enable wide output (-w)"
19//config: default y 19//config: default y
20//config: depends on PS && !DESKTOP 20//config: depends on PS && !DESKTOP
21//config: help 21//config: help
@@ -24,7 +24,7 @@
24//config: than once, the length is unlimited. 24//config: than once, the length is unlimited.
25//config: 25//config:
26//config:config FEATURE_PS_LONG 26//config:config FEATURE_PS_LONG
27//config: bool "Enable long output option (-l)" 27//config: bool "Enable long output (-l)"
28//config: default y 28//config: default y
29//config: depends on PS && !DESKTOP 29//config: depends on PS && !DESKTOP
30//config: help 30//config: help
@@ -32,11 +32,16 @@
32//config: Adds fields PPID, RSS, START, TIME & TTY 32//config: Adds fields PPID, RSS, START, TIME & TTY
33//config: 33//config:
34//config:config FEATURE_PS_TIME 34//config:config FEATURE_PS_TIME
35//config: bool "Support -o time and -o etime output specifiers" 35//config: bool "Enable -o time and -o etime specifiers"
36//config: default y 36//config: default y
37//config: depends on PS && DESKTOP 37//config: depends on PS && DESKTOP
38//config: select PLATFORM_LINUX 38//config: select PLATFORM_LINUX
39//config: 39//config:
40//config:config FEATURE_PS_ADDITIONAL_COLUMNS
41//config: bool "Enable -o rgroup, -o ruser, -o nice specifiers"
42//config: default y
43//config: depends on PS && DESKTOP
44//config:
40//config:config FEATURE_PS_UNUSUAL_SYSTEMS 45//config:config FEATURE_PS_UNUSUAL_SYSTEMS
41//config: bool "Support Linux prior to 2.4.0 and non-ELF systems" 46//config: bool "Support Linux prior to 2.4.0 and non-ELF systems"
42//config: default n 47//config: default n
@@ -44,13 +49,9 @@
44//config: help 49//config: help
45//config: Include support for measuring HZ on old kernels and non-ELF systems 50//config: Include support for measuring HZ on old kernels and non-ELF systems
46//config: (if you are on Linux 2.4.0+ and use ELF, you don't need this) 51//config: (if you are on Linux 2.4.0+ and use ELF, you don't need this)
47//config:
48//config:config FEATURE_PS_ADDITIONAL_COLUMNS
49//config: bool "Support -o rgroup, -o ruser, -o nice specifiers"
50//config: default y
51//config: depends on PS && DESKTOP
52 52
53//applet:IF_PS(APPLET(ps, BB_DIR_BIN, BB_SUID_DROP)) 53//applet:IF_PS(APPLET(ps, BB_DIR_BIN, BB_SUID_DROP))
54/* can't be NOEXEC: uses ELF aux vector. To have it, we must be a normal, execed process */
54 55
55//kbuild:lib-$(CONFIG_PS) += ps.o 56//kbuild:lib-$(CONFIG_PS) += ps.o
56 57
@@ -202,6 +203,7 @@ struct globals {
202 203
203#if ENABLE_FEATURE_PS_TIME 204#if ENABLE_FEATURE_PS_TIME
204/* for ELF executables, notes are pushed before environment and args */ 205/* for ELF executables, notes are pushed before environment and args */
206/* try "LD_SHOW_AUXV=1 /bin/true" */
205static uintptr_t find_elf_note(uintptr_t findme) 207static uintptr_t find_elf_note(uintptr_t findme)
206{ 208{
207 uintptr_t *ep = (uintptr_t *) environ; 209 uintptr_t *ep = (uintptr_t *) environ;
@@ -217,7 +219,7 @@ static uintptr_t find_elf_note(uintptr_t findme)
217 return -1; 219 return -1;
218} 220}
219 221
220#if ENABLE_FEATURE_PS_UNUSUAL_SYSTEMS 222# if ENABLE_FEATURE_PS_UNUSUAL_SYSTEMS
221static unsigned get_HZ_by_waiting(void) 223static unsigned get_HZ_by_waiting(void)
222{ 224{
223 struct timeval tv1, tv2; 225 struct timeval tv1, tv2;
@@ -260,13 +262,13 @@ static unsigned get_HZ_by_waiting(void)
260 262
261 return r; 263 return r;
262} 264}
263#else 265# else
264static inline unsigned get_HZ_by_waiting(void) 266static inline unsigned get_HZ_by_waiting(void)
265{ 267{
266 /* Better method? */ 268 /* Better method? */
267 return 100; 269 return 100;
268} 270}
269#endif 271# endif
270 272
271static unsigned get_kernel_HZ(void) 273static unsigned get_kernel_HZ(void)
272{ 274{
diff --git a/procps/pstree.c b/procps/pstree.c
index 212cda23c..824907997 100644
--- a/procps/pstree.c
+++ b/procps/pstree.c
@@ -9,14 +9,13 @@
9 * 9 *
10 * Licensed under GPLv2, see file LICENSE in this source tree. 10 * Licensed under GPLv2, see file LICENSE in this source tree.
11 */ 11 */
12
13//config:config PSTREE 12//config:config PSTREE
14//config: bool "pstree (9.4 kb)" 13//config: bool "pstree (9.4 kb)"
15//config: default y 14//config: default y
16//config: help 15//config: help
17//config: Display a tree of processes. 16//config: Display a tree of processes.
18 17
19//applet:IF_PSTREE(APPLET(pstree, BB_DIR_USR_BIN, BB_SUID_DROP)) 18//applet:IF_PSTREE(APPLET_NOEXEC(pstree, pstree, BB_DIR_USR_BIN, BB_SUID_DROP, pstree))
20 19
21//kbuild:lib-$(CONFIG_PSTREE) += pstree.o 20//kbuild:lib-$(CONFIG_PSTREE) += pstree.o
22 21