981a10192ff4d2debb97a1ac491a7dbcf4e705f4
[oweals/busybox.git] / NOFORK_NOEXEC.lst
1 Why an applet can't be NOFORK or NOEXEC?
2
3 Why can't be NOFORK:
4 interactive: may wait for user input, ^C has to work
5 spawner: "tool PROG ARGS" which changes program state and execs - must fork
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
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)
12
13 "runners" can become eligible after shell is taught ^C to interrupt NOFORKs,
14 need to be inspected that they do not fall into alloc+xfunc, open+xfunc,
15 leak categories.
16
17 Why can't be NOEXEC:
18 suid: runs under different uid - must fork+exec
19
20 Why shouldn't be NOFORK/NOEXEC:
21 rare: not started often enough to bother optimizing (example: poweroff)
22 daemon: runs indefinitely; these are also always fit "rare" category
23 longterm: often runs for a long time (many seconds), execing makes
24         memory footprint smaller
25 complex: no immediately obvious reason why NOFORK wouldn't work,
26         but does some non-obvoius operations (example: fuser, lsof, losetup);
27         detailed audit often turns out that it's a leaker
28
29 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
31 for users to keep it waiting for many minutes, whereas running "rm" in shell
32 is very typical, and speeding up this common use via NOEXEC is useful.
33 IOW: rm is "interactive", but not "longterm".
34
35
36 [ - NOFORK
37 [[ - NOFORK
38 acpid - daemon
39 add-shell - noexec. leaks: open+xfunc
40 addgroup - noexec. leaks
41 adduser - noexec. leaks
42 adjtimex - NOFORK
43 ar - runner
44 arch - NOFORK
45 arp - complex, rare
46 arping - runner
47 ash - interactive, longterm
48 awk - noexec. runner
49 base64 - runner
50 basename - NOFORK
51 beep - longterm: beep -r 999999999
52 blkdiscard - noexec. leaks: open+xioctl
53 blkid - noexec
54 blockdev - noexec. leaks fd
55 bootchartd - daemon
56 brctl - noexec
57 bunzip2 - runner
58 bzcat - runner
59 bzip2 - runner
60 cal - runner: cal -n9999
61 cat - runner
62 chat - needs ^C to work
63 chattr - noexec. runner
64 chgrp - noexec. runner
65 chmod - noexec. runner
66 chown - noexec. runner
67 chpasswd - runner (list of "user:password"s from stdin)
68 chpst - noexec. spawner
69 chroot - noexec. spawner
70 chrt - noexec. spawner
71 chvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
72 cksum - noexec. runner
73 clear - NOFORK
74 cmp - runner
75 comm - runner
76 conspy - interactive, longterm
77 cp - noexec. runner
78 cpio - runner
79 crond - daemon
80 crontab - longterm (runs $EDITOR), leaks: open+xasprintf
81 cryptpw - noexec. changes state: with --password-fd=N, moves N to stdin
82 cttyhack - noexec. spawner
83 cut - noexec. runner
84 date - noexec. nofork candidate(needs to stop messing up env, free xasprintf result, not use xfuncs after xasprintf)
85 dc - runner (eats stdin if no params)
86 dd - noexec. runner
87 deallocvt - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
88 delgroup - noexec. leaks
89 deluser - noexec. leaks
90 depmod - complex, rare
91 devmem - runner, complex (access to device memory may hang)
92 df - leaks: nested allocs
93 dhcprelay - daemon
94 diff - runner
95 dirname - NOFORK
96 dmesg - runner
97 dnsd - daemon
98 dnsdomainname - needs ^C (may talk to DNS servers, which may be down)
99 dos2unix - noexec. runner
100 dpkg - runner
101 du - runner
102 dumpkmap - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
103 dumpleases - leaks: open+xread
104 echo - NOFORK
105 ed - interactive, longterm
106 egrep - longterm runner ("CMD | egrep ..."  may run indefinitely, better to exec to conserve memory)
107 eject - leaks: open+ioctl_or_perror_and_die, changes state (moves fds)
108 env - noexec. spawner, changes state (env)
109 envdir - noexec. spawner
110 envuidgid - noexec. spawner
111 expand - runner
112 expr - leaks: nested allocs
113 factor - runner (eats stdin if no params)
114 fakeidentd - daemon
115 false - NOFORK
116 fatattr - leaks: open+xioctl, complex
117 fbset - leaks: open+xfunc, complex, rare
118 fbsplash - runner, longterm
119 fdflush - leaks: open+ioctl_or_perror_and_die, needs ^C (floppy may be unresponsive), rare
120 fdformat - needs ^C (floppy may be unresponsive), longterm, rare
121 fdisk - interactive, longterm
122 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)
124 find - noexec. runner
125 findfs - suid
126 flash_eraseall - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
127 flash_lock - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
128 flash_unlock - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
129 flashcp - needs ^C. could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
130 flock - spawner, changes state (file locks), let's play safe and not be noexec
131 fold - noexec. runner
132 free - nofork candidate(struct globals, needs to close /proc/meminfo fd)
133 freeramdisk - leaks: open+ioctl_or_perror_and_die
134 fsck - interactive, longterm
135 fsck.minix - needs ^C
136 fsfreeze - noexec. leaks: open+xioctl
137 fstrim - noexec. leaks: open+xioctl, find_block_device -> readdir+xstrdup
138 fsync - NOFORK
139 ftpd - daemon
140 ftpget - runner
141 ftpput - runner
142 fuser - complex
143 getopt - noexec. leaks: many allocs
144 getty - interactive, longterm
145 grep - longterm runner ("CMD | grep ..."  may run indefinitely, better to exec to conserve memory)
146 groups - noexec
147 gunzip - runner
148 gzip - runner
149 halt - rare
150 hd - noexec. runner
151 hdparm - complex, rare
152 head - noexec. runner
153 hexdump - noexec. runner
154 hostid - NOFORK
155 hostname - needs ^C (may talk to DNS servers, which may be down)
156 httpd - daemon
157 hush - interactive, longterm
158 hwclock - talks to hardware (xioctl(RTC_RD_TIME)) - needs ^C
159 i2cdetect
160 i2cdump
161 i2cget
162 i2cset
163 id - noexec
164 ifconfig - leaks: xsocket+ioctl_or_perror_and_die
165 ifenslave - leaks: xsocket+bb_perror_msg_and_die
166 ifplugd - daemon
167 inetd - daemon
168 init - daemon
169 inotifyd - daemon
170 insmod - noexec
171 install - runner
172 ionice - noexec. spawner
173 iostat - runner
174 ip - noexec candidate
175 ipaddr - noexec candidate
176 ipcalc - noexec candidate
177 ipcrm - noexec candidate
178 ipcs - noexec candidate
179 iplink - noexec candidate
180 ipneigh - noexec candidate
181 iproute - noexec candidate
182 iprule - noexec candidate
183 iptunnel - noexec candidate
184 kbd_mode - noexec. leaks: xopen_nonblocking+xioctl
185 kill - NOFORK
186 killall - NOFORK
187 killall5 - NOFORK
188 klogd - daemon
189 last - runner (I've got 1300 lines of output when tried it)
190 less - interactive, longterm
191 link - NOFORK
192 linux32 - noexec. spawner
193 linux64 - noexec. spawner
194 linuxrc - daemon
195 ln - noexec
196 loadfont - noexec. leaks: config_open+bb_error_msg_and_die("map format")
197 loadkmap - noexec. leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds
198 logger - runner
199 login - suid, interactive, longterm
200 logname - NOFORK
201 losetup - complex
202 lpd - daemon
203 lpq - runner
204 lpr - runner
205 ls - noexec. runner
206 lsattr - noexec. runner
207 lsmod - noexec
208 lsof - complex
209 lspci - noexec. too rare to bother for nofork
210 lsscsi - noexec. too rare to bother for nofork
211 lsusb - noexec. too rare to bother for nofork
212 lzcat - runner
213 lzma - runner
214 lzop - runner
215 lzopcat - runner
216 makedevs - noexec
217 makemime - runner
218 man - spawner, interactive, longterm
219 md5sum - noexec. runner
220 mdev - daemon
221 mesg - NOFORK
222 microcom - interactive, longterm
223 mkdir - NOFORK
224 mkdosfs - needs ^C
225 mke2fs - needs ^C
226 mkfifo - noexec
227 mkfs.ext2 - needs ^C
228 mkfs.minix - needs ^C
229 mkfs.vfat - needs ^C
230 mknod - noexec
231 mkpasswd - noexec. changes state: with --password-fd=N, moves N to stdin
232 mkswap - needs ^C
233 mktemp - noexec. leaks: xstrdup+concat_path_file
234 modinfo - noexec
235 modprobe - noexec
236 more - interactive, longterm
237 mount - suid
238 mountpoint - noexec. leaks: option -n "print dev name": find_block_device -> readdir+xstrdup
239 mpstat - longterm: "mpstat 1" runs indefinitely
240 mt - rare
241 mv - noexec candidate, runner
242 nameif - noexec. openlog(), leaks: config_open2+ioctl_or_perror_and_die
243 nbd-client - noexec
244 nc - runner
245 netstat - runner with -c
246 nice - noexec. spawner
247 nl - runner
248 nmeter - longterm
249 nohup - noexec. spawner
250 nproc - NOFORK
251 ntpd - daemon
252 od - runner
253 openvt - longterm: spawns a child and waits for it
254 partprobe - noexec. leaks: open+ioctl_or_perror_and_die(BLKRRPART)
255 passwd - suid
256 paste - noexec. runner
257 patch - needs ^C
258 pgrep - nofork candidate(xregcomp, procps_scan - are they ok?)
259 pidof - nofork candidate(uses find_pid_by_name, is that ok?)
260 ping - suid, runner
261 ping6 - suid, runner
262 pipe_progress - longterm
263 pivot_root - NOFORK
264 pkill - nofork candidate(xregcomp, procps_scan - are they ok?)
265 pmap - noexec candidate, leaks: open+xstrdup
266 popmaildir - runner
267 poweroff - rare
268 powertop - interactive, longterm
269 printenv - NOFORK
270 printf - NOFORK
271 ps - looks for AT_CLKTCK elf aux vector, therefore can't be noexec
272 pscan - longterm
273 pstree - noexec
274 pwd - NOFORK
275 pwdx - NOFORK
276 raidautorun - noexec. very simple. leaks: open+xioctl
277 rdate - needs ^C (may talk to DNS servers, which may be down)
278 rdev - leaks: find_block_device -> readdir+xstrdup
279 readlink - NOFORK
280 readprofile - reads /boot/System.map and /proc/profile, better to free more memory by execing?
281 realpath - NOFORK
282 reboot - rare
283 reformime - runner
284 remove-shell - noexec. leaks: open+xfunc
285 renice - nofork candidate(uses getpwnam, is that ok?)
286 reset - noexec. spawner (execs "stty")
287 resize - noexec. changes state (signal handlers)
288 rev - runner
289 rm - noexec. rm -i interactive
290 rmdir - NOFORK
291 rmmod - noexec
292 route - needs ^C (may talk to DNS servers, which may be down)
293 rpm - runner
294 rpm2cpio - runner
295 rtcwake - longterm: puts system to sleep, optimizing this for speed is pointless
296 run-parts - longterm
297 runlevel - noexec. can be nofork if "endutxent()" is called unconditionally, but too rare to bother?
298 runsv - daemon
299 runsvdir - daemon
300 rx - runner
301 script - longterm: pumps script output from slave pty
302 scriptreplay - longterm: plays back "script" saved output, sleeping as necessary.
303 sed - runner
304 sendmail - runner
305 seq - noexec. runner
306 setarch - noexec. spawner
307 setconsole - noexec
308 setfont - noexec. leaks a lot of stuff
309 setkeycodes - noexec
310 setlogcons - noexec
311 setpriv - spawner, changes state, let's play safe and not be noexec
312 setserial - noexec
313 setsid - spawner, uses fork_or_rexec() [not audited to work in noexec], let's play safe and not be noexec
314 setuidgid - noexec. spawner
315 sha1sum - noexec. runner
316 sha256sum - noexec. runner
317 sha3sum - noexec. runner
318 sha512sum - noexec. runner
319 showkey - interactive, longterm
320 shred - runner
321 shuf - noexec. runner
322 slattach - longterm (may sleep forever), uses bb_common_bufsiz1
323 sleep - runner, longterm
324 smemcap - runner
325 softlimit - noexec. spawner
326 sort - noexec. runner
327 split - runner
328 ssl_client - longterm
329 start-stop-daemon - not noexec: uses bb_common_bufsiz1
330 stat - nofork candidate(needs fewer allocs)
331 strings - runner
332 stty - noexec. nofork candidate: has no allocs or opens except xmove_fd(xopen("-F DEVICE"),STDIN). tcsetattr(STDIN) is not a problem: it would work the same across processes sharing this fd
333 su - suid, spawner
334 sulogin - noexec. spawner
335 sum - runner
336 sv - noexec. needs ^C (uses usleep(420000))
337 svc - noexec. needs ^C (uses usleep(420000))
338 svlogd - daemon
339 swapoff - rare
340 swapon - rare
341 switch_root - spawner, rare, changes state (oh yes), execing may be important to free binary's inode
342 sync - NOFORK
343 sysctl - noexec. leaks: xstrdup+xmalloc_read
344 syslogd - daemon
345 tac - noexec. runner
346 tail - runner
347 tar - runner
348 taskset - noexec. spawner
349 tcpsvd - daemon
350 tee - runner
351 telnet - interactive, longterm
352 telnetd - daemon
353 test - NOFORK
354 tftp - runner
355 tftpd - daemon
356 time - spawner, longterm, changes state (signals)
357 timeout - spawner, longterm, changes state (signals)
358 top - interactive, longterm
359 touch - NOFORK
360 tr - runner
361 traceroute - suid, runner
362 traceroute6 - suid, runner
363 true - NOFORK
364 truncate - NOFORK
365 tty - NOFORK
366 ttysize - NOFORK
367 tunctl - noexec
368 tune2fs - noexec. leaks: open+xfunc
369 ubiattach - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
370 ubidetach - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
371 ubimkvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
372 ubirename - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
373 ubirmvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
374 ubirsvol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
375 ubiupdatevol - could be noexec, but I feel flash ops are risky (prone to hw/fw/sw bugs)
376 udhcpc - daemon
377 udhcpd - daemon
378 udpsvd - daemon
379 uevent - daemon
380 umount - noexec. leaks: nested xmalloc
381 uname - NOFORK
382 uncompress - runner
383 unexpand - runner
384 uniq - runner
385 unix2dos - noexec. runner
386 unlink - NOFORK
387 unlzma - runner
388 unlzop - runner
389 unxz - runner
390 unzip - runner
391 uptime - nofork candidate(is getutxent ok?)
392 users - nofork candidate(is getutxent ok?)
393 usleep - NOFORK
394 uudecode - runner
395 uuencode - runner
396 vconfig - leaks: xsocket+ioctl_or_perror_and_die
397 vi - interactive, longterm
398 vlock - suid
399 volname - runner
400 w - nofork candidate(is getutxent ok?)
401 wall - suid
402 watch - longterm
403 watchdog - daemon
404 wc - runner
405 wget - longterm
406 which - NOFORK
407 who - nofork candidate(is getutxent ok?)
408 whoami - NOFORK
409 whois - needs ^C
410 xargs - noexec. spawner
411 xxd - noexec. runner
412 xz - runner
413 xzcat - runner
414 yes - noexec. runner
415 zcat - runner
416 zcip - daemon