diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-07 16:47:34 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-07 16:47:34 +0200 |
commit | 1a1203ff8909efc003bb6bf679a6afd6628dc179 (patch) | |
tree | 543504b74dd44b83536ff3b2da079586c6401a2e | |
parent | 798b94518e61ced3f7be7766727705df4859878c (diff) | |
download | busybox-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.lst | 72 | ||||
-rw-r--r-- | coreutils/who.c | 8 | ||||
-rw-r--r-- | miscutils/i2c_tools.c | 1 | ||||
-rw-r--r-- | procps/uptime.c | 2 | ||||
-rw-r--r-- | util-linux/renice.c | 2 |
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: | |||
4 | interactive: may wait for user input, ^C has to work | 4 | interactive: may wait for user input, ^C has to work |
5 | spawner: "tool PROG ARGS" which changes program state and execs - must fork | 5 | spawner: "tool PROG ARGS" which changes program state and execs - must fork |
6 | changes state: e.g. environment, signal handlers | 6 | changes state: e.g. environment, signal handlers |
7 | alloc+xfunc: xmalloc, then xfunc - leaks memory if xfunc dies | ||
8 | open+xfunc: opens fd, then calls xfunc - fd is leaked if xfunc dies | ||
9 | leaks: does not free allocated memory or opened fds | 7 | leaks: 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 | ||
10 | runner: sometimes may run for long(ish) time, and/or works with network: | 10 | runner: 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 | |||
25 | complex: no immediately obvious reason why NOFORK wouldn't work, | 25 | complex: 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 |
28 | hardware: performs unusual hardware ops which may take long, | ||
29 | or even hang due to hardware or firmware bugs | ||
28 | 30 | ||
29 | Interesting example of "interactive" applet which is nevertheless can be | 31 | Interesting 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 | |||
42 | adjtimex - NOFORK | 44 | adjtimex - NOFORK |
43 | ar - runner | 45 | ar - runner |
44 | arch - NOFORK | 46 | arch - NOFORK |
45 | arp - complex, rare | 47 | arp - runner, needs ^C: arp -n talks to DNS servers |
46 | arping - runner | 48 | arping - longterm |
47 | ash - interactive, longterm | 49 | ash - interactive, longterm |
48 | awk - noexec. runner | 50 | awk - noexec. runner |
49 | base64 - runner | 51 | base64 - runner |
@@ -87,7 +89,7 @@ dd - noexec. runner | |||
87 | deallocvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds | 89 | deallocvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds |
88 | delgroup - noexec. leaks | 90 | delgroup - noexec. leaks |
89 | deluser - noexec. leaks | 91 | deluser - noexec. leaks |
90 | depmod - complex, rare | 92 | depmod - longterm(ish) |
91 | devmem - runner, complex (access to device memory may hang) | 93 | devmem - runner, complex (access to device memory may hang) |
92 | df - leaks: nested allocs | 94 | df - leaks: nested allocs |
93 | dhcprelay - daemon | 95 | dhcprelay - daemon |
@@ -114,19 +116,19 @@ factor - runner (eats stdin if no params) | |||
114 | fakeidentd - daemon | 116 | fakeidentd - daemon |
115 | false - NOFORK | 117 | false - NOFORK |
116 | fatattr - leaks: open+xioctl, complex | 118 | fatattr - leaks: open+xioctl, complex |
117 | fbset - leaks: open+xfunc, complex, rare | 119 | fbset - hardware, leaks: open+xfunc |
118 | fbsplash - runner, longterm | 120 | fbsplash - runner, longterm |
119 | fdflush - leaks: open+ioctl_or_perror_and_die, needs ^C (floppy may be unresponsive), rare | 121 | fdflush - hardware, leaks: open+ioctl_or_perror_and_die |
120 | fdformat - needs ^C (floppy may be unresponsive), longterm, rare | 122 | fdformat - hardware, needs ^C (floppy may be unresponsive), longterm |
121 | fdisk - interactive, longterm | 123 | fdisk - interactive, longterm |
122 | fgconsole - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds | 124 | fgconsole - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds |
123 | fgrep - longterm runner ("CMD | fgrep ..." may run indefinitely, better to exec to conserve memory) | 125 | fgrep - longterm runner ("CMD | fgrep ..." may run indefinitely, better to exec to conserve memory) |
124 | find - noexec. runner | 126 | find - noexec. runner |
125 | findfs - suid | 127 | findfs - suid |
126 | flash_eraseall - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 128 | flash_eraseall - hardware |
127 | flash_lock - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 129 | flash_lock - hardware |
128 | flash_unlock - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 130 | flash_unlock - hardware |
129 | flashcp - needs ^C. could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 131 | flashcp - hardware |
130 | flock - spawner, changes state (file locks), let's play safe and not be noexec | 132 | flock - spawner, changes state (file locks), let's play safe and not be noexec |
131 | fold - noexec. runner | 133 | fold - noexec. runner |
132 | free - nofork candidate(struct globals, needs to close /proc/meminfo fd) | 134 | free - nofork candidate(struct globals, needs to close /proc/meminfo fd) |
@@ -148,18 +150,18 @@ gunzip - runner | |||
148 | gzip - runner | 150 | gzip - runner |
149 | halt - rare | 151 | halt - rare |
150 | hd - noexec. runner | 152 | hd - noexec. runner |
151 | hdparm - complex, rare | 153 | hdparm - hardware |
152 | head - noexec. runner | 154 | head - noexec. runner |
153 | hexdump - noexec. runner | 155 | hexdump - noexec. runner |
154 | hostid - NOFORK | 156 | hostid - NOFORK |
155 | hostname - needs ^C (may talk to DNS servers, which may be down) | 157 | hostname - needs ^C (may talk to DNS servers, which may be down) |
156 | httpd - daemon | 158 | httpd - daemon |
157 | hush - interactive, longterm | 159 | hush - interactive, longterm |
158 | hwclock - talks to hardware (xioctl(RTC_RD_TIME)) - needs ^C | 160 | hwclock - hardware (xioctl(RTC_RD_TIME)) |
159 | i2cdetect | 161 | i2cdetect - hardware |
160 | i2cdump | 162 | i2cdump - hardware |
161 | i2cget | 163 | i2cget - hardware |
162 | i2cset | 164 | i2cset - hardware |
163 | id - noexec | 165 | id - noexec |
164 | ifconfig - leaks: xsocket+ioctl_or_perror_and_die | 166 | ifconfig - leaks: xsocket+ioctl_or_perror_and_die |
165 | ifenslave - leaks: xsocket+bb_perror_msg_and_die | 167 | ifenslave - leaks: xsocket+bb_perror_msg_and_die |
@@ -237,7 +239,7 @@ more - interactive, longterm | |||
237 | mount - suid | 239 | mount - suid |
238 | mountpoint - noexec. leaks: option -n "print dev name": find_block_device -> readdir+xstrdup | 240 | mountpoint - noexec. leaks: option -n "print dev name": find_block_device -> readdir+xstrdup |
239 | mpstat - longterm: "mpstat 1" runs indefinitely | 241 | mpstat - longterm: "mpstat 1" runs indefinitely |
240 | mt - rare | 242 | mt - hardware |
241 | mv - noexec candidate, runner | 243 | mv - noexec candidate, runner |
242 | nameif - noexec. openlog(), leaks: config_open2+ioctl_or_perror_and_die | 244 | nameif - noexec. openlog(), leaks: config_open2+ioctl_or_perror_and_die |
243 | nbd-client - noexec | 245 | nbd-client - noexec |
@@ -257,8 +259,8 @@ paste - noexec. runner | |||
257 | patch - needs ^C | 259 | patch - needs ^C |
258 | pgrep - nofork candidate(xregcomp, procps_scan - are they ok?) | 260 | pgrep - nofork candidate(xregcomp, procps_scan - are they ok?) |
259 | pidof - nofork candidate(uses find_pid_by_name, is that ok?) | 261 | pidof - nofork candidate(uses find_pid_by_name, is that ok?) |
260 | ping - suid, runner | 262 | ping - suid, longterm |
261 | ping6 - suid, runner | 263 | ping6 - suid, longterm |
262 | pipe_progress - longterm | 264 | pipe_progress - longterm |
263 | pivot_root - NOFORK | 265 | pivot_root - NOFORK |
264 | pkill - nofork candidate(xregcomp, procps_scan - are they ok?) | 266 | pkill - nofork candidate(xregcomp, procps_scan - are they ok?) |
@@ -282,7 +284,7 @@ realpath - NOFORK | |||
282 | reboot - rare | 284 | reboot - rare |
283 | reformime - runner | 285 | reformime - runner |
284 | remove-shell - noexec. leaks: open+xfunc | 286 | remove-shell - noexec. leaks: open+xfunc |
285 | renice - nofork candidate(uses getpwnam, is that ok?) | 287 | renice - noexec. nofork candidate(uses getpwnam, is that ok?) |
286 | reset - noexec. spawner (execs "stty") | 288 | reset - noexec. spawner (execs "stty") |
287 | resize - noexec. changes state (signal handlers) | 289 | resize - noexec. changes state (signal handlers) |
288 | rev - runner | 290 | rev - runner |
@@ -358,21 +360,21 @@ timeout - spawner, longterm, changes state (signals) | |||
358 | top - interactive, longterm | 360 | top - interactive, longterm |
359 | touch - NOFORK | 361 | touch - NOFORK |
360 | tr - runner | 362 | tr - runner |
361 | traceroute - suid, runner | 363 | traceroute - suid, longterm |
362 | traceroute6 - suid, runner | 364 | traceroute6 - suid, longterm |
363 | true - NOFORK | 365 | true - NOFORK |
364 | truncate - NOFORK | 366 | truncate - NOFORK |
365 | tty - NOFORK | 367 | tty - NOFORK |
366 | ttysize - NOFORK | 368 | ttysize - NOFORK |
367 | tunctl - noexec | 369 | tunctl - noexec |
368 | tune2fs - noexec. leaks: open+xfunc | 370 | tune2fs - noexec. leaks: open+xfunc |
369 | ubiattach - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 371 | ubiattach - hardware |
370 | ubidetach - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 372 | ubidetach - hardware |
371 | ubimkvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 373 | ubimkvol - hardware |
372 | ubirename - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 374 | ubirename - hardware |
373 | ubirmvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 375 | ubirmvol - hardware |
374 | ubirsvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 376 | ubirsvol - hardware |
375 | ubiupdatevol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs) | 377 | ubiupdatevol - hardware |
376 | udhcpc - daemon | 378 | udhcpc - daemon |
377 | udhcpd - daemon | 379 | udhcpd - daemon |
378 | udpsvd - daemon | 380 | udpsvd - daemon |
@@ -388,8 +390,8 @@ unlzma - runner | |||
388 | unlzop - runner | 390 | unlzop - runner |
389 | unxz - runner | 391 | unxz - runner |
390 | unzip - runner | 392 | unzip - runner |
391 | uptime - nofork candidate(is getutxent ok?) | 393 | uptime - noexec. nofork candidate(is getutxent ok?) |
392 | users - nofork candidate(is getutxent ok?) | 394 | users - noexec. nofork candidate(is getutxent ok?) |
393 | usleep - NOFORK | 395 | usleep - NOFORK |
394 | uudecode - runner | 396 | uudecode - runner |
395 | uuencode - runner | 397 | uuencode - runner |
@@ -397,14 +399,14 @@ vconfig - leaks: xsocket+ioctl_or_perror_and_die | |||
397 | vi - interactive, longterm | 399 | vi - interactive, longterm |
398 | vlock - suid | 400 | vlock - suid |
399 | volname - runner | 401 | volname - runner |
400 | w - nofork candidate(is getutxent ok?) | 402 | w - noexec. nofork candidate(is getutxent ok?) |
401 | wall - suid | 403 | wall - suid |
402 | watch - longterm | 404 | watch - longterm |
403 | watchdog - daemon | 405 | watchdog - daemon |
404 | wc - runner | 406 | wc - runner |
405 | wget - longterm | 407 | wget - longterm |
406 | which - NOFORK | 408 | which - NOFORK |
407 | who - nofork candidate(is getutxent ok?) | 409 | who - noexec. nofork candidate(is getutxent ok?) |
408 | whoami - NOFORK | 410 | whoami - NOFORK |
409 | whois - needs ^C | 411 | whois - needs ^C |
410 | xargs - noexec. spawner | 412 | xargs - 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 | ||