From 76b4c33c7f5e353c43ba5e4c7dd8222b13e4c6d1 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 13 May 2016 02:33:33 +0000 Subject: [PATCH] ptrace: decode data argument of PTRACE_PEEKSIGINFO request The data argument of PTRACE_PEEKSIGINFO request is a pointer to siginfo_t array. * printsiginfo.c (print_siginfo_t): New function. (print_siginfo_array): New mpers printer. * process.c (SYS_FUNC(ptrace)): Print data argument of PTRACE_PEEKSIGINFO request using print_siginfo_array. --- printsiginfo.c | 18 ++++++++++++++++++ process.c | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/printsiginfo.c b/printsiginfo.c index 240fd65e..596d958a 100644 --- a/printsiginfo.c +++ b/printsiginfo.c @@ -242,3 +242,21 @@ MPERS_PRINTER_DECL(void, printsiginfo_at)(struct tcb *tcp, long addr) if (!umove_or_printaddr(tcp, addr, &si)) printsiginfo(&si, verbose(tcp)); } + +static bool +print_siginfo_t(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) +{ + const siginfo_t *si = elem_buf; + + printsiginfo(si, verbose(tcp)); + + return true; +} + +MPERS_PRINTER_DECL(void, print_siginfo_array)(struct tcb *tcp, unsigned long addr, unsigned long len) +{ + siginfo_t si; + + print_array(tcp, addr, len, &si, sizeof(si), + umoven_or_printaddr, print_siginfo_t, 0); +} diff --git a/process.c b/process.c index 19b616d0..3aecf088 100644 --- a/process.c +++ b/process.c @@ -212,6 +212,7 @@ SYS_FUNC(ptrace) case PTRACE_GETREGSET: case PTRACE_GETSIGINFO: case PTRACE_GETSIGMASK: + case PTRACE_PEEKSIGINFO: case PTRACE_SECCOMP_GET_FILTER: if (verbose(tcp)) { /* print data on exiting syscall */ @@ -245,6 +246,12 @@ SYS_FUNC(ptrace) case PTRACE_GETSIGMASK: print_sigset_addr_len(tcp, data, addr); break; + case PTRACE_PEEKSIGINFO: + if (syserror(tcp)) + printaddr(data); + else + print_siginfo_array(tcp, data, tcp->u_rval); + break; case PTRACE_SECCOMP_GET_FILTER: if (syserror(tcp)) printaddr(data); -- 2.50.1