Implement io_pgetevents syscall decoding

Introduced by Linux commit v4.17-rc3-7-g7a074e9.

* print_aio_sigset.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* aio.c (print_io_getevents): Rename from SYS_FUNC(io_getevents), add
has_usig flag, print user sigset on exiting if has_usig is set to true.
(SYS_FUNC(io_getevents), SYS_FUNC(io_pgetevents)): New functions,
wrappers for print_io_getevents.
* linux/32/syscallent.h ([292]): Wire up io_pgetevents.
* linux/64/syscallent.h ([292]): Likewise.
* linux/i386/syscallent.h ([385]): Likewise.
* linux/x32/syscallent.h ([333]): Likewise.
* linux/x86_64/syscallent.h ([333]): Likewise.
* NEWS: Mention this improvement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
Eugene Syromyatnikov 2018-06-07 19:57:28 +02:00 committed by Dmitry V. Levin
parent 6527c044f3
commit 8f996fc157
9 changed files with 78 additions and 3 deletions

View File

@ -241,6 +241,7 @@ strace_SOURCES = \
pkeys.c \
poll.c \
prctl.c \
print_aio_sigset.c \
print_dev_t.c \
print_group_req.c \
print_fields.h \

1
NEWS
View File

@ -36,6 +36,7 @@ Noteworthy changes in release ?.?? (????-??-??)
* Enhanced decoding of BTRFS_*, FS_IOC_*, SIOCGIFHWADDR, and SIOCSIFHWADDR
ioctl commands.
* Enhanced decoding of AF_BLUETOOTH socket addresses.
* Implemented decoding of io_pgetevent syscall.
* Updated lists of ADJ_*, BPF_*, BPF_F_*, BPF_PROG_TYPE_*, ETH_P_*, FPE_*,
IFF_*, IPPROTO_*, MAP_*, MS_*, MSG_*, NETLINK_*, PACKET_*, PROT_*, SCTP_*,
SECCOMP_FILTER_FLAG_*, SEGV_*, SEM_*, SHM_*, SW_*, V4L2_CID_*,

19
aio.c
View File

@ -238,7 +238,8 @@ SYS_FUNC(io_cancel)
return 0;
}
SYS_FUNC(io_getevents)
static int
print_io_getevents(struct tcb *tcp, bool has_usig)
{
if (entering(tcp)) {
printaddr(tcp->u_arg[0]);
@ -251,13 +252,27 @@ SYS_FUNC(io_getevents)
tfetch_mem, print_io_event, 0);
tprints(", ");
/*
* Since the timeout parameter is read by the kernel
* Since the timeout and usig parameters are read by the kernel
* on entering syscall, it has to be decoded the same way
* whether the syscall has failed or not.
*/
temporarily_clear_syserror(tcp);
print_timespec(tcp, tcp->u_arg[4]);
if (has_usig) {
tprints(", ");
print_aio_sigset(tcp, tcp->u_arg[5]);
}
restore_cleared_syserror(tcp);
}
return 0;
}
SYS_FUNC(io_getevents)
{
return print_io_getevents(tcp, false);
}
SYS_FUNC(io_pgetevents)
{
return print_io_getevents(tcp, true);
}

View File

@ -282,6 +282,7 @@
[289] = { 2, 0, SEN(pkey_alloc), "pkey_alloc" },
[290] = { 1, 0, SEN(pkey_free), "pkey_free" },
[291] = { 5, TD|TF|TSTA, SEN(statx), "statx" },
[292] = { 6, 0, SEN(io_pgetevents), "io_pgetevents" },
#undef sys_ARCH_mmap
#undef ARCH_WANT_SYNC_FILE_RANGE2

View File

@ -275,3 +275,4 @@
[289] = { 2, 0, SEN(pkey_alloc), "pkey_alloc" },
[290] = { 1, 0, SEN(pkey_free), "pkey_free" },
[291] = { 5, TD|TF|TSTA, SEN(statx), "statx" },
[292] = { 6, 0, SEN(io_pgetevents), "io_pgetevents" },

View File

@ -411,6 +411,7 @@
[382] = { 1, 0, SEN(pkey_free), "pkey_free" },
[383] = { 5, TD|TF|TSTA, SEN(statx), "statx" },
[384] = { 2, TP, SEN(arch_prctl), "arch_prctl" },
[385] = { 6, 0, SEN(io_pgetevents), "io_pgetevents" },
#define SYS_socket_subcall 400
#include "subcall.h"

View File

@ -331,7 +331,8 @@
[330] = { 2, 0, SEN(pkey_alloc), "pkey_alloc" },
[331] = { 1, 0, SEN(pkey_free), "pkey_free" },
[332] = { 5, TD|TF|TSTA, SEN(statx), "statx" },
[333 ... 511] = { },
[333] = { 6, 0, SEN(io_pgetevents), "io_pgetevents" },
[334 ... 511] = { },
/*
* x32-specific system call numbers start at 512 to avoid cache impact
* for native 64-bit operation.

View File

@ -331,3 +331,4 @@
[330] = { 2, 0, SEN(pkey_alloc), "pkey_alloc" },
[331] = { 1, 0, SEN(pkey_free), "pkey_free" },
[332] = { 5, TD|TF|TSTA, SEN(statx), "statx" },
[333] = { 6, 0, SEN(io_pgetevents), "io_pgetevents" },

53
print_aio_sigset.c Normal file
View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2018 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#include DEF_MPERS_TYPE(strace_aio_sigset)
typedef struct {
sigset_t *sigmask;
size_t sigsetsize;
} strace_aio_sigset;
#include MPERS_DEFS
#include "print_fields.h"
MPERS_PRINTER_DECL(void, print_aio_sigset, struct tcb *tcp,
const kernel_ulong_t addr)
{
strace_aio_sigset sigset;
if (!umove_or_printaddr(tcp, addr, &sigset)) {
tprints("{sigmask=");
print_sigset_addr_len(tcp, (uintptr_t) sigset.sigmask,
sigset.sigsetsize);
PRINT_FIELD_U(", ", sigset, sigsetsize);
tprints("}");
}
}