diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-04 19:16:01 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-04 19:16:01 +0200 |
commit | 6514785f95878911b3ec88e2367234df74c14cd4 (patch) | |
tree | d5212cbe1de8c0fe15cb42e0c83c00ea6d77403c | |
parent | 947b2391c07f8a11f7bd4658f77cd03172fc221a (diff) | |
download | busybox-w32-6514785f95878911b3ec88e2367234df74c14cd4.tar.gz busybox-w32-6514785f95878911b3ec88e2367234df74c14cd4.tar.bz2 busybox-w32-6514785f95878911b3ec88e2367234df74c14cd4.zip |
mesg: make in NOFORK
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | NOFORK_NOEXEC.lst | 48 | ||||
-rw-r--r-- | util-linux/mesg.c | 9 |
2 files changed, 31 insertions, 26 deletions
diff --git a/NOFORK_NOEXEC.lst b/NOFORK_NOEXEC.lst index 730f2cc3c..ccd8f0c96 100644 --- a/NOFORK_NOEXEC.lst +++ b/NOFORK_NOEXEC.lst | |||
@@ -51,7 +51,7 @@ basename - NOFORK | |||
51 | beep | 51 | beep |
52 | blkdiscard | 52 | blkdiscard |
53 | blkid | 53 | blkid |
54 | blockdev | 54 | blockdev - noexec candidate (rather simple), leaks fd |
55 | bootchartd - daemon | 55 | bootchartd - daemon |
56 | brctl | 56 | brctl |
57 | bunzip2 - runner | 57 | bunzip2 - runner |
@@ -69,7 +69,7 @@ chpasswd - runner (list of "user:password"s from stdin) | |||
69 | chpst - noexec candidate, spawner | 69 | chpst - noexec candidate, spawner |
70 | chroot - noexec candidate, spawner | 70 | chroot - noexec candidate, spawner |
71 | chrt - noexec candidate, spawner | 71 | chrt - noexec candidate, spawner |
72 | chvt - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. Can be noexec. | 72 | chvt - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. noexec candidate. |
73 | cksum - noexec. runner | 73 | cksum - noexec. runner |
74 | clear - NOFORK | 74 | clear - NOFORK |
75 | cmp - runner | 75 | cmp - runner |
@@ -78,14 +78,14 @@ conspy - interactive, longterm | |||
78 | cp - noexec. runner | 78 | cp - noexec. runner |
79 | cpio - runner | 79 | cpio - runner |
80 | crond - daemon | 80 | crond - daemon |
81 | crontab | 81 | crontab 0 leaks: open+xasprintf |
82 | cryptpw - changes state: with --password-fd=N, moves N to stdin. Also, "rare" category. Can be noexec. | 82 | cryptpw - changes state: with --password-fd=N, moves N to stdin. Also, "rare" category. noexec candidate. |
83 | cttyhack - noexec candidate, spawner | 83 | cttyhack - noexec candidate, spawner |
84 | cut - noexec. runner | 84 | cut - noexec. runner |
85 | date - noexec. nofork candidate(needs to stop messing up env, free xasprintf result, not use xfuncs after xasprintf) | 85 | date - noexec. nofork candidate(needs to stop messing up env, free xasprintf result, not use xfuncs after xasprintf) |
86 | dc - runner (eats stdin if no params) | 86 | dc - runner (eats stdin if no params) |
87 | dd - noexec. runner | 87 | dd - noexec. runner |
88 | deallocvt - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. Can be noexec. | 88 | deallocvt - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. noexec candidate. |
89 | delgroup | 89 | delgroup |
90 | deluser | 90 | deluser |
91 | depmod - complex, rare | 91 | depmod - complex, rare |
@@ -100,8 +100,8 @@ dnsdomainname - needs ^C (may talk to DNS servers, which may be down) | |||
100 | dos2unix - noexec. runner | 100 | dos2unix - noexec. runner |
101 | dpkg - runner | 101 | dpkg - runner |
102 | du - runner | 102 | du - runner |
103 | dumpkmap - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. Can be noexec. | 103 | dumpkmap - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. noexec candidate. |
104 | dumpleases | 104 | dumpleases - leaks: open+xread |
105 | echo - NOFORK | 105 | echo - NOFORK |
106 | ed - interactive, longterm | 106 | ed - interactive, longterm |
107 | egrep - longterm runner ("CMD | egrep ..." may run indefinitely, better to exec to conserve memory) | 107 | egrep - longterm runner ("CMD | egrep ..." may run indefinitely, better to exec to conserve memory) |
@@ -120,7 +120,7 @@ fbsplash - runner, longterm | |||
120 | fdflush - leaks: open+ioctl_or_perror_and_die, needs ^C (floppy may be unresponsive), rare | 120 | fdflush - leaks: open+ioctl_or_perror_and_die, needs ^C (floppy may be unresponsive), rare |
121 | fdformat - needs ^C (floppy may be unresponsive), longterm, rare | 121 | fdformat - needs ^C (floppy may be unresponsive), longterm, rare |
122 | fdisk - interactive, longterm | 122 | fdisk - interactive, longterm |
123 | fgconsole - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. Can be noexec. | 123 | fgconsole - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. noexec candidate. |
124 | fgrep - longterm runner ("CMD | fgrep ..." may run indefinitely, better to exec to conserve memory) | 124 | fgrep - longterm runner ("CMD | fgrep ..." may run indefinitely, better to exec to conserve memory) |
125 | find - noexec. runner | 125 | find - noexec. runner |
126 | findfs - suid | 126 | findfs - suid |
@@ -133,7 +133,7 @@ fold - noexec. runner | |||
133 | free - nofork candidate(struct globals, needs to close /proc/meminfo fd) | 133 | free - nofork candidate(struct globals, needs to close /proc/meminfo fd) |
134 | freeramdisk - leaks: open+ioctl_or_perror_and_die | 134 | freeramdisk - leaks: open+ioctl_or_perror_and_die |
135 | fsck - interactive, longterm | 135 | fsck - interactive, longterm |
136 | fsck.minix | 136 | fsck.minix - needs ^C |
137 | fsfreeze - noexec candidate (it's very simple), leaks: open+xioctl | 137 | fsfreeze - noexec candidate (it's very simple), leaks: open+xioctl |
138 | fstrim - noexec candidate (it's very simple), leaks: open+xioctl, find_block_device -> readdir+xstrdup | 138 | fstrim - noexec candidate (it's very simple), leaks: open+xioctl, find_block_device -> readdir+xstrdup |
139 | fsync - NOFORK | 139 | fsync - NOFORK |
@@ -162,8 +162,8 @@ i2cdump | |||
162 | i2cget | 162 | i2cget |
163 | i2cset | 163 | i2cset |
164 | id - noexec | 164 | id - noexec |
165 | ifconfig | 165 | ifconfig - leaks: xsocket+ioctl_or_perror_and_die |
166 | ifenslave | 166 | ifenslave - leaks: xsocket+bb_perror_msg_and_die |
167 | ifplugd - daemon | 167 | ifplugd - daemon |
168 | inetd - daemon | 168 | inetd - daemon |
169 | init - daemon | 169 | init - daemon |
@@ -182,7 +182,7 @@ ipneigh - noexec candidate | |||
182 | iproute - noexec candidate | 182 | iproute - noexec candidate |
183 | iprule - noexec candidate | 183 | iprule - noexec candidate |
184 | iptunnel - noexec candidate | 184 | iptunnel - noexec candidate |
185 | kbd_mode | 185 | kbd_mode - leaks: xopen_nonblocking+xioctl |
186 | kill - NOFORK | 186 | kill - NOFORK |
187 | killall - NOFORK | 187 | killall - NOFORK |
188 | killall5 - NOFORK | 188 | killall5 - NOFORK |
@@ -194,8 +194,8 @@ linux32 - spawner | |||
194 | linux64 - spawner | 194 | linux64 - spawner |
195 | linuxrc - daemon | 195 | linuxrc - daemon |
196 | ln - noexec | 196 | ln - noexec |
197 | loadfont | 197 | loadfont - leaks: config_open+bb_error_msg_and_die("map format") |
198 | loadkmap - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. Can be noexec. | 198 | loadkmap - leaks: get_console_fd_or_die() may open a new fd, or return one of stdio fds. Also, "rare" category. noexec candidate. |
199 | logger - runner | 199 | logger - runner |
200 | login - suid, interactive, longterm | 200 | login - suid, interactive, longterm |
201 | logname - NOFORK | 201 | logname - NOFORK |
@@ -219,7 +219,7 @@ makemime - runner | |||
219 | man - spawner, interactive, longterm | 219 | man - spawner, interactive, longterm |
220 | md5sum - noexec. runner | 220 | md5sum - noexec. runner |
221 | mdev - daemon | 221 | mdev - daemon |
222 | mesg | 222 | mesg - NOFORK |
223 | microcom - interactive, longterm | 223 | microcom - interactive, longterm |
224 | mkdir - NOFORK | 224 | mkdir - NOFORK |
225 | mkdosfs - needs ^C | 225 | mkdosfs - needs ^C |
@@ -229,7 +229,7 @@ mkfs.ext2 - needs ^C | |||
229 | mkfs.minix - needs ^C | 229 | mkfs.minix - needs ^C |
230 | mkfs.vfat - needs ^C | 230 | mkfs.vfat - needs ^C |
231 | mknod - noexec | 231 | mknod - noexec |
232 | mkpasswd - changes state: with --password-fd=N, moves N to stdin. Also, "rare" category. Can be noexec. | 232 | mkpasswd - changes state: with --password-fd=N, moves N to stdin. Also, "rare" category. noexec candidate. |
233 | mkswap - needs ^C | 233 | mkswap - needs ^C |
234 | mktemp - noexec. leaks: xstrdup+concat_path_file | 234 | mktemp - noexec. leaks: xstrdup+concat_path_file |
235 | modinfo - noexec | 235 | modinfo - noexec |
@@ -239,8 +239,8 @@ mount - suid | |||
239 | mountpoint - noexec candidate, leaks: option -n "print dev name": find_block_device -> readdir+xstrdup | 239 | mountpoint - noexec candidate, leaks: option -n "print dev name": find_block_device -> readdir+xstrdup |
240 | mpstat - noexec candidate (it's a measuring tool, putting less load by itself is good), complex | 240 | mpstat - noexec candidate (it's a measuring tool, putting less load by itself is good), complex |
241 | mt - rare | 241 | mt - rare |
242 | mv - runner (can be noexec?) | 242 | mv - noexec candidate, runner |
243 | nameif | 243 | nameif - leaks: config_open2+ioctl_or_perror_and_die |
244 | nbd-client | 244 | nbd-client |
245 | nc - runner | 245 | nc - runner |
246 | netstat - runner with -c | 246 | netstat - runner with -c |
@@ -260,8 +260,8 @@ pgrep - nofork candidate(xregcomp, procps_scan - are they ok?) | |||
260 | pidof - nofork candidate(uses find_pid_by_name, is that ok?) | 260 | pidof - nofork candidate(uses find_pid_by_name, is that ok?) |
261 | ping - suid, runner | 261 | ping - suid, runner |
262 | ping6 - suid, runner | 262 | ping6 - suid, runner |
263 | pipe_progress | 263 | pipe_progress - longterm |
264 | pivot_root | 264 | pivot_root - nofork candidate? the code is trivial |
265 | pkill - nofork candidate(xregcomp, procps_scan - are they ok?) | 265 | pkill - nofork candidate(xregcomp, procps_scan - are they ok?) |
266 | pmap - noexec candidate, leaks: open+xstrdup | 266 | pmap - noexec candidate, leaks: open+xstrdup |
267 | popmaildir - runner | 267 | popmaildir - runner |
@@ -378,7 +378,7 @@ udhcpc - daemon | |||
378 | udhcpd - daemon | 378 | udhcpd - daemon |
379 | udpsvd - daemon | 379 | udpsvd - daemon |
380 | uevent - daemon | 380 | uevent - daemon |
381 | umount | 381 | umount - noexec candidate, leaks: nested xmalloc |
382 | uname - NOFORK | 382 | uname - NOFORK |
383 | uncompress - runner | 383 | uncompress - runner |
384 | unexpand - runner | 384 | unexpand - runner |
@@ -398,16 +398,16 @@ vconfig - leaks: xsocket+ioctl_or_perror_and_die | |||
398 | vi - interactive, longterm | 398 | vi - interactive, longterm |
399 | vlock - suid | 399 | vlock - suid |
400 | volname - runner | 400 | volname - runner |
401 | w | 401 | w - nofork candidate(is getutxent ok?) |
402 | wall - suid | 402 | wall - suid |
403 | watch - longterm | 403 | watch - longterm |
404 | watchdog - daemon | 404 | watchdog - daemon |
405 | wc - runner | 405 | wc - runner |
406 | wget - longterm | 406 | wget - longterm |
407 | which - NOFORK | 407 | which - NOFORK |
408 | who | 408 | who - nofork candidate(is getutxent ok?) |
409 | whoami - NOFORK | 409 | whoami - NOFORK |
410 | whois | 410 | whois - needs ^C |
411 | xargs - noexec. spawner | 411 | xargs - noexec. spawner |
412 | xxd - noexec. runner | 412 | xxd - noexec. runner |
413 | xz - runner | 413 | xz - runner |
diff --git a/util-linux/mesg.c b/util-linux/mesg.c index c4371eb24..91c05317e 100644 --- a/util-linux/mesg.c +++ b/util-linux/mesg.c | |||
@@ -26,7 +26,7 @@ | |||
26 | //config: If you set this option to N, "mesg y" will enable writing | 26 | //config: If you set this option to N, "mesg y" will enable writing |
27 | //config: by anybody at all. This is not recommended. | 27 | //config: by anybody at all. This is not recommended. |
28 | 28 | ||
29 | //applet:IF_MESG(APPLET(mesg, BB_DIR_USR_BIN, BB_SUID_DROP)) | 29 | //applet:IF_MESG(APPLET_NOFORK(mesg, mesg, BB_DIR_USR_BIN, BB_SUID_DROP, mesg)) |
30 | 30 | ||
31 | //kbuild:lib-$(CONFIG_MESG) += mesg.o | 31 | //kbuild:lib-$(CONFIG_MESG) += mesg.o |
32 | 32 | ||
@@ -60,10 +60,15 @@ int mesg_main(int argc UNUSED_PARAM, char **argv) | |||
60 | bb_show_usage(); | 60 | bb_show_usage(); |
61 | } | 61 | } |
62 | 62 | ||
63 | /* We are a NOFORK applet. | ||
64 | * (Not that it's very useful, but code is trivially NOFORK-safe). | ||
65 | * Play nice. Do not leak anything. | ||
66 | */ | ||
67 | |||
63 | if (!isatty(STDIN_FILENO)) | 68 | if (!isatty(STDIN_FILENO)) |
64 | bb_error_msg_and_die("not a tty"); | 69 | bb_error_msg_and_die("not a tty"); |
65 | 70 | ||
66 | xfstat(STDIN_FILENO, &sb, "stderr"); | 71 | xfstat(STDIN_FILENO, &sb, "stdin"); |
67 | if (c == 0) { | 72 | if (c == 0) { |
68 | puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); | 73 | puts((sb.st_mode & (S_IWGRP|S_IWOTH)) ? "is y" : "is n"); |
69 | return EXIT_SUCCESS; | 74 | return EXIT_SUCCESS; |