pmap: tweak help text, show usage if no params are given

Noticed while auditing nofork/noexec status

function                                             old     new   delta
pmap_main                                             70      80     +10
packed_usage                                       31747   31744      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2017-08-04 18:36:55 +02:00
parent 83d7785e41
commit 947b2391c0
2 changed files with 32 additions and 31 deletions

View File

@ -135,7 +135,7 @@ freeramdisk - leaks: open+ioctl_or_perror_and_die
fsck - interactive, longterm fsck - interactive, longterm
fsck.minix fsck.minix
fsfreeze - noexec candidate (it's very simple), leaks: open+xioctl fsfreeze - noexec candidate (it's very simple), leaks: open+xioctl
fstrim - noexec candidate (it's very simple), leaks: open+xioctl fstrim - noexec candidate (it's very simple), leaks: open+xioctl, find_block_device -> readdir+xstrdup
fsync - NOFORK fsync - NOFORK
ftpd - daemon ftpd - daemon
ftpget - runner ftpget - runner
@ -153,7 +153,7 @@ hdparm - complex, rare
head - noexec. runner head - noexec. runner
hexdump - noexec. runner hexdump - noexec. runner
hostid - NOFORK hostid - NOFORK
hostname - DNS resolution may trigger, need ^C hostname - needs ^C (may talk to DNS servers, which may be down)
httpd - daemon httpd - daemon
hush - interactive, longterm hush - interactive, longterm
hwclock - talks to hardware (xioctl(RTC_RD_TIME)) - needs ^C hwclock - talks to hardware (xioctl(RTC_RD_TIME)) - needs ^C
@ -222,40 +222,40 @@ mdev - daemon
mesg mesg
microcom - interactive, longterm microcom - interactive, longterm
mkdir - NOFORK mkdir - NOFORK
mkdosfs mkdosfs - needs ^C
mke2fs mke2fs - needs ^C
mkfifo - noexec mkfifo - noexec
mkfs.ext2 mkfs.ext2 - needs ^C
mkfs.minix mkfs.minix - needs ^C
mkfs.vfat mkfs.vfat - needs ^C
mknod - noexec mknod - noexec
mkpasswd mkpasswd - changes state: with --password-fd=N, moves N to stdin. Also, "rare" category. Can be noexec.
mkswap mkswap - needs ^C
mktemp - noexec. leaks: xstrdup+concat_path_file mktemp - noexec. leaks: xstrdup+concat_path_file
modinfo - noexec modinfo - noexec
modprobe - noexec modprobe - noexec
more - interactive, longterm more - interactive, longterm
mount - suid mount - suid
mountpoint mountpoint - noexec candidate, leaks: option -n "print dev name": find_block_device -> readdir+xstrdup
mpstat mpstat - noexec candidate (it's a measuring tool, putting less load by itself is good), complex
mt mt - rare
mv - runner (can be noexec?) mv - runner (can be noexec?)
nameif nameif
nbd-client nbd-client
nc - runner nc - runner
netstat - runner with -c netstat - runner with -c
nice - spawner nice - noexec candidate, spawner
nl - runner nl - runner
nmeter - runner nmeter - longterm
nohup - spawner nohup - noexec candidate (maybe free concat_path_file result?), spawner
nproc - NOFORK nproc - NOFORK
ntpd - daemon ntpd - daemon
od - runner od - runner
openvt - spawner openvt - spawner
partprobe partprobe - noexec candidate (simple), leaks: open+ioctl_or_perror_and_die(BLKRRPART)
passwd - suid passwd - suid
paste - noexec. runner paste - noexec. runner
patch patch - needs ^C
pgrep - nofork candidate(xregcomp, procps_scan - are they ok?) pgrep - nofork candidate(xregcomp, procps_scan - are they ok?)
pidof - nofork candidate(uses find_pid_by_name, is that ok?) pidof - nofork candidate(uses find_pid_by_name, is that ok?)
ping - suid, runner ping - suid, runner
@ -263,7 +263,7 @@ ping6 - suid, runner
pipe_progress pipe_progress
pivot_root pivot_root
pkill - nofork candidate(xregcomp, procps_scan - are they ok?) pkill - nofork candidate(xregcomp, procps_scan - are they ok?)
pmap pmap - noexec candidate, leaks: open+xstrdup
popmaildir - runner popmaildir - runner
poweroff - rare poweroff - rare
powertop - interactive, longterm powertop - interactive, longterm
@ -275,8 +275,8 @@ pstree
pwd - NOFORK pwd - NOFORK
pwdx - NOFORK pwdx - NOFORK
raidautorun raidautorun
rdate rdate - needs ^C (may talk to DNS servers, which may be down)
rdev rdev - leaks: find_block_device -> readdir+xstrdup
readlink - NOFORK readlink - NOFORK
readprofile readprofile
realpath - NOFORK realpath - NOFORK
@ -284,16 +284,16 @@ reboot - rare
reformime - runner reformime - runner
remove-shell remove-shell
renice - nofork candidate(uses getpwnam, is that ok?) renice - nofork candidate(uses getpwnam, is that ok?)
reset - spawner (execs "stty") reset - noexec candidate, spawner (execs "stty")
resize - noexec. changes state (signal handlers) resize - noexec. changes state (signal handlers)
rev - runner rev - runner
rm - noexec. rm -i interactive rm - noexec. rm -i interactive
rmdir - NOFORK rmdir - NOFORK
rmmod - noexec rmmod - noexec
route route - needs ^C (may talk to DNS servers, which may be down)
rpm - runner rpm - runner
rpm2cpio - runner rpm2cpio - runner
rtcwake - puts system to sleep, optimizing this for speed is pointless rtcwake - longterm: puts system to sleep, optimizing this for speed is pointless
run-parts run-parts
runlevel - noexec. can be nofork if "endutxent()" is called unconditionally, but too rare to bother? runlevel - noexec. can be nofork if "endutxent()" is called unconditionally, but too rare to bother?
runsv - daemon runsv - daemon
@ -321,27 +321,27 @@ showkey - interactive, longterm
shred - runner shred - runner
shuf - noexec. runner shuf - noexec. runner
slattach slattach
sleep - runner sleep - runner, longterm
smemcap - runner smemcap - runner
softlimit - spawner softlimit - noexec candidate, spawner
sort - noexec. runner sort - noexec. runner
split - runner split - runner
ssl_client - network ssl_client - longterm
start-stop-daemon start-stop-daemon
stat - nofork candidate(needs fewer allocs) stat - nofork candidate(needs fewer allocs)
strings - runner strings - runner
stty 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
su - suid, spawner su - suid, spawner
sulogin - spawner sulogin - spawner
sum - runner sum - runner
sv sv - noexec candidate, needs ^C (uses usleep(420000))
svc svc - noexec candidate, needs ^C (uses usleep(420000))
svlogd - daemon svlogd - daemon
swapoff - rare swapoff - rare
swapon - rare swapon - rare
switch_root - spawner, rare, changes state switch_root - spawner, rare, changes state
sync - NOFORK sync - NOFORK
sysctl sysctl - noexec candidate, leaks: xstrdup+xmalloc_read
syslogd - daemon syslogd - daemon
tac - noexec. runner tac - noexec. runner
tail - runner tail - runner

View File

@ -18,7 +18,7 @@
//kbuild:lib-$(CONFIG_PMAP) += pmap.o //kbuild:lib-$(CONFIG_PMAP) += pmap.o
//usage:#define pmap_trivial_usage //usage:#define pmap_trivial_usage
//usage: "[-xq] PID" //usage: "[-xq] PID..."
//usage:#define pmap_full_usage "\n\n" //usage:#define pmap_full_usage "\n\n"
//usage: "Display process memory usage" //usage: "Display process memory usage"
//usage: "\n" //usage: "\n"
@ -96,6 +96,7 @@ int pmap_main(int argc UNUSED_PARAM, char **argv)
unsigned opts; unsigned opts;
int ret; int ret;
opt_complementary = "-1"; /* min one arg */
opts = getopt32(argv, "xq"); opts = getopt32(argv, "xq");
argv += optind; argv += optind;