aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-07 16:47:34 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-07 16:47:34 +0200
commit1a1203ff8909efc003bb6bf679a6afd6628dc179 (patch)
tree543504b74dd44b83536ff3b2da079586c6401a2e
parent798b94518e61ced3f7be7766727705df4859878c (diff)
downloadbusybox-w32-1a1203ff8909efc003bb6bf679a6afd6628dc179.tar.gz
busybox-w32-1a1203ff8909efc003bb6bf679a6afd6628dc179.tar.bz2
busybox-w32-1a1203ff8909efc003bb6bf679a6afd6628dc179.zip
users,w,who,uptime,renice: make NOEXEC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--NOFORK_NOEXEC.lst72
-rw-r--r--coreutils/who.c8
-rw-r--r--miscutils/i2c_tools.c1
-rw-r--r--procps/uptime.c2
-rw-r--r--util-linux/renice.c2
5 files changed, 44 insertions, 41 deletions
diff --git a/NOFORK_NOEXEC.lst b/NOFORK_NOEXEC.lst
index 981a10192..70f38d867 100644
--- a/NOFORK_NOEXEC.lst
+++ b/NOFORK_NOEXEC.lst
@@ -4,9 +4,9 @@ Why can't be NOFORK:
4interactive: may wait for user input, ^C has to work 4interactive: may wait for user input, ^C has to work
5spawner: "tool PROG ARGS" which changes program state and execs - must fork 5spawner: "tool PROG ARGS" which changes program state and execs - must fork
6changes state: e.g. environment, signal handlers 6changes state: e.g. environment, signal handlers
7alloc+xfunc: xmalloc, then xfunc - leaks memory if xfunc dies
8open+xfunc: opens fd, then calls xfunc - fd is leaked if xfunc dies
9leaks: does not free allocated memory or opened fds 7leaks: does not free allocated memory or opened fds
8 alloc+xfunc: xmalloc, then xfunc - leaks memory if xfunc dies
9 open+xfunc: opens fd, then calls xfunc - fd is leaked if xfunc dies
10runner: sometimes may run for long(ish) time, and/or works with network: 10runner: sometimes may run for long(ish) time, and/or works with network:
11 ^C has to work (cat BIGFILE, chmod -R, ftpget, nc) 11 ^C has to work (cat BIGFILE, chmod -R, ftpget, nc)
12 12
@@ -25,6 +25,8 @@ longterm: often runs for a long time (many seconds), execing makes
25complex: no immediately obvious reason why NOFORK wouldn't work, 25complex: no immediately obvious reason why NOFORK wouldn't work,
26 but does some non-obvoius operations (example: fuser, lsof, losetup); 26 but does some non-obvoius operations (example: fuser, lsof, losetup);
27 detailed audit often turns out that it's a leaker 27 detailed audit often turns out that it's a leaker
28hardware: performs unusual hardware ops which may take long,
29 or even hang due to hardware or firmware bugs
28 30
29Interesting example of "interactive" applet which is nevertheless can be 31Interesting example of "interactive" applet which is nevertheless can be
30(and is) NOEXEC is "rm". Yes, "rm -i" is interactive - but it's not that typical 32(and is) NOEXEC is "rm". Yes, "rm -i" is interactive - but it's not that typical
@@ -42,8 +44,8 @@ adduser - noexec. leaks
42adjtimex - NOFORK 44adjtimex - NOFORK
43ar - runner 45ar - runner
44arch - NOFORK 46arch - NOFORK
45arp - complex, rare 47arp - runner, needs ^C: arp -n talks to DNS servers
46arping - runner 48arping - longterm
47ash - interactive, longterm 49ash - interactive, longterm
48awk - noexec. runner 50awk - noexec. runner
49base64 - runner 51base64 - runner
@@ -87,7 +89,7 @@ dd - noexec. runner
87deallocvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds 89deallocvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
88delgroup - noexec. leaks 90delgroup - noexec. leaks
89deluser - noexec. leaks 91deluser - noexec. leaks
90depmod - complex, rare 92depmod - longterm(ish)
91devmem - runner, complex (access to device memory may hang) 93devmem - runner, complex (access to device memory may hang)
92df - leaks: nested allocs 94df - leaks: nested allocs
93dhcprelay - daemon 95dhcprelay - daemon
@@ -114,19 +116,19 @@ factor - runner (eats stdin if no params)
114fakeidentd - daemon 116fakeidentd - daemon
115false - NOFORK 117false - NOFORK
116fatattr - leaks: open+xioctl, complex 118fatattr - leaks: open+xioctl, complex
117fbset - leaks: open+xfunc, complex, rare 119fbset - hardware, leaks: open+xfunc
118fbsplash - runner, longterm 120fbsplash - runner, longterm
119fdflush - leaks: open+ioctl_or_perror_and_die, needs ^C (floppy may be unresponsive), rare 121fdflush - hardware, leaks: open+ioctl_or_perror_and_die
120fdformat - needs ^C (floppy may be unresponsive), longterm, rare 122fdformat - hardware, needs ^C (floppy may be unresponsive), longterm
121fdisk - interactive, longterm 123fdisk - interactive, longterm
122fgconsole - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds 124fgconsole - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
123fgrep - longterm runner ("CMD | fgrep ..." may run indefinitely, better to exec to conserve memory) 125fgrep - longterm runner ("CMD | fgrep ..." may run indefinitely, better to exec to conserve memory)
124find - noexec. runner 126find - noexec. runner
125findfs - suid 127findfs - suid
126flash_eraseall - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 128flash_eraseall - hardware
127flash_lock - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 129flash_lock - hardware
128flash_unlock - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 130flash_unlock - hardware
129flashcp - needs ^C. could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 131flashcp - hardware
130flock - spawner, changes state (file locks), let's play safe and not be noexec 132flock - spawner, changes state (file locks), let's play safe and not be noexec
131fold - noexec. runner 133fold - noexec. runner
132free - nofork candidate(struct globals, needs to close /proc/meminfo fd) 134free - nofork candidate(struct globals, needs to close /proc/meminfo fd)
@@ -148,18 +150,18 @@ gunzip - runner
148gzip - runner 150gzip - runner
149halt - rare 151halt - rare
150hd - noexec. runner 152hd - noexec. runner
151hdparm - complex, rare 153hdparm - hardware
152head - noexec. runner 154head - noexec. runner
153hexdump - noexec. runner 155hexdump - noexec. runner
154hostid - NOFORK 156hostid - NOFORK
155hostname - needs ^C (may talk to DNS servers, which may be down) 157hostname - needs ^C (may talk to DNS servers, which may be down)
156httpd - daemon 158httpd - daemon
157hush - interactive, longterm 159hush - interactive, longterm
158hwclock - talks to hardware (xioctl(RTC_RD_TIME)) - needs ^C 160hwclock - hardware (xioctl(RTC_RD_TIME))
159i2cdetect 161i2cdetect - hardware
160i2cdump 162i2cdump - hardware
161i2cget 163i2cget - hardware
162i2cset 164i2cset - hardware
163id - noexec 165id - noexec
164ifconfig - leaks: xsocket+ioctl_or_perror_and_die 166ifconfig - leaks: xsocket+ioctl_or_perror_and_die
165ifenslave - leaks: xsocket+bb_perror_msg_and_die 167ifenslave - leaks: xsocket+bb_perror_msg_and_die
@@ -237,7 +239,7 @@ more - interactive, longterm
237mount - suid 239mount - suid
238mountpoint - noexec. leaks: option -n "print dev name": find_block_device -> readdir+xstrdup 240mountpoint - noexec. leaks: option -n "print dev name": find_block_device -> readdir+xstrdup
239mpstat - longterm: "mpstat 1" runs indefinitely 241mpstat - longterm: "mpstat 1" runs indefinitely
240mt - rare 242mt - hardware
241mv - noexec candidate, runner 243mv - noexec candidate, runner
242nameif - noexec. openlog(), leaks: config_open2+ioctl_or_perror_and_die 244nameif - noexec. openlog(), leaks: config_open2+ioctl_or_perror_and_die
243nbd-client - noexec 245nbd-client - noexec
@@ -257,8 +259,8 @@ paste - noexec. runner
257patch - needs ^C 259patch - needs ^C
258pgrep - nofork candidate(xregcomp, procps_scan - are they ok?) 260pgrep - nofork candidate(xregcomp, procps_scan - are they ok?)
259pidof - nofork candidate(uses find_pid_by_name, is that ok?) 261pidof - nofork candidate(uses find_pid_by_name, is that ok?)
260ping - suid, runner 262ping - suid, longterm
261ping6 - suid, runner 263ping6 - suid, longterm
262pipe_progress - longterm 264pipe_progress - longterm
263pivot_root - NOFORK 265pivot_root - NOFORK
264pkill - nofork candidate(xregcomp, procps_scan - are they ok?) 266pkill - nofork candidate(xregcomp, procps_scan - are they ok?)
@@ -282,7 +284,7 @@ realpath - NOFORK
282reboot - rare 284reboot - rare
283reformime - runner 285reformime - runner
284remove-shell - noexec. leaks: open+xfunc 286remove-shell - noexec. leaks: open+xfunc
285renice - nofork candidate(uses getpwnam, is that ok?) 287renice - noexec. nofork candidate(uses getpwnam, is that ok?)
286reset - noexec. spawner (execs "stty") 288reset - noexec. spawner (execs "stty")
287resize - noexec. changes state (signal handlers) 289resize - noexec. changes state (signal handlers)
288rev - runner 290rev - runner
@@ -358,21 +360,21 @@ timeout - spawner, longterm, changes state (signals)
358top - interactive, longterm 360top - interactive, longterm
359touch - NOFORK 361touch - NOFORK
360tr - runner 362tr - runner
361traceroute - suid, runner 363traceroute - suid, longterm
362traceroute6 - suid, runner 364traceroute6 - suid, longterm
363true - NOFORK 365true - NOFORK
364truncate - NOFORK 366truncate - NOFORK
365tty - NOFORK 367tty - NOFORK
366ttysize - NOFORK 368ttysize - NOFORK
367tunctl - noexec 369tunctl - noexec
368tune2fs - noexec. leaks: open+xfunc 370tune2fs - noexec. leaks: open+xfunc
369ubiattach - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 371ubiattach - hardware
370ubidetach - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 372ubidetach - hardware
371ubimkvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 373ubimkvol - hardware
372ubirename - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 374ubirename - hardware
373ubirmvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 375ubirmvol - hardware
374ubirsvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 376ubirsvol - hardware
375ubiupdatevol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) 377ubiupdatevol - hardware
376udhcpc - daemon 378udhcpc - daemon
377udhcpd - daemon 379udhcpd - daemon
378udpsvd - daemon 380udpsvd - daemon
@@ -388,8 +390,8 @@ unlzma - runner
388unlzop - runner 390unlzop - runner
389unxz - runner 391unxz - runner
390unzip - runner 392unzip - runner
391uptime - nofork candidate(is getutxent ok?) 393uptime - noexec. nofork candidate(is getutxent ok?)
392users - nofork candidate(is getutxent ok?) 394users - noexec. nofork candidate(is getutxent ok?)
393usleep - NOFORK 395usleep - NOFORK
394uudecode - runner 396uudecode - runner
395uuencode - runner 397uuencode - runner
@@ -397,14 +399,14 @@ vconfig - leaks: xsocket+ioctl_or_perror_and_die
397vi - interactive, longterm 399vi - interactive, longterm
398vlock - suid 400vlock - suid
399volname - runner 401volname - runner
400w - nofork candidate(is getutxent ok?) 402w - noexec. nofork candidate(is getutxent ok?)
401wall - suid 403wall - suid
402watch - longterm 404watch - longterm
403watchdog - daemon 405watchdog - daemon
404wc - runner 406wc - runner
405wget - longterm 407wget - longterm
406which - NOFORK 408which - NOFORK
407who - nofork candidate(is getutxent ok?) 409who - noexec. nofork candidate(is getutxent ok?)
408whoami - NOFORK 410whoami - NOFORK
409whois - needs ^C 411whois - needs ^C
410xargs - noexec. spawner 412xargs - noexec. spawner
diff --git a/coreutils/who.c b/coreutils/who.c
index 91f99138c..6be3d692e 100644
--- a/coreutils/who.c
+++ b/coreutils/who.c
@@ -38,10 +38,10 @@
38//config: help 38//config: help
39//config: Print users currently logged on. 39//config: Print users currently logged on.
40 40
41// APPLET_ODDNAME:name main location suid_type help 41// APPLET_NOEXEC:name main location suid_type help
42//applet:IF_USERS(APPLET_ODDNAME(users, who, BB_DIR_USR_BIN, BB_SUID_DROP, users)) 42//applet:IF_USERS(APPLET_NOEXEC(users, who, BB_DIR_USR_BIN, BB_SUID_DROP, users))
43//applet:IF_W( APPLET_ODDNAME(w, who, BB_DIR_USR_BIN, BB_SUID_DROP, w)) 43//applet:IF_W( APPLET_NOEXEC(w, who, BB_DIR_USR_BIN, BB_SUID_DROP, w))
44//applet:IF_WHO( APPLET( who, BB_DIR_USR_BIN, BB_SUID_DROP)) 44//applet:IF_WHO( APPLET_NOEXEC(who, who, BB_DIR_USR_BIN, BB_SUID_DROP, who))
45 45
46//kbuild:lib-$(CONFIG_USERS) += who.o 46//kbuild:lib-$(CONFIG_USERS) += who.o
47//kbuild:lib-$(CONFIG_W) += who.o 47//kbuild:lib-$(CONFIG_W) += who.o
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index ca2580e92..8d04d2259 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -42,6 +42,7 @@
42//applet:IF_I2CSET(APPLET(i2cset, BB_DIR_USR_SBIN, BB_SUID_DROP)) 42//applet:IF_I2CSET(APPLET(i2cset, BB_DIR_USR_SBIN, BB_SUID_DROP))
43//applet:IF_I2CDUMP(APPLET(i2cdump, BB_DIR_USR_SBIN, BB_SUID_DROP)) 43//applet:IF_I2CDUMP(APPLET(i2cdump, BB_DIR_USR_SBIN, BB_SUID_DROP))
44//applet:IF_I2CDETECT(APPLET(i2cdetect, BB_DIR_USR_SBIN, BB_SUID_DROP)) 44//applet:IF_I2CDETECT(APPLET(i2cdetect, BB_DIR_USR_SBIN, BB_SUID_DROP))
45/* not NOEXEC: if hw operation stalls, use less memory in "hung" process */
45 46
46//kbuild:lib-$(CONFIG_I2CGET) += i2c_tools.o 47//kbuild:lib-$(CONFIG_I2CGET) += i2c_tools.o
47//kbuild:lib-$(CONFIG_I2CSET) += i2c_tools.o 48//kbuild:lib-$(CONFIG_I2CSET) += i2c_tools.o
diff --git a/procps/uptime.c b/procps/uptime.c
index 24b2b39df..b0ee8391b 100644
--- a/procps/uptime.c
+++ b/procps/uptime.c
@@ -27,7 +27,7 @@
27//config: help 27//config: help
28//config: Display the number of users currently logged on. 28//config: Display the number of users currently logged on.
29 29
30//applet:IF_UPTIME(APPLET(uptime, BB_DIR_USR_BIN, BB_SUID_DROP)) 30//applet:IF_UPTIME(APPLET_NOEXEC(uptime, uptime, BB_DIR_USR_BIN, BB_SUID_DROP, uptime))
31 31
32//kbuild:lib-$(CONFIG_UPTIME) += uptime.o 32//kbuild:lib-$(CONFIG_UPTIME) += uptime.o
33 33
diff --git a/util-linux/renice.c b/util-linux/renice.c
index 23cbca88d..70c494b3d 100644
--- a/util-linux/renice.c
+++ b/util-linux/renice.c
@@ -25,7 +25,7 @@
25//config: Renice alters the scheduling priority of one or more running 25//config: Renice alters the scheduling priority of one or more running
26//config: processes. 26//config: processes.
27 27
28//applet:IF_RENICE(APPLET(renice, BB_DIR_USR_BIN, BB_SUID_DROP)) 28//applet:IF_RENICE(APPLET_NOEXEC(renice, renice, BB_DIR_USR_BIN, BB_SUID_DROP, renice))
29 29
30//kbuild:lib-$(CONFIG_RENICE) += renice.o 30//kbuild:lib-$(CONFIG_RENICE) += renice.o
31 31