linux/64/syscallent.h \
linux/aarch64/arch_defs_.h \
linux/aarch64/arch_regs.c \
- linux/aarch64/arch_regs.h \
- linux/aarch64/arch_rt_sigframe.c \
linux/aarch64/arch_sigreturn.c \
linux/aarch64/get_error.c \
linux/aarch64/get_scno.c \
linux/alpha/arch_defs_.h \
linux/alpha/arch_getrval2.c \
linux/alpha/arch_regs.c \
- linux/alpha/arch_regs.h \
- linux/alpha/arch_rt_sigframe.c \
linux/alpha/arch_sigreturn.c \
linux/alpha/errnoent.h \
linux/alpha/get_error.c \
linux/alpha/syscallent.h \
linux/alpha/userent.h \
linux/arc/arch_regs.c \
- linux/arc/arch_regs.h \
- linux/arc/arch_rt_sigframe.c \
linux/arc/get_error.c \
linux/arc/get_scno.c \
linux/arc/get_syscall_args.c \
linux/arch_defs_.h \
linux/arch_kvm.c \
linux/arch_regs.h \
+ linux/arch_rt_sigframe.c \
linux/arch_sigreturn.c \
linux/arm/arch_defs_.h \
linux/arm/arch_regs.c \
- linux/arm/arch_regs.h \
- linux/arm/arch_rt_sigframe.c \
linux/arm/arch_sigreturn.c \
linux/arm/get_error.c \
linux/arm/get_scno.c \
linux/arm/syscallent.h \
linux/arm/userent.h \
linux/avr32/arch_regs.c \
- linux/avr32/arch_regs.h \
- linux/avr32/arch_rt_sigframe.c \
linux/avr32/get_error.c \
linux/avr32/get_scno.c \
linux/avr32/get_syscall_args.c \
linux/avr32/userent.h \
linux/bfin/arch_defs_.h \
linux/bfin/arch_regs.c \
- linux/bfin/arch_rt_sigframe.c \
linux/bfin/get_error.c \
linux/bfin/get_scno.c \
linux/bfin/get_syscall_args.c \
linux/getregs_old.h \
linux/hppa/arch_defs_.h \
linux/hppa/arch_regs.c \
- linux/hppa/arch_regs.h \
linux/hppa/arch_rt_sigframe.c \
linux/hppa/errnoent.h \
linux/hppa/get_error.c \
linux/i386/arch_kvm.c \
linux/i386/arch_defs_.h \
linux/i386/arch_regs.c \
- linux/i386/arch_regs.h \
linux/i386/arch_rt_sigframe.c \
linux/i386/arch_sigreturn.c \
linux/i386/get_error.c \
linux/inet_diag.h \
linux/m68k/arch_defs_.h \
linux/m68k/arch_regs.c \
- linux/m68k/arch_regs.h \
linux/m68k/arch_rt_sigframe.c \
linux/m68k/arch_sigreturn.c \
linux/m68k/get_error.c \
linux/m68k/syscallent.h \
linux/m68k/userent.h \
linux/metag/arch_regs.c \
- linux/metag/arch_regs.h \
linux/metag/arch_rt_sigframe.c \
linux/metag/get_error.c \
linux/metag/get_scno.c \
linux/metag/syscallent.h \
linux/microblaze/arch_defs_.h \
linux/microblaze/arch_regs.c \
- linux/microblaze/arch_rt_sigframe.c \
linux/microblaze/arch_sigreturn.c \
linux/microblaze/get_error.c \
linux/microblaze/get_scno.c \
linux/mips/arch_defs_.h \
linux/mips/arch_getrval2.c \
linux/mips/arch_regs.c \
- linux/mips/arch_regs.h \
- linux/mips/arch_rt_sigframe.c \
linux/mips/arch_sigreturn.c \
linux/mips/errnoent.h \
linux/mips/genstub.sh \
linux/netlink_diag.h \
linux/nios2/arch_defs_.h \
linux/nios2/arch_regs.c \
- linux/nios2/arch_regs.h \
- linux/nios2/arch_rt_sigframe.c \
linux/nios2/get_error.c \
linux/nios2/get_scno.c \
linux/nios2/get_syscall_args.c \
linux/nios2/syscallent.h \
linux/nr_prefix.c \
linux/or1k/arch_regs.c \
- linux/or1k/arch_regs.h \
- linux/or1k/arch_rt_sigframe.c \
linux/or1k/get_error.c \
linux/or1k/get_scno.c \
linux/or1k/get_syscall_args.c \
linux/packet_diag.h \
linux/powerpc/arch_defs_.h \
linux/powerpc/arch_regs.c \
- linux/powerpc/arch_regs.h \
linux/powerpc/arch_rt_sigframe.c \
linux/powerpc/arch_sigreturn.c \
linux/powerpc/errnoent.h \
linux/powerpc/userent.h \
linux/powerpc64/arch_defs_.h \
linux/powerpc64/arch_regs.c \
- linux/powerpc64/arch_regs.h \
linux/powerpc64/arch_rt_sigframe.c \
linux/powerpc64/arch_sigreturn.c \
linux/powerpc64/errnoent.h \
linux/raw_syscall.h \
linux/riscv/arch_defs_.h \
linux/riscv/arch_regs.c \
- linux/riscv/arch_regs.h \
- linux/riscv/arch_rt_sigframe.c \
linux/riscv/get_error.c \
linux/riscv/get_scno.c \
linux/riscv/get_syscall_args.c \
linux/rt_sigframe.h \
linux/s390/arch_defs_.h \
linux/s390/arch_regs.c \
- linux/s390/arch_regs.h \
- linux/s390/arch_rt_sigframe.c \
linux/s390/arch_sigreturn.c \
linux/s390/get_error.c \
linux/s390/get_scno.c \
linux/s390/userent1.h \
linux/s390x/arch_defs_.h \
linux/s390x/arch_regs.c \
- linux/s390x/arch_regs.h \
- linux/s390x/arch_rt_sigframe.c \
linux/s390x/arch_sigreturn.c \
linux/s390x/get_error.c \
linux/s390x/get_scno.c \
linux/sh/arch_defs_.h \
linux/sh/arch_getrval2.c \
linux/sh/arch_regs.c \
- linux/sh/arch_rt_sigframe.c \
linux/sh/get_error.c \
linux/sh/get_scno.c \
linux/sh/get_syscall_args.c \
linux/sh64/arch_defs_.h \
linux/sh64/arch_regs.c \
linux/sh64/arch_regs.h \
- linux/sh64/arch_rt_sigframe.c \
linux/sh64/get_error.c \
linux/sh64/get_scno.c \
linux/sh64/get_syscall_args.c \
linux/sparc/arch_defs_.h \
linux/sparc/arch_getrval2.c \
linux/sparc/arch_regs.c \
- linux/sparc/arch_regs.h \
- linux/sparc/arch_rt_sigframe.c \
linux/sparc/arch_sigreturn.c \
linux/sparc/errnoent.h \
linux/sparc/get_error.c \
linux/sparc64/arch_defs_.h \
linux/sparc64/arch_getrval2.c \
linux/sparc64/arch_regs.c \
- linux/sparc64/arch_regs.h \
linux/sparc64/arch_rt_sigframe.c \
linux/sparc64/arch_sigreturn.c \
linux/sparc64/errnoent.h \
linux/syscall.h \
linux/tile/arch_defs_.h \
linux/tile/arch_regs.c \
- linux/tile/arch_regs.h \
- linux/tile/arch_rt_sigframe.c \
linux/tile/arch_sigreturn.c \
linux/tile/get_error.c \
linux/tile/get_scno.c \
linux/x86_64/syscallent2.h \
linux/x86_64/userent.h \
linux/xtensa/arch_regs.c \
- linux/xtensa/arch_rt_sigframe.c \
linux/xtensa/get_error.c \
linux/xtensa/get_scno.c \
linux/xtensa/get_syscall_args.c \
extern void set_overhead(int);
extern bool get_instruction_pointer(struct tcb *, kernel_ulong_t *);
+extern bool get_stack_pointer(struct tcb *, kernel_ulong_t *);
extern void print_instruction_pointer(struct tcb *);
extern int syscall_entering_decode(struct tcb *);
#define aarch64_regs arm_regs_union.aarch64_r
#define arm_regs arm_regs_union.arm_r
-uint64_t *const aarch64_sp_ptr = (uint64_t *) &aarch64_regs.sp;
-uint32_t *const arm_sp_ptr = &arm_regs.ARM_sp;
static struct iovec aarch64_io = {
.iov_base = &arm_regs_union
};
#define ARCH_REGS_FOR_GETREGSET arm_regs_union
#define ARCH_IOVEC_FOR_GETREGSET aarch64_io
-#define ARCH_PC_REG ((aarch64_io.iov_len == sizeof(arm_regs)) ? arm_regs.ARM_pc : aarch64_regs.pc)
+#define ARCH_PC_REG \
+ ((aarch64_io.iov_len == sizeof(arm_regs)) ? arm_regs.ARM_pc : aarch64_regs.pc)
+#define ARCH_SP_REG \
+ ((aarch64_io.iov_len == sizeof(arm_regs)) ? arm_regs.ARM_sp : aarch64_regs.sp)
#define ARCH_PERSONALITY_0_IOV_SIZE sizeof(aarch64_regs)
#define ARCH_PERSONALITY_1_IOV_SIZE sizeof(arm_regs)
+++ /dev/null
-extern uint64_t *const aarch64_sp_ptr;
-extern uint32_t *const arm_sp_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define FUNC_GET_RT_SIGFRAME_ADDR \
- static kernel_ulong_t arm_get_rt_sigframe_addr(struct tcb *tcp)
-
-#include "arm/arch_rt_sigframe.c"
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define FUNC_GET_RT_SIGFRAME_ADDR DEF_FUNC_GET_RT_SIGFRAME_ADDR
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return tcp->currpers == 1 ? arm_get_rt_sigframe_addr(tcp)
- : *aarch64_sp_ptr;
-}
static unsigned long alpha_r0;
static unsigned long alpha_a3;
+
+#define REG_R0 0
+#define REG_A0 16
+#define REG_A3 19
+#define REG_SP 30
+#define REG_PC 64
+
#define ARCH_PC_PEEK_ADDR REG_PC
+#define ARCH_SP_PEEK_ADDR REG_SP
+++ /dev/null
-#define REG_R0 0
-#define REG_A0 16
-#define REG_A3 19
-#define REG_FP 30
-#define REG_PC 64
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- unsigned long addr;
-
- return upeek(tcp, REG_FP, &addr) ? 0 : addr;
-}
{
unsigned long addr;
- if (upeek(tcp, REG_FP, &addr) < 0)
+ if (!get_stack_pointer(tcp, &addr))
return;
addr += offsetof(struct sigcontext, sc_mask);
static struct user_regs_struct arc_regs;
-unsigned long *const arc_sp_ptr = &arc_regs.scratch.sp;
#define ARCH_REGS_FOR_GETREGSET arc_regs
#define ARCH_PC_REG arc_regs.efa
+#define ARCH_SP_REG arc_regs.scratch.sp
+++ /dev/null
-extern unsigned long *const arc_sp_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *arc_sp_ptr;
-}
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/* This is a generic definition for compatible architectures. */
+
FUNC_GET_RT_SIGFRAME_ADDR
{
- unsigned long addr;
-
- return upeek(tcp, PT_USP, &addr) ? 0 : addr;
+ kernel_ulong_t sp;
+ return get_stack_pointer(tcp, &sp) ? sp : 0;
}
static struct pt_regs arm_regs;
-unsigned long *const arm_sp_ptr = (unsigned long *) &arm_regs.ARM_sp;
#define ARCH_REGS_FOR_GETREGS arm_regs
#define ARCH_PC_REG arm_regs.ARM_pc
+#define ARCH_SP_REG arm_regs.ARM_sp
+++ /dev/null
-extern unsigned long *const arm_sp_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *arm_sp_ptr;
-}
static void
arch_sigreturn(struct tcb *tcp)
{
+ kernel_ulong_t sp;
+ if (!get_stack_pointer(tcp, &sp))
+ return;
+
#define SIZEOF_STRUCT_SIGINFO 128
#define SIZEOF_STRUCT_SIGCONTEXT (21 * 4)
#define OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK (5 * 4 + SIZEOF_STRUCT_SIGCONTEXT)
- const unsigned long addr =
+ const kernel_ulong_t addr =
#ifdef AARCH64
tcp->currpers == 0 ?
- (*aarch64_sp_ptr + SIZEOF_STRUCT_SIGINFO +
+ (sp + SIZEOF_STRUCT_SIGINFO +
offsetof(ucontext_t, uc_sigmask)) :
#endif
- (*arm_sp_ptr +
- OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK);
+ (sp + OFFSETOF_STRUCT_UCONTEXT_UC_SIGMASK);
tprints("{mask=");
print_sigset_addr(tcp, addr);
tprints("}");
static struct pt_regs avr32_regs;
-unsigned long *const avr32_sp_ptr = &avr32_regs.sp;
#define ARCH_REGS_FOR_GETREGS avr32_regs
#define ARCH_PC_REG avr32_regs.pc
+#define ARCH_SP_REG avr32_regs.sp
+++ /dev/null
-extern unsigned long *const avr32_sp_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *avr32_sp_ptr;
-}
static unsigned long bfin_r0;
#define ARCH_PC_PEEK_ADDR PT_PC
+#define ARCH_SP_PEEK_ADDR PT_USP
static unsigned long hppa_r28;
+
+#define PT_GR20 (20*4)
+#define PT_GR26 (26*4)
+#define PT_GR28 (28*4)
+#define PT_GR30 (30*4)
+#define PT_IAOQ0 (106*4)
+#define PT_IAOQ1 (107*4)
+
#define ARCH_PC_PEEK_ADDR PT_IAOQ0
+#define ARCH_SP_PEEK_ADDR PT_GR30
+++ /dev/null
-#define PT_GR20 (20*4)
-#define PT_GR26 (26*4)
-#define PT_GR28 (28*4)
-#define PT_IAOQ0 (106*4)
-#define PT_IAOQ1 (107*4)
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
{
unsigned long addr;
- return upeek(tcp, 4 * 30, &addr)
- ? 0 : (addr & ~1UL) - RT_SIGFRAME_SIZE;
+ return get_stack_pointer(tcp, &addr)
+ ? (addr & ~1UL) - RT_SIGFRAME_SIZE : 0;
}
static struct user_regs_struct i386_regs;
-unsigned long *const i386_esp_ptr = (unsigned long *) &i386_regs.esp;
#define ARCH_REGS_FOR_GETREGS i386_regs
#define ARCH_PC_REG i386_regs.eip
+#define ARCH_SP_REG i386_regs.esp
+++ /dev/null
-extern unsigned long *const i386_esp_ptr;
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
FUNC_GET_RT_SIGFRAME_ADDR
{
- return *i386_esp_ptr - 4;
+ kernel_ulong_t sp;
+ return get_stack_pointer(tcp, &sp) ? sp - current_klongsize : 0;
}
uint32_t struct_fpstate_padding[156];
uint32_t extramask;
} frame;
+ kernel_ulong_t sp;
- if (umove(tcp, *i386_esp_ptr, &frame) < 0) {
- tprintf("{mask=%#lx}", (unsigned long) *i386_esp_ptr);
- } else {
+ if (get_stack_pointer(tcp, &sp) &&
+ !umove_or_printaddr(tcp, sp, &frame)) {
uint32_t mask[2] = { frame.oldmask, frame.extramask };
tprintsigmask_addr("{mask=", mask);
tprints("}");
static struct pt_all_user_regs ia64_regs;
-unsigned long *const ia64_frame_ptr = &ia64_regs.gr[12];
#define ARCH_REGS_FOR_GETREGS ia64_regs
#define ARCH_PC_REG ia64_regs.br[0]
+#define ARCH_SP_REG ia64_regs.gr[12]
#include <asm/ptrace_offsets.h>
-extern unsigned long *const ia64_frame_ptr;
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
FUNC_GET_RT_SIGFRAME_ADDR
{
- return *ia64_frame_ptr + 16;
+ kernel_ulong_t sp;
+ return get_stack_pointer(tcp, &sp) ? sp + 16 : 0;
}
static struct user_regs_struct m68k_regs;
-unsigned long *const m68k_usp_ptr = (unsigned long *) &m68k_regs.usp;
-#define ARCH_PC_REG m68k_regs.pc
#define ARCH_REGS_FOR_GETREGS m68k_regs
+#define ARCH_PC_REG m68k_regs.pc
+#define ARCH_SP_REG m68k_regs.usp
+++ /dev/null
-extern unsigned long *const m68k_usp_ptr;
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *m68k_usp_ptr - 4;
-}
+#include "i386/arch_rt_sigframe.c"
static void
arch_sigreturn(struct tcb *tcp)
{
- unsigned long addr;
+ unsigned long addr, sp;
/* Fetch pointer to struct sigcontext. */
- if (umove(tcp, *m68k_usp_ptr + 2 * sizeof(int), &addr) < 0)
+ if (!get_stack_pointer(tcp, &sp) ||
+ umove_or_printaddr(tcp, sp + 2 * sizeof(int), &addr))
return;
unsigned long mask[NSIG_BYTES / sizeof(long)];
/* Fetch first word of signal mask. */
- if (umove(tcp, addr, &mask[0]) < 0)
+ if (umove_or_printaddr(tcp, addr, &mask[0]))
return;
/* Fetch remaining words of signal mask, located immediately before. */
addr -= sizeof(mask) - sizeof(long);
- if (umoven(tcp, addr, sizeof(mask) - sizeof(long), &mask[1]) < 0)
+ if (umoven_or_printaddr(tcp, addr, sizeof(mask) - sizeof(long), &mask[1]))
return;
tprintsigmask_addr("{mask=", mask);
static struct user_gp_regs metag_regs;
-unsigned long *const metag_sp_ptr = &metag_regs.ax[0][0];
#define ARCH_REGS_FOR_GETREGSET metag_regs
#define ARCH_PC_REG metag_regs.pc
+#define ARCH_SP_REG metag_regs.ax[0][0]
+++ /dev/null
-extern unsigned long *const metag_sp_ptr;
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
FUNC_GET_RT_SIGFRAME_ADDR
{
- return *metag_sp_ptr - sizeof(struct_rt_sigframe);
+ kernel_ulong_t sp;
+ return get_stack_pointer(tcp, &sp)
+ ? sp - sizeof(struct_rt_sigframe) : 0;
}
static unsigned long microblaze_r3;
#define ARCH_PC_PEEK_ADDR PT_PC
+#define ARCH_SP_PEEK_ADDR PT_GPR(1)
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- unsigned long addr;
-
- return upeek(tcp, 4 * 1, &addr) ? 0 : addr;
-}
-struct mips_regs mips_regs; /* not static */
+static struct {
+ uint64_t uregs[38];
+} mips_regs;
+
+#define REG_V0 2
+#define REG_A0 4
+
+#define mips_REG_V0 mips_regs.uregs[REG_V0]
+#define mips_REG_A0 mips_regs.uregs[REG_A0 + 0]
+#define mips_REG_A1 mips_regs.uregs[REG_A0 + 1]
+#define mips_REG_A2 mips_regs.uregs[REG_A0 + 2]
+#define mips_REG_A3 mips_regs.uregs[REG_A0 + 3]
+#define mips_REG_A4 mips_regs.uregs[REG_A0 + 4]
+#define mips_REG_A5 mips_regs.uregs[REG_A0 + 5]
+#define mips_REG_SP mips_regs.uregs[29]
+#define mips_REG_EPC mips_regs.uregs[34]
+
/* PTRACE_GETREGS on MIPS is available since linux v2.6.15. */
#define ARCH_REGS_FOR_GETREGS mips_regs
#define ARCH_PC_REG mips_REG_EPC
+#define ARCH_SP_REG mips_REG_SP
+++ /dev/null
-struct mips_regs {
- uint64_t uregs[38];
-};
-
-extern struct mips_regs mips_regs;
-
-#define REG_V0 2
-#define REG_A0 4
-
-#define mips_REG_V0 mips_regs.uregs[REG_V0]
-#define mips_REG_A0 mips_regs.uregs[REG_A0 + 0]
-#define mips_REG_A1 mips_regs.uregs[REG_A0 + 1]
-#define mips_REG_A2 mips_regs.uregs[REG_A0 + 2]
-#define mips_REG_A3 mips_regs.uregs[REG_A0 + 3]
-#define mips_REG_A4 mips_regs.uregs[REG_A0 + 4]
-#define mips_REG_A5 mips_regs.uregs[REG_A0 + 5]
-#define mips_REG_SP mips_regs.uregs[29]
-#define mips_REG_EPC mips_regs.uregs[34]
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return mips_REG_SP;
-}
{
/* 64-bit ABIs do not have old sigreturn. */
#ifdef LINUX_MIPSO32
+ kernel_ulong_t addr;
+ if (!get_stack_pointer(tcp, &addr))
+ return;
/*
* offsetof(struct sigframe, sf_mask) ==
* sizeof(sf_ass) + sizeof(sf_pad) + sizeof(struct sigcontext)
*/
- const kernel_ulong_t addr = mips_REG_SP + 6 * 4 +
- sizeof(struct sigcontext);
+ addr += 6 * 4 + sizeof(struct sigcontext);
tprints("{mask=");
print_sigset_addr(tcp, addr);
static struct user_pt_regs nios2_regs;
-unsigned int *const nios2_sp_ptr = &nios2_regs.regs[PTR_SP];
# define ARCH_REGS_FOR_GETREGSET nios2_regs
#define ARCH_PC_REG nios2_regs.regs[PTR_EA]
+#define ARCH_SP_REG nios2_regs.regs[PTR_SP]
+++ /dev/null
-extern unsigned int *const nios2_sp_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *nios2_sp_ptr;
-}
static struct user_regs_struct or1k_regs;
-unsigned long *const or1k_sp_ptr = &or1k_regs.gpr[1];
#define ARCH_REGS_FOR_GETREGSET or1k_regs
#define ARCH_PC_REG or1k_regs.pc
+#define ARCH_SP_REG or1k_regs.gpr[1]
+++ /dev/null
-extern unsigned long *const or1k_sp_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *or1k_sp_ptr;
-}
-struct pt_regs ppc_regs; /* not static */
+static struct pt_regs ppc_regs;
#define ARCH_REGS_FOR_GETREGS ppc_regs
#define ARCH_PC_REG ppc_regs.nip
+#define ARCH_SP_REG ppc_regs.gpr[1]
+++ /dev/null
-extern struct pt_regs ppc_regs;
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
FUNC_GET_RT_SIGFRAME_ADDR
{
- return ppc_regs.gpr[1] + SIGNAL_FRAMESIZE32 + 16;
+ kernel_ulong_t sp;
+ return get_stack_pointer(tcp, &sp) ? sp + SIGNAL_FRAMESIZE32 + 16 : 0;
}
static void
arch_sigreturn(struct tcb *tcp)
{
+ kernel_ulong_t addr;
+ if (!get_stack_pointer(tcp, &addr))
+ return;
+
/* Skip dummy stack frame. */
- const unsigned long addr = ppc_regs.gpr[1] + 64;
+ addr += 64;
#ifdef POWERPC64
/* The only sigreturn on ppc64 is compat_sys_sigreturn. */
sigreturn_context sc;
- if (umove(tcp, addr, &sc) < 0) {
- tprintf("{mask=%#lx}", addr);
- } else {
+ if (!umove_or_printaddr(tcp, addr, &sc)) {
const unsigned int mask[NSIG_BYTES / sizeof(int)] = {
sc.oldmask,
sc._unused[3]
+++ /dev/null
-#include "powerpc/arch_regs.h"
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
FUNC_GET_RT_SIGFRAME_ADDR
{
- return tcp->currpers == 1
- ? ppc_get_rt_sigframe_addr(tcp) : ppc_regs.gpr[1];
+ if (tcp->currpers == 1)
+ return ppc_get_rt_sigframe_addr(tcp);
+ kernel_ulong_t sp;
+ return get_stack_pointer(tcp, &sp) ? sp : 0;
}
static struct user_regs_struct riscv_regs;
-unsigned long *const riscv_sp_ptr = &riscv_regs.sp;
#define ARCH_REGS_FOR_GETREGSET riscv_regs
#define ARCH_PC_REG riscv_regs.pc
+#define ARCH_SP_REG riscv_regs.sp
+++ /dev/null
-extern unsigned long *const riscv_sp_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *riscv_sp_ptr;
-}
/* PTRACE_GETREGSET on S390 is available since linux v2.6.27. */
static struct user_regs_struct s390_regset;
-unsigned long *const s390_frame_ptr = &s390_regset.gprs[15];
#define ARCH_REGS_FOR_GETREGSET s390_regset
#define ARCH_PC_REG s390_regset.psw.addr
+#define ARCH_SP_REG s390_regset.gprs[15]
+++ /dev/null
-extern unsigned long *const s390_frame_ptr;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return *s390_frame_ptr;
-}
-#ifndef S390_FRAME_PTR
-# define S390_FRAME_PTR s390_frame_ptr
-#endif
#ifndef SIGNAL_FRAMESIZE
# define SIGNAL_FRAMESIZE __SIGNAL_FRAMESIZE
#endif
static void
arch_sigreturn(struct tcb *tcp)
{
- PTR_TYPE mask[NSIG_BYTES / sizeof(PTR_TYPE)];
- const PTR_TYPE addr = *S390_FRAME_PTR + SIGNAL_FRAMESIZE;
+ kernel_ulong_t addr;
- if (umove(tcp, addr, &mask) < 0) {
- tprintf("{mask=%#llx}", zero_extend_signed_to_ull(addr));
- } else {
+ if (!get_stack_pointer(tcp, &addr))
+ return;
+ addr += SIGNAL_FRAMESIZE;
+
+ PTR_TYPE mask[NSIG_BYTES / sizeof(PTR_TYPE)];
+ if (!umove_or_printaddr(tcp, addr, &mask)) {
tprintsigmask_addr("{mask=", mask);
tprints("}");
}
#define s390_regset s390x_regs_union.s390_regs
#define s390x_regset s390x_regs_union.s390x_regs
-uint32_t *const s390_frame_ptr = &s390_regset.gprs[15];
-unsigned long *const s390x_frame_ptr = &s390x_regset.gprs[15];
-
static struct iovec s390x_io = {
.iov_base = &s390x_regs_union,
};
#define ARCH_PC_REG \
(s390x_io.iov_len == sizeof(s390_regset) ? \
s390_regset.psw.addr : s390x_regset.psw.addr)
+#define ARCH_SP_REG \
+ (s390x_io.iov_len == sizeof(s390_regset) ? \
+ s390_regset.gprs[15] : s390x_regset.gprs[15])
#define ARCH_PERSONALITY_0_IOV_SIZE sizeof(s390x_regset)
#define ARCH_PERSONALITY_1_IOV_SIZE sizeof(s390_regset)
+++ /dev/null
-extern uint32_t *const s390_frame_ptr;
-extern unsigned long *const s390x_frame_ptr;
+++ /dev/null
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return tcp->currpers == 1 ? *s390_frame_ptr : *s390x_frame_ptr;
-}
#define SIGNAL_FRAMESIZE S390_SIGNAL_FRAMESIZE
#define PTR_TYPE uint32_t
-#define S390_FRAME_PTR s390_frame_ptr
#define arch_sigreturn s390_arch_sigreturn
#include "s390/arch_sigreturn.c"
#undef arch_sigreturn
-#undef S390_FRAME_PTR
#undef PTR_TYPE
#undef SIGNAL_FRAMESIZE
-#define S390_FRAME_PTR s390x_frame_ptr
#define arch_sigreturn s390x_arch_sigreturn
#include "s390/arch_sigreturn.c"
#undef arch_sigreturn
static unsigned long sh_r0;
#define ARCH_PC_PEEK_ADDR (4 * REG_PC)
+#define ARCH_SP_PEEK_ADDR (4 * 15)
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- unsigned long addr;
-
- return upeek(tcp, sizeof(long) * 15, &addr) ? 0 : addr;
-}
static unsigned long sh64_r9;
#define ARCH_PC_PEEK_ADDR REG_PC
+#define ARCH_SP_PEEK_ADDR REG_GENERAL(15)
+++ /dev/null
-#include "sh/arch_rt_sigframe.c"
-struct pt_regs sparc_regs; /* not static */
+static struct pt_regs sparc_regs;
+
+/* Indexes into the pt_regs.u_reg[] array -- UREG_XX from kernel are all off
+ * by 1 and use Ix instead of Ox. These work for both 32 and 64 bit Linux. */
+#define U_REG_G1 0
+#define U_REG_O0 7
+#define U_REG_O1 8
+#define U_REG_FP 13
+
#define ARCH_REGS_FOR_GETREGS sparc_regs
#define ARCH_PC_REG sparc_regs.pc
+#define ARCH_SP_REG sparc_regs.u_regs[U_REG_FP]
+++ /dev/null
-extern struct pt_regs sparc_regs;
-/* Indexes into the pt_regs.u_reg[] array -- UREG_XX from kernel are all off
- * by 1 and use Ix instead of Ox. These work for both 32 and 64 bit Linux. */
-#define U_REG_G1 0
-#define U_REG_O0 7
-#define U_REG_O1 8
-#define U_REG_FP 13
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return sparc_regs.u_regs[U_REG_FP];
-}
static void
arch_sigreturn(struct tcb *tcp)
{
- unsigned long addr = sparc_regs.u_regs[U_REG_FP] +
- SIZEOF_STRUCT_SPARC_STACKF + SIZEOF_STRUCT_PT_REGS;
+ kernel_ulong_t addr;
+ if (!get_stack_pointer(tcp, &addr))
+ return;
+ addr += SIZEOF_STRUCT_SPARC_STACKF + SIZEOF_STRUCT_PT_REGS;
struct {
unsigned int mask;
char fpu_save[PERSONALITY_WORDSIZE];
unsigned int extramask[NSIG_BYTES / sizeof(int) - 1];
} frame;
- if (umove(tcp, addr, &frame) < 0) {
- tprintf("{mask=%#lx}", addr);
- } else {
+ if (!umove_or_printaddr(tcp, addr, &frame)) {
unsigned int mask[NSIG_BYTES / sizeof(int)];
mask[0] = frame.mask;
+++ /dev/null
-#include "sparc/arch_regs.h"
/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2017-2018 Dmitry V. Levin <ldv@altlinux.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
FUNC_GET_RT_SIGFRAME_ADDR
{
- return tcp->currpers == 1 ? sparc_regs.u_regs[U_REG_FP] & 0xffffffffUL
- : sparc_regs.u_regs[U_REG_FP] + STACK_BIAS;
+ kernel_ulong_t sp;
+ if (!get_stack_pointer(tcp, &sp))
+ return 0;
+ return tcp->currpers == 1 ? sp & 0xffffffffUL
+ : sp + STACK_BIAS;
}
-struct pt_regs tile_regs; /* not static */
+static struct pt_regs tile_regs;
#define ARCH_REGS_FOR_GETREGS tile_regs
#define ARCH_PC_REG tile_regs.pc
+#define ARCH_SP_REG tile_regs.sp
+++ /dev/null
-extern struct pt_regs tile_regs;
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return tile_regs.sp;
-}
static void
arch_sigreturn(struct tcb *tcp)
{
+ kernel_ulong_t addr;
+ if (!get_stack_pointer(tcp, &addr))
+ return;
+
/* offset of ucontext in the kernel's sigframe structure */
#define SIGFRAME_UC_OFFSET C_ABI_SAVE_AREA_SIZE + sizeof(siginfo_t)
- const unsigned long addr = tile_regs.sp + SIGFRAME_UC_OFFSET +
- offsetof(ucontext_t, uc_sigmask);
+ addr += SIGFRAME_UC_OFFSET + offsetof(ucontext_t, uc_sigmask);
tprints("{mask=");
print_sigset_addr(tcp, addr);
#define x86_64_regs x86_regs_union.x86_64_r
#define i386_regs x86_regs_union.i386_r
-uint32_t *const i386_esp_ptr = &i386_regs.esp;
-uint64_t *const x86_64_rsp_ptr = (uint64_t *) &x86_64_regs.rsp;
static struct iovec x86_io = {
.iov_base = &x86_regs_union
};
#define ARCH_REGS_FOR_GETREGSET x86_regs_union
#define ARCH_IOVEC_FOR_GETREGSET x86_io
-#define ARCH_PC_REG (x86_io.iov_len == sizeof(i386_regs) ? i386_regs.eip : x86_64_regs.rip)
+#define ARCH_PC_REG \
+ (x86_io.iov_len == sizeof(i386_regs) ? i386_regs.eip : x86_64_regs.rip)
+#define ARCH_SP_REG \
+ (x86_io.iov_len == sizeof(i386_regs) ? i386_regs.esp : x86_64_regs.rsp)
-extern uint32_t *const i386_esp_ptr;
-extern uint64_t *const x86_64_rsp_ptr;
/* <asm/ptrace.h> does not provide these definitions. */
#define R15 0
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define FUNC_GET_RT_SIGFRAME_ADDR \
- static kernel_ulong_t i386_get_rt_sigframe_addr(struct tcb *tcp)
-
#include "i386/arch_rt_sigframe.c"
-
-#undef FUNC_GET_RT_SIGFRAME_ADDR
-#define FUNC_GET_RT_SIGFRAME_ADDR DEF_FUNC_GET_RT_SIGFRAME_ADDR
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- return tcp->currpers == 1 ? i386_get_rt_sigframe_addr(tcp)
- : *x86_64_rsp_ptr - sizeof(kernel_ulong_t);
-}
static unsigned long xtensa_a2;
#define ARCH_PC_PEEK_ADDR REG_PC
+#define ARCH_SP_PEEK_ADDR (REG_A_BASE + 1)
+++ /dev/null
-/*
- * Copyright (c) 2017 Dmitry V. Levin <ldv@altlinux.org>
- * 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.
- */
-
-FUNC_GET_RT_SIGFRAME_ADDR
-{
- unsigned long addr;
-
- return upeek(tcp, REG_A_BASE + 3, &addr) ? 0 : addr;
-}
#endif
}
+bool
+get_stack_pointer(struct tcb *tcp, kernel_ulong_t *sp)
+{
+#if defined ARCH_SP_REG
+ if (get_regs(tcp) < 0)
+ return false;
+ *sp = (kernel_ulong_t) ARCH_SP_REG;
+ return true;
+#elif defined ARCH_SP_PEEK_ADDR
+ if (upeek(tcp, ARCH_SP_PEEK_ADDR, sp) < 0)
+ return false;
+ return true;
+#else
+ return false;
+#endif
+}
+
/*
* Returns:
* 0: "ignore this ptrace stop", syscall_entering_decode() should return a "bail