From 31601155c46c28694060e3f6d6709e42bc0b5be3 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sun, 12 Mar 2017 22:01:09 +0000 Subject: [PATCH] Implement proper decoding of rt_sigreturn syscall * rt_sigreturn.c: New file. * Makefile.am (strace_SOURCES): Add it. * linux/dummy.h (sys_rt_sigreturn): Remove. * linux/64/syscallent.h (rt_sigreturn): Change sys_func to rt_sigreturn. * linux/hppa/syscallent.h (rt_sigreturn): Likewise. * linux/ia64/syscallent.h (rt_sigreturn): Likewise. * linux/s390/syscallent.h (rt_sigreturn): Likewise. * linux/s390x/syscallent.h (rt_sigreturn): Likewise. * linux/x86_64/syscallent.h (rt_sigreturn): Likewise. * linux/x32/syscallent.h (rt_sigreturn, 64:rt_sigreturn): Likewise. * NEWS: Mention this change. --- Makefile.am | 1 + NEWS | 4 +++ linux/64/syscallent.h | 2 +- linux/dummy.h | 1 - linux/hppa/syscallent.h | 2 +- linux/ia64/syscallent.h | 2 +- linux/s390/syscallent.h | 2 +- linux/s390x/syscallent.h | 2 +- linux/x32/syscallent.h | 4 +-- linux/x86_64/syscallent.h | 2 +- rt_sigreturn.c | 54 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 rt_sigreturn.c diff --git a/Makefile.am b/Makefile.am index 31682d4d..e5a94474 100644 --- a/Makefile.am +++ b/Makefile.am @@ -210,6 +210,7 @@ strace_SOURCES = \ renameat.c \ resource.c \ rt_sigframe.c \ + rt_sigreturn.c \ rtc.c \ sched.c \ sched_attr.h \ diff --git a/NEWS b/NEWS index 77b66782..2a701c2a 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,10 @@ Noteworthy changes in release ?.?? (????-??-??) * Improvements * Enhanced decoding of sched_setattr syscall. * Added -e trace=%sched option for tracing sched_* syscalls. + * Implemented decoding of signal mask in rt_sigreturn syscall on alpha, arc, + arm, avr32, bfin, cris, hppa, m68k, metag, microblaze, mips, nios2, or1k, + powerpc, powerpc64, riscv, sh, sh64, sparc, sparc64, tile, x86, and xtensa + architectures. * Bug fixes * Fixed decoding of flags argument of preadv2 and pwritev2 syscalls on x32. diff --git a/linux/64/syscallent.h b/linux/64/syscallent.h index a705eae9..b5a09d4f 100644 --- a/linux/64/syscallent.h +++ b/linux/64/syscallent.h @@ -137,7 +137,7 @@ [136] = { 2, TS, SEN(rt_sigpending), "rt_sigpending" }, [137] = { 4, TS, SEN(rt_sigtimedwait), "rt_sigtimedwait" }, [138] = { 3, TS, SEN(rt_sigqueueinfo), "rt_sigqueueinfo" }, -[139] = { 0, TS, SEN(sigreturn), "rt_sigreturn" }, +[139] = { 0, TS, SEN(rt_sigreturn), "rt_sigreturn" }, [140] = { 3, 0, SEN(setpriority), "setpriority" }, [141] = { 2, 0, SEN(getpriority), "getpriority" }, [142] = { 4, 0, SEN(reboot), "reboot" }, diff --git a/linux/dummy.h b/linux/dummy.h index 2758cfb2..06fd3695 100644 --- a/linux/dummy.h +++ b/linux/dummy.h @@ -113,7 +113,6 @@ #define sys_munlockall printargs #define sys_pause printargs #define sys_printargs printargs -#define sys_rt_sigreturn printargs #define sys_sched_yield printargs #define sys_setsid printargs #define sys_set_tid_address printargs diff --git a/linux/hppa/syscallent.h b/linux/hppa/syscallent.h index 647a2dc5..f59ea571 100644 --- a/linux/hppa/syscallent.h +++ b/linux/hppa/syscallent.h @@ -175,7 +175,7 @@ [170] = { 3, 0, SEN(setresgid), "setresgid" }, [171] = { 3, 0, SEN(getresgid), "getresgid" }, [172] = { 5, 0, SEN(prctl), "prctl" }, -[173] = { 0, TS, SEN(sigreturn), "rt_sigreturn" }, +[173] = { 0, TS, SEN(rt_sigreturn), "rt_sigreturn" }, [174] = { 4, TS, SEN(rt_sigaction), "rt_sigaction" }, [175] = { 4, TS, SEN(rt_sigprocmask), "rt_sigprocmask" }, [176] = { 2, TS, SEN(rt_sigpending), "rt_sigpending" }, diff --git a/linux/ia64/syscallent.h b/linux/ia64/syscallent.h index 895e7aec..47b71d6a 100644 --- a/linux/ia64/syscallent.h +++ b/linux/ia64/syscallent.h @@ -198,7 +198,7 @@ [1178] = { 2, TS, SEN(rt_sigpending), "rt_sigpending" }, [1179] = { 4, TS, SEN(rt_sigprocmask), "rt_sigprocmask" }, [1180] = { 3, TS, SEN(rt_sigqueueinfo), "rt_sigqueueinfo" }, -[1181] = { 0, TS, SEN(sigreturn), "rt_sigreturn" }, +[1181] = { 0, TS, SEN(rt_sigreturn), "rt_sigreturn" }, [1182] = { 2, TS, SEN(rt_sigsuspend), "rt_sigsuspend" }, [1183] = { 4, TS, SEN(rt_sigtimedwait), "rt_sigtimedwait" }, [1184] = { 2, TF, SEN(getcwd), "getcwd" }, diff --git a/linux/s390/syscallent.h b/linux/s390/syscallent.h index c04353cc..105e511e 100644 --- a/linux/s390/syscallent.h +++ b/linux/s390/syscallent.h @@ -201,7 +201,7 @@ [170] = { 3, 0, SEN(setresgid16), "setresgid" }, [171] = { 3, 0, SEN(getresgid16), "getresgid" }, [172] = { 5, 0, SEN(prctl), "prctl" }, -[173] = { 0, TS, SEN(sigreturn), "rt_sigreturn" }, +[173] = { 0, TS, SEN(rt_sigreturn), "rt_sigreturn" }, [174] = { 4, TS, SEN(rt_sigaction), "rt_sigaction" }, [175] = { 4, TS, SEN(rt_sigprocmask), "rt_sigprocmask" }, [176] = { 2, TS, SEN(rt_sigpending), "rt_sigpending" }, diff --git a/linux/s390x/syscallent.h b/linux/s390x/syscallent.h index ab8a5d86..d5b54590 100644 --- a/linux/s390x/syscallent.h +++ b/linux/s390x/syscallent.h @@ -190,7 +190,7 @@ [169] = { 3, 0, SEN(nfsservctl), "nfsservctl" }, [170 ... 171] = { }, [172] = { 5, 0, SEN(prctl), "prctl" }, -[173] = { 0, TS, SEN(sigreturn), "rt_sigreturn" }, +[173] = { 0, TS, SEN(rt_sigreturn), "rt_sigreturn" }, [174] = { 4, TS, SEN(rt_sigaction), "rt_sigaction" }, [175] = { 4, TS, SEN(rt_sigprocmask), "rt_sigprocmask" }, [176] = { 2, TS, SEN(rt_sigpending), "rt_sigpending" }, diff --git a/linux/x32/syscallent.h b/linux/x32/syscallent.h index 2699bc04..30a684a8 100644 --- a/linux/x32/syscallent.h +++ b/linux/x32/syscallent.h @@ -13,7 +13,7 @@ [ 12] = { 1, TM|SI, SEN(brk), "brk" }, [ 13] = { 4, TS, SEN(printargs), "64:rt_sigaction" }, [ 14] = { 4, TS, SEN(rt_sigprocmask), "rt_sigprocmask" }, -[ 15] = { 0, TS, SEN(printargs), "64:rt_sigreturn" }, +[ 15] = { 0, TS, SEN(rt_sigreturn), "64:rt_sigreturn" }, [ 16] = { 3, TD, SEN(printargs), "64:ioctl" }, [ 17] = { 4, TD, SEN(pread), "pread64" }, [ 18] = { 4, TD, SEN(pwrite), "pwrite64" }, @@ -336,7 +336,7 @@ * for native 64-bit operation. */ [512] = { 4, CST|TS, SEN(rt_sigaction), "rt_sigaction" }, -[513] = { 0, CST|TS, SEN(sigreturn), "rt_sigreturn" }, +[513] = { 0, CST|TS, SEN(rt_sigreturn), "rt_sigreturn" }, [514] = { 3, CST|TD, SEN(ioctl), "ioctl" }, [515] = { 3, CST|TD, SEN(readv), "readv" }, [516] = { 3, CST|TD, SEN(writev), "writev" }, diff --git a/linux/x86_64/syscallent.h b/linux/x86_64/syscallent.h index a1a268ec..62960d21 100644 --- a/linux/x86_64/syscallent.h +++ b/linux/x86_64/syscallent.h @@ -13,7 +13,7 @@ [ 12] = { 1, TM|SI, SEN(brk), "brk" }, [ 13] = { 4, TS, SEN(rt_sigaction), "rt_sigaction" }, [ 14] = { 4, TS, SEN(rt_sigprocmask), "rt_sigprocmask" }, -[ 15] = { 0, TS, SEN(sigreturn), "rt_sigreturn" }, +[ 15] = { 0, TS, SEN(rt_sigreturn), "rt_sigreturn" }, [ 16] = { 3, TD, SEN(ioctl), "ioctl" }, [ 17] = { 4, TD, SEN(pread), "pread64" }, [ 18] = { 4, TD, SEN(pwrite), "pwrite64" }, diff --git a/rt_sigreturn.c b/rt_sigreturn.c new file mode 100644 index 00000000..af705c37 --- /dev/null +++ b/rt_sigreturn.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Dmitry V. Levin + * 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(struct_rt_sigframe) + +#include "rt_sigframe.h" + +#include MPERS_DEFS + +#ifndef OFFSETOF_SIGMASK_IN_RT_SIGFRAME +# define OFFSETOF_SIGMASK_IN_RT_SIGFRAME \ + offsetof(struct_rt_sigframe, uc.uc_sigmask) +#endif + +SYS_FUNC(rt_sigreturn) +{ + const kernel_ulong_t sf_addr = get_rt_sigframe_addr(tcp); + + if (sf_addr) { + const kernel_ulong_t sm_addr = + sf_addr + OFFSETOF_SIGMASK_IN_RT_SIGFRAME; + tprints("{mask="); + print_sigset_addr(tcp, sm_addr); + tprints("}"); + } + + return RVAL_DECODED; +} -- 2.40.0