diff options
author | Masatake YAMATO <yamato@redhat.com> | 2021-12-01 06:22:40 +0900 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2023-02-20 08:00:00 +0000 |
commit | 6a0c56322626a33b368795e66a8bd8e70fe05e5a (patch) | |
tree | 17eecdb3c57bcd54855e1657318fc1db99637d49 | |
parent | c15a5b82351bfd7e4116a8ed83f769543c5227b9 (diff) | |
download | strace-6a0c56322626a33b368795e66a8bd8e70fe05e5a.tar.gz |
ioctl: prepare finfo only when ioctl command can overlap
If an ioctl decoder does not deal with overlapping commands,
avoid issuing extra syscalls required to obtain finfo.
* src/ioctl.c (ioctl_command_overlaps): New function.
(SYS_FUNC(ioctl)): Call getfdpath_pid only when ioctl_command_overlaps
returns true.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Dmitry V. Levin <ldv@strace.io>
-rw-r--r-- | src/ioctl.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ioctl.c b/src/ioctl.c index 5cb3d9df5..20e1f3230 100644 --- a/src/ioctl.c +++ b/src/ioctl.c @@ -431,6 +431,16 @@ ioctl_decode(struct tcb *tcp) return 0; } +/* + * Return true if the specified ioctl command may overlap. + */ +static bool +ioctl_command_overlaps(unsigned int code) +{ + /* see <asm-generic/ioctls.h> and <linux/soundcard.h> */ + return (0x5401 <= code && code <= 0x5408); +} + SYS_FUNC(ioctl) { const struct_ioctlent *iop; @@ -441,7 +451,8 @@ SYS_FUNC(ioctl) struct finfo *finfo = NULL; char path[PATH_MAX + 1]; bool deleted; - if (getfdpath_pid(tcp->pid, tcp->u_arg[0], path, sizeof(path), + if (ioctl_command_overlaps(tcp->u_arg[1]) && + getfdpath_pid(tcp->pid, tcp->u_arg[0], path, sizeof(path), &deleted) >= 0) { finfo = get_finfo_for_dev(path, &finfoa); finfo->deleted = deleted; |