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