diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-03 03:29:32 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-03 03:29:32 +0200 |
commit | 819b47aa357c33bf84919495795b36f8c1faa3ac (patch) | |
tree | 7ba0ddb384c2e7fdf581989f66085b95a78e0976 | |
parent | 39701204cfa0f261beb2dc056024634e4c3afd71 (diff) | |
download | busybox-w32-819b47aa357c33bf84919495795b36f8c1faa3ac.tar.gz busybox-w32-819b47aa357c33bf84919495795b36f8c1faa3ac.tar.bz2 busybox-w32-819b47aa357c33bf84919495795b36f8c1faa3ac.zip |
new NOFORKs: clear, nproc, tty, uname, arch, unlink, which
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | NOFORK_NOEXEC.lst | 404 | ||||
-rw-r--r-- | console-tools/clear.c | 2 | ||||
-rw-r--r-- | coreutils/nproc.c | 2 | ||||
-rw-r--r-- | coreutils/tty.c | 2 | ||||
-rw-r--r-- | coreutils/uname.c | 6 | ||||
-rw-r--r-- | coreutils/unlink.c | 2 | ||||
-rw-r--r-- | debianutils/which.c | 4 |
7 files changed, 414 insertions, 8 deletions
diff --git a/NOFORK_NOEXEC.lst b/NOFORK_NOEXEC.lst new file mode 100644 index 000000000..02eba46e8 --- /dev/null +++ b/NOFORK_NOEXEC.lst | |||
@@ -0,0 +1,404 @@ | |||
1 | Why an applet can't be NOFORK or NOEXEC? | ||
2 | |||
3 | Why can't be NOFORK: | ||
4 | daemon: runs indefinitely | ||
5 | interactive: may wait for user input, ^C has to work | ||
6 | spawner: "tool PROG ARGS" which changes program's environment - must fork | ||
7 | changes state: e.g. environment, signal handlers | ||
8 | runner: sometimes may run for long time, and/or works with network: | ||
9 | ^C has to work (cat BIGFILE, chmod -R, ftpget, nc) | ||
10 | |||
11 | "runners" can become eligible after hush is taught ^C to interrupt NOFORKs! | ||
12 | |||
13 | Why can't be NOEXEC: | ||
14 | suid: runs under different uid - must fork+exec | ||
15 | |||
16 | Why shouldn't be NOFORK/NOEXEC: | ||
17 | complex: no immediately obvious reason why NOFORK wouldn't work, | ||
18 | but does some non-obvoius operations (example: fuser, lsof, losetup). | ||
19 | for NOFORK, nested xmallocs (typical in complex code) is a problem. | ||
20 | rare: not used often enough to bother optimizing (example: poweroff) | ||
21 | |||
22 | [ - NOFORK | ||
23 | [[ - NOFORK | ||
24 | acpid - daemon | ||
25 | add-shell | ||
26 | addgroup | ||
27 | adduser | ||
28 | adjtimex | ||
29 | ar - runner | ||
30 | arch - NOFORK | ||
31 | arp | ||
32 | arping - runner | ||
33 | ash - interactive | ||
34 | awk - noexec, runner | ||
35 | base64 - runner | ||
36 | basename - NOFORK | ||
37 | beep | ||
38 | blkdiscard | ||
39 | blkid | ||
40 | blockdev | ||
41 | bootchartd - daemon | ||
42 | brctl | ||
43 | bunzip2 - runner | ||
44 | busybox | ||
45 | bzcat - runner | ||
46 | bzip2 - runner | ||
47 | cal | ||
48 | cat - runner | ||
49 | chat | ||
50 | chattr - runner | ||
51 | chgrp - noexec, runner | ||
52 | chmod - noexec, runner | ||
53 | chown - noexec, runner | ||
54 | chpasswd - runner (list of "user:password"s from stdin) | ||
55 | chpst - spawner | ||
56 | chroot - spawner | ||
57 | chrt - spawner | ||
58 | chvt | ||
59 | cksum - noexec, runner | ||
60 | clear - NOFORK | ||
61 | cmp - runner | ||
62 | comm - runner | ||
63 | conspy - interactive | ||
64 | cp - noexec, runner | ||
65 | cpio - runner | ||
66 | crond - daemon | ||
67 | crontab | ||
68 | cryptpw | ||
69 | cttyhack - spawner | ||
70 | cut - noexec, runner | ||
71 | date | ||
72 | dc - runner (eats stdin if no params) | ||
73 | dd - noexec, runner | ||
74 | deallocvt | ||
75 | delgroup | ||
76 | deluser | ||
77 | depmod | ||
78 | devmem | ||
79 | df | ||
80 | dhcprelay - daemon | ||
81 | diff - runner | ||
82 | dirname - NOFORK | ||
83 | dmesg | ||
84 | dnsd - daemon | ||
85 | dnsdomainname | ||
86 | dos2unix - noexec, runner | ||
87 | dpkg - runner | ||
88 | du | ||
89 | dumpkmap | ||
90 | dumpleases | ||
91 | echo - NOFORK | ||
92 | ed - interactive | ||
93 | egrep - runner | ||
94 | eject | ||
95 | env - noexec, changes state (env) | ||
96 | envdir - spawner | ||
97 | envuidgid - spawner | ||
98 | expand - runner | ||
99 | expr | ||
100 | factor - runner (eats stdin if no params) | ||
101 | fakeidentd - daemon | ||
102 | false - NOFORK | ||
103 | fatattr | ||
104 | fbset | ||
105 | fbsplash - runner, interactive | ||
106 | fdflush | ||
107 | fdformat - runner | ||
108 | fdisk - interactive | ||
109 | fgconsole | ||
110 | fgrep - runner | ||
111 | find - noexec, runner | ||
112 | findfs - suid | ||
113 | flash_eraseall | ||
114 | flash_lock | ||
115 | flash_unlock | ||
116 | flashcp | ||
117 | flock | ||
118 | fold - noexec, runner | ||
119 | free | ||
120 | freeramdisk | ||
121 | fsck - interactive | ||
122 | fsck.minix | ||
123 | fsfreeze | ||
124 | fstrim | ||
125 | fsync - NOFORK | ||
126 | ftpd - daemon | ||
127 | ftpget - runner | ||
128 | ftpput - runner | ||
129 | fuser - complex | ||
130 | getopt | ||
131 | getty - interactive | ||
132 | grep - runner | ||
133 | groups - noexec | ||
134 | gunzip - runner | ||
135 | gzip - runner | ||
136 | halt - rare | ||
137 | hd - noexec, runner | ||
138 | hdparm - complex, rare | ||
139 | head - noexec, runner | ||
140 | hexdump - noexec, runner | ||
141 | hostid - NOFORK | ||
142 | hostname | ||
143 | httpd - daemon | ||
144 | hush - interactive | ||
145 | hwclock | ||
146 | i2cdetect | ||
147 | i2cdump | ||
148 | i2cget | ||
149 | i2cset | ||
150 | id - noexec | ||
151 | ifconfig | ||
152 | ifenslave | ||
153 | ifplugd - daemon | ||
154 | inetd - daemon | ||
155 | init - daemon | ||
156 | inotifyd - daemon | ||
157 | insmod | ||
158 | install - runner | ||
159 | ionice - spawner | ||
160 | iostat - runner | ||
161 | ip | ||
162 | ipaddr | ||
163 | ipcalc | ||
164 | ipcrm | ||
165 | ipcs | ||
166 | iplink | ||
167 | ipneigh | ||
168 | iproute | ||
169 | iprule | ||
170 | iptunnel | ||
171 | kbd_mode | ||
172 | kill | ||
173 | killall | ||
174 | killall5 | ||
175 | klogd - daemon | ||
176 | last | ||
177 | less - interactive | ||
178 | link - NOFORK | ||
179 | linux32 - spawner | ||
180 | linux64 - spawner | ||
181 | linuxrc - daemon | ||
182 | ln - noexec | ||
183 | loadfont | ||
184 | loadkmap | ||
185 | logger - runner | ||
186 | login - suid, interactive | ||
187 | logname - NOFORK | ||
188 | losetup - complex | ||
189 | lpd - daemon | ||
190 | lpq - runner | ||
191 | lpr - runner | ||
192 | ls - noexec, runner | ||
193 | lsattr | ||
194 | lsmod | ||
195 | lsof - complex | ||
196 | lspci | ||
197 | lsscsi | ||
198 | lsusb | ||
199 | lzcat - runner | ||
200 | lzma - runner | ||
201 | lzop - runner | ||
202 | lzopcat - runner | ||
203 | makedevs | ||
204 | makemime - runner | ||
205 | man - spawner, interactive | ||
206 | md5sum - noexec, runner | ||
207 | mdev - daemon | ||
208 | mesg | ||
209 | microcom - interactive, complex | ||
210 | mkdir - NOFORK | ||
211 | mkdosfs | ||
212 | mke2fs | ||
213 | mkfifo - noexec | ||
214 | mkfs.ext2 | ||
215 | mkfs.minix | ||
216 | mkfs.vfat | ||
217 | mknod - noexec | ||
218 | mkpasswd | ||
219 | mkswap | ||
220 | mktemp | ||
221 | modinfo | ||
222 | modprobe | ||
223 | more - interactive | ||
224 | mount - suid | ||
225 | mountpoint | ||
226 | mpstat | ||
227 | mt | ||
228 | mv | ||
229 | nameif | ||
230 | nbd-client | ||
231 | nc - runner | ||
232 | netstat | ||
233 | nice - spawner | ||
234 | nl - runner | ||
235 | nmeter - runner | ||
236 | nohup - spawner | ||
237 | nproc - NOFORK | ||
238 | ntpd - daemon | ||
239 | od - runner | ||
240 | openvt - spawner | ||
241 | partprobe | ||
242 | passwd - suid | ||
243 | paste - noexec, runner | ||
244 | patch | ||
245 | pgrep | ||
246 | pidof | ||
247 | ping - suid, runner | ||
248 | ping6 - suid, runner | ||
249 | pipe_progress | ||
250 | pivot_root | ||
251 | pkill | ||
252 | pmap | ||
253 | popmaildir - runner | ||
254 | poweroff - rare | ||
255 | powertop - interactive | ||
256 | printenv - NOFORK | ||
257 | printf - NOFORK | ||
258 | ps | ||
259 | pscan | ||
260 | pstree | ||
261 | pwd - NOFORK | ||
262 | pwdx | ||
263 | raidautorun | ||
264 | rdate | ||
265 | rdev | ||
266 | readlink | ||
267 | readprofile | ||
268 | realpath | ||
269 | reboot - rare | ||
270 | reformime - runner | ||
271 | remove-shell | ||
272 | renice | ||
273 | reset - spawner (execs "stty") | ||
274 | resize | ||
275 | rev - runner | ||
276 | rm - noexec, rm -i interactive | ||
277 | rmdir - NOFORK | ||
278 | rmmod | ||
279 | route | ||
280 | rpm - runner | ||
281 | rpm2cpio - runner | ||
282 | rtcwake - complex, rare | ||
283 | run-parts | ||
284 | runlevel | ||
285 | runsv - daemon | ||
286 | runsvdir - daemon | ||
287 | rx - runner | ||
288 | script | ||
289 | scriptreplay | ||
290 | sed - runner | ||
291 | sendmail - runner | ||
292 | seq - noexec, runner | ||
293 | setarch - spawner | ||
294 | setconsole | ||
295 | setfont | ||
296 | setkeycodes | ||
297 | setlogcons | ||
298 | setpriv - spawner | ||
299 | setserial | ||
300 | setsid - spawner | ||
301 | setuidgid | ||
302 | sh - interactive | ||
303 | sha1sum - noexec, runner | ||
304 | sha256sum - noexec, runner | ||
305 | sha3sum - noexec, runner | ||
306 | sha512sum - noexec, runner | ||
307 | showkey - interactive | ||
308 | shred - runner | ||
309 | shuf - noexec, runner | ||
310 | slattach | ||
311 | sleep - runner | ||
312 | smemcap - runner | ||
313 | softlimit - spawner | ||
314 | sort - noexec, runner | ||
315 | split - runner | ||
316 | ssl_client - network | ||
317 | start-stop-daemon | ||
318 | stat | ||
319 | strings - runner | ||
320 | stty | ||
321 | su - suid, spawner | ||
322 | sulogin - spawner | ||
323 | sum - runner | ||
324 | sv | ||
325 | svc | ||
326 | svlogd - daemon | ||
327 | swapoff - rare | ||
328 | swapon - rare | ||
329 | switch_root - spawner, rare, change state | ||
330 | sync - NOFORK | ||
331 | sysctl | ||
332 | syslogd - daemon | ||
333 | tac - noexec, runner | ||
334 | tail - runner | ||
335 | tar - runner | ||
336 | taskset - spawner | ||
337 | tcpsvd - daemon | ||
338 | tee - runner | ||
339 | telnet - interactive | ||
340 | telnetd - daemon | ||
341 | test - NOFORK | ||
342 | tftp - runner | ||
343 | tftpd - daemon | ||
344 | time - spawner, change state (signals) | ||
345 | timeout - spawner, change state (signals) | ||
346 | top - interactive | ||
347 | touch - NOFORK | ||
348 | tr - runner | ||
349 | traceroute - suid, runner | ||
350 | traceroute6 - suid, runner | ||
351 | true - NOFORK | ||
352 | truncate - NOFORK | ||
353 | tty - NOFORK | ||
354 | ttysize | ||
355 | tunctl | ||
356 | tune2fs | ||
357 | ubiattach | ||
358 | ubidetach | ||
359 | ubimkvol | ||
360 | ubirename | ||
361 | ubirmvol | ||
362 | ubirsvol | ||
363 | ubiupdatevol | ||
364 | udhcpc - daemon | ||
365 | udhcpd - daemon | ||
366 | udpsvd - daemon | ||
367 | uevent - daemon | ||
368 | umount | ||
369 | uname - NOFORK | ||
370 | uncompress - runner | ||
371 | unexpand - runner | ||
372 | uniq - runner | ||
373 | unix2dos - noexec, runner | ||
374 | unlink - NOFORK | ||
375 | unlzma - runner | ||
376 | unlzop - runner | ||
377 | unxz - runner | ||
378 | unzip - runner | ||
379 | uptime | ||
380 | users | ||
381 | usleep - NOFORK | ||
382 | uudecode - runner | ||
383 | uuencode - runner | ||
384 | vconfig | ||
385 | vi - interactive | ||
386 | vlock - suid | ||
387 | volname - runner | ||
388 | w | ||
389 | wall - suid | ||
390 | watch - runner | ||
391 | watchdog - daemon | ||
392 | wc - runner | ||
393 | wget - runner | ||
394 | which - NOFORK | ||
395 | who | ||
396 | whoami - NOFORK | ||
397 | whois | ||
398 | xargs - noexec, spawner | ||
399 | xxd - noexec, runner | ||
400 | xz - runner | ||
401 | xzcat - runner | ||
402 | yes - noexec, runner | ||
403 | zcat - runner | ||
404 | zcip - daemon | ||
diff --git a/console-tools/clear.c b/console-tools/clear.c index 13eec498b..3cc16257b 100644 --- a/console-tools/clear.c +++ b/console-tools/clear.c | |||
@@ -12,7 +12,7 @@ | |||
12 | //config: help | 12 | //config: help |
13 | //config: This program clears the terminal screen. | 13 | //config: This program clears the terminal screen. |
14 | 14 | ||
15 | //applet:IF_CLEAR(APPLET(clear, BB_DIR_USR_BIN, BB_SUID_DROP)) | 15 | //applet:IF_CLEAR(APPLET_NOFORK(clear, clear, BB_DIR_USR_BIN, BB_SUID_DROP, clear)) |
16 | 16 | ||
17 | //kbuild:lib-$(CONFIG_CLEAR) += clear.o | 17 | //kbuild:lib-$(CONFIG_CLEAR) += clear.o |
18 | 18 | ||
diff --git a/coreutils/nproc.c b/coreutils/nproc.c index 68a831865..0ae55e70a 100644 --- a/coreutils/nproc.c +++ b/coreutils/nproc.c | |||
@@ -9,7 +9,7 @@ | |||
9 | //config: help | 9 | //config: help |
10 | //config: Print number of CPUs | 10 | //config: Print number of CPUs |
11 | 11 | ||
12 | //applet:IF_NPROC(APPLET(nproc, BB_DIR_USR_BIN, BB_SUID_DROP)) | 12 | //applet:IF_NPROC(APPLET_NOFORK(nproc, nproc, BB_DIR_USR_BIN, BB_SUID_DROP, nproc)) |
13 | 13 | ||
14 | //kbuild:lib-$(CONFIG_NPROC) += nproc.o | 14 | //kbuild:lib-$(CONFIG_NPROC) += nproc.o |
15 | 15 | ||
diff --git a/coreutils/tty.c b/coreutils/tty.c index 331941a01..18ad7c566 100644 --- a/coreutils/tty.c +++ b/coreutils/tty.c | |||
@@ -13,7 +13,7 @@ | |||
13 | //config: tty is used to print the name of the current terminal to | 13 | //config: tty is used to print the name of the current terminal to |
14 | //config: standard output. | 14 | //config: standard output. |
15 | 15 | ||
16 | //applet:IF_TTY(APPLET(tty, BB_DIR_USR_BIN, BB_SUID_DROP)) | 16 | //applet:IF_TTY(APPLET_NOFORK(tty, tty, BB_DIR_USR_BIN, BB_SUID_DROP, tty)) |
17 | 17 | ||
18 | //kbuild:lib-$(CONFIG_TTY) += tty.o | 18 | //kbuild:lib-$(CONFIG_TTY) += tty.o |
19 | 19 | ||
diff --git a/coreutils/uname.c b/coreutils/uname.c index aad58cab0..d6e447e33 100644 --- a/coreutils/uname.c +++ b/coreutils/uname.c | |||
@@ -63,9 +63,9 @@ | |||
63 | //config: help | 63 | //config: help |
64 | //config: Same as uname -m. | 64 | //config: Same as uname -m. |
65 | 65 | ||
66 | //applet:IF_UNAME(APPLET(uname, BB_DIR_BIN, BB_SUID_DROP)) | 66 | // APPLET_NOFORK:name main location suid_type help |
67 | // APPLET_ODDNAME:name main location suid_type help | 67 | //applet:IF_UNAME(APPLET_NOFORK( uname, uname, BB_DIR_BIN, BB_SUID_DROP, uname)) |
68 | //applet:IF_BB_ARCH(APPLET_ODDNAME(arch, uname, BB_DIR_BIN, BB_SUID_DROP, arch)) | 68 | //applet:IF_BB_ARCH(APPLET_NOFORK(arch, uname, BB_DIR_BIN, BB_SUID_DROP, arch)) |
69 | 69 | ||
70 | //kbuild:lib-$(CONFIG_UNAME) += uname.o | 70 | //kbuild:lib-$(CONFIG_UNAME) += uname.o |
71 | //kbuild:lib-$(CONFIG_BB_ARCH) += uname.o | 71 | //kbuild:lib-$(CONFIG_BB_ARCH) += uname.o |
diff --git a/coreutils/unlink.c b/coreutils/unlink.c index 3322d5b47..e32a9743c 100644 --- a/coreutils/unlink.c +++ b/coreutils/unlink.c | |||
@@ -11,7 +11,7 @@ | |||
11 | //config: help | 11 | //config: help |
12 | //config: unlink deletes a file by calling unlink() | 12 | //config: unlink deletes a file by calling unlink() |
13 | 13 | ||
14 | //applet:IF_UNLINK(APPLET(unlink, BB_DIR_USR_BIN, BB_SUID_DROP)) | 14 | //applet:IF_UNLINK(APPLET_NOFORK(unlink, unlink, BB_DIR_USR_BIN, BB_SUID_DROP, unlink)) |
15 | 15 | ||
16 | //kbuild:lib-$(CONFIG_UNLINK) += unlink.o | 16 | //kbuild:lib-$(CONFIG_UNLINK) += unlink.o |
17 | 17 | ||
diff --git a/debianutils/which.c b/debianutils/which.c index 3197ddac1..b31d61871 100644 --- a/debianutils/which.c +++ b/debianutils/which.c | |||
@@ -12,7 +12,7 @@ | |||
12 | //config: which is used to find programs in your PATH and | 12 | //config: which is used to find programs in your PATH and |
13 | //config: print out their pathnames. | 13 | //config: print out their pathnames. |
14 | 14 | ||
15 | //applet:IF_WHICH(APPLET(which, BB_DIR_USR_BIN, BB_SUID_DROP)) | 15 | //applet:IF_WHICH(APPLET_NOFORK(which, which, BB_DIR_USR_BIN, BB_SUID_DROP, which)) |
16 | 16 | ||
17 | //kbuild:lib-$(CONFIG_WHICH) += which.o | 17 | //kbuild:lib-$(CONFIG_WHICH) += which.o |
18 | 18 | ||
@@ -56,6 +56,8 @@ int which_main(int argc UNUSED_PARAM, char **argv) | |||
56 | char *p; | 56 | char *p; |
57 | 57 | ||
58 | path = tmp = xstrdup(env_path); | 58 | path = tmp = xstrdup(env_path); |
59 | //NOFORK FIXME: nested xmallocs (one is inside find_executable()) | ||
60 | //can leak memory on failure | ||
59 | while ((p = find_executable(*argv, &tmp)) != NULL) { | 61 | while ((p = find_executable(*argv, &tmp)) != NULL) { |
60 | missing = 0; | 62 | missing = 0; |
61 | puts(p); | 63 | puts(p); |