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