This set of changes removes tracehook.h, moves modification of all of
the ptrace fields inside of siglock to remove races, adds a missing
permission check to ptrace.c
The removal of tracehook.h is quite significant as it has been a major
source of confusion in recent years. Much of that confusion was
around task_work and TIF_NOTIFY_SIGNAL (which I have now decoupled
making the semantics clearer).
For people who don't know tracehook.h is a vestiage of an attempt to
implement uprobes like functionality that was never fully merged, and
was later superseeded by uprobes when uprobes was merged. For many
years now we have been removing what tracehook functionaly a little
bit at a time. To the point where now anything left in tracehook.h is
some weird strange thing that is difficult to understand.
Eric W. Biederman (15):
ptrace: Move ptrace_report_syscall into ptrace.h
ptrace/arm: Rename tracehook_report_syscall report_syscall
ptrace: Create ptrace_report_syscall_{entry,exit} in ptrace.h
ptrace: Remove arch_syscall_{enter,exit}_tracehook
ptrace: Remove tracehook_signal_handler
task_work: Remove unnecessary include from posix_timers.h
task_work: Introduce task_work_pending
task_work: Call tracehook_notify_signal from get_signal on all architectures
task_work: Decouple TIF_NOTIFY_SIGNAL and task_work
signal: Move set_notify_signal and clear_notify_signal into sched/signal.h
resume_user_mode: Remove #ifdef TIF_NOTIFY_RESUME in set_notify_resume
resume_user_mode: Move to resume_user_mode.h
tracehook: Remove tracehook.h
ptrace: Move setting/clearing ptrace_message into ptrace_stop
ptrace: Return the signal to continue with from ptrace_stop
Jann Horn (1):
ptrace: Check PTRACE_O_SUSPEND_SECCOMP permission on PTRACE_SEIZE
Yang Li (1):
ptrace: Remove duplicated include in ptrace.c
MAINTAINERS | 1 -
arch/Kconfig | 5 +-
arch/alpha/kernel/ptrace.c | 5 +-
arch/alpha/kernel/signal.c | 4 +-
arch/arc/kernel/ptrace.c | 5 +-
arch/arc/kernel/signal.c | 4 +-
arch/arm/kernel/ptrace.c | 12 +-
arch/arm/kernel/signal.c | 4 +-
arch/arm64/kernel/ptrace.c | 14 +--
arch/arm64/kernel/signal.c | 4 +-
arch/csky/kernel/ptrace.c | 5 +-
arch/csky/kernel/signal.c | 4 +-
arch/h8300/kernel/ptrace.c | 5 +-
arch/h8300/kernel/signal.c | 4 +-
arch/hexagon/kernel/process.c | 4 +-
arch/hexagon/kernel/signal.c | 1 -
arch/hexagon/kernel/traps.c | 6 +-
arch/ia64/kernel/process.c | 4 +-
arch/ia64/kernel/ptrace.c | 6 +-
arch/ia64/kernel/signal.c | 1 -
arch/m68k/kernel/ptrace.c | 5 +-
arch/m68k/kernel/signal.c | 4 +-
arch/microblaze/kernel/ptrace.c | 5 +-
arch/microblaze/kernel/signal.c | 4 +-
arch/mips/kernel/ptrace.c | 5 +-
arch/mips/kernel/signal.c | 4 +-
arch/nds32/include/asm/syscall.h | 2 +-
arch/nds32/kernel/ptrace.c | 5 +-
arch/nds32/kernel/signal.c | 4 +-
arch/nios2/kernel/ptrace.c | 5 +-
arch/nios2/kernel/signal.c | 4 +-
arch/openrisc/kernel/ptrace.c | 5 +-
arch/openrisc/kernel/signal.c | 4 +-
arch/parisc/kernel/ptrace.c | 7 +-
arch/parisc/kernel/signal.c | 4 +-
arch/powerpc/kernel/ptrace/ptrace.c | 8 +-
arch/powerpc/kernel/signal.c | 4 +-
arch/riscv/kernel/ptrace.c | 5 +-
arch/riscv/kernel/signal.c | 4 +-
arch/s390/include/asm/entry-common.h | 1 -
arch/s390/kernel/ptrace.c | 1 -
arch/s390/kernel/signal.c | 5 +-
arch/sh/kernel/ptrace_32.c | 5 +-
arch/sh/kernel/signal_32.c | 4 +-
arch/sparc/kernel/ptrace_32.c | 5 +-
arch/sparc/kernel/ptrace_64.c | 5 +-
arch/sparc/kernel/signal32.c | 1 -
arch/sparc/kernel/signal_32.c | 4 +-
arch/sparc/kernel/signal_64.c | 4 +-
arch/um/kernel/process.c | 4 +-
arch/um/kernel/ptrace.c | 5 +-
arch/x86/kernel/ptrace.c | 1 -
arch/x86/kernel/signal.c | 5 +-
arch/x86/mm/tlb.c | 1 +
arch/xtensa/kernel/ptrace.c | 5 +-
arch/xtensa/kernel/signal.c | 4 +-
block/blk-cgroup.c | 2 +-
fs/coredump.c | 1 -
fs/exec.c | 1 -
fs/io-wq.c | 6 +-
fs/io_uring.c | 11 +-
fs/proc/array.c | 1 -
fs/proc/base.c | 1 -
include/asm-generic/syscall.h | 2 +-
include/linux/entry-common.h | 47 +-------
include/linux/entry-kvm.h | 2 +-
include/linux/posix-timers.h | 1 -
include/linux/ptrace.h | 81 ++++++++++++-
include/linux/resume_user_mode.h | 64 ++++++++++
include/linux/sched/signal.h | 17 +++
include/linux/task_work.h | 5 +
include/linux/tracehook.h | 226 -----------------------------------
include/uapi/linux/ptrace.h | 2 +-
kernel/entry/common.c | 19 +--
kernel/entry/kvm.c | 9 +-
kernel/exit.c | 3 +-
kernel/livepatch/transition.c | 1 -
kernel/ptrace.c | 47 +++++---
kernel/seccomp.c | 1 -
kernel/signal.c | 62 +++++-----
kernel/task_work.c | 4 +-
kernel/time/posix-cpu-timers.c | 1 +
mm/memcontrol.c | 2 +-
security/apparmor/domain.c | 1 -
security/selinux/hooks.c | 1 -
85 files changed, 372 insertions(+), 495 deletions(-)
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEgjlraLDcwBA2B+6cC/v6Eiajj0AFAmJCQkoACgkQC/v6Eiaj
j0DCWQ/5AZVFU+hX32obUNCLackHTwgcCtSOs3JNBmNA/zL/htPiYYG0ghkvtlDR
Dw5J5DnxC6P7PVAdAqrpvx2uX2FebHYU0bRlyLx8LYUEP5dhyNicxX9jA882Z+vw
Ud0Ue9EojwGWS76dC9YoKUj3slThMATbhA2r4GVEoof8fSNJaBxQIqath44t0FwU
DinWa+tIOvZANGBZr6CUUINNIgqBIZCH/R4h6ArBhMlJpuQ5Ufk2kAaiWFwZCkX4
0LuuAwbKsCKkF8eap5I2KrIg/7zZVgxAg9O3cHOzzm8OPbKzRnNnQClcDe8perqp
S6e/f3MgpE+eavd1EiLxevZ660cJChnmikXVVh8ZYYoefaMKGqBaBSsB38bNcLjY
3+f2dB+TNBFRnZs1aCujK3tWBT9QyjZDKtCBfzxDNWBpXGLhHH6j6lA5Lj+Cef5K
/HNHFb+FuqedlFZh5m1Y+piFQ70hTgCa2u8b+FSOubI2hW9Zd+WzINV0ANaZ2LvZ
4YGtcyDNk1q1+c87lxP9xMRl/xi6rNg+B9T2MCo4IUnHgpSVP6VEB3osgUmrrrN0
eQlUI154G/AaDlqXLgmn1xhRmlPGfmenkxpok1AuzxvNJsfLKnpEwQSc13g3oiZr
disZQxNY0kBO2Nv3G323Z6PLinhbiIIFez6cJzK5v0YJ2WtO3pY=
=uEro
-----END PGP SIGNATURE-----
Merge tag 'ptrace-cleanups-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull ptrace cleanups from Eric Biederman:
"This set of changes removes tracehook.h, moves modification of all of
the ptrace fields inside of siglock to remove races, adds a missing
permission check to ptrace.c
The removal of tracehook.h is quite significant as it has been a major
source of confusion in recent years. Much of that confusion was around
task_work and TIF_NOTIFY_SIGNAL (which I have now decoupled making the
semantics clearer).
For people who don't know tracehook.h is a vestiage of an attempt to
implement uprobes like functionality that was never fully merged, and
was later superseeded by uprobes when uprobes was merged. For many
years now we have been removing what tracehook functionaly a little
bit at a time. To the point where anything left in tracehook.h was
some weird strange thing that was difficult to understand"
* tag 'ptrace-cleanups-for-v5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
ptrace: Remove duplicated include in ptrace.c
ptrace: Check PTRACE_O_SUSPEND_SECCOMP permission on PTRACE_SEIZE
ptrace: Return the signal to continue with from ptrace_stop
ptrace: Move setting/clearing ptrace_message into ptrace_stop
tracehook: Remove tracehook.h
resume_user_mode: Move to resume_user_mode.h
resume_user_mode: Remove #ifdef TIF_NOTIFY_RESUME in set_notify_resume
signal: Move set_notify_signal and clear_notify_signal into sched/signal.h
task_work: Decouple TIF_NOTIFY_SIGNAL and task_work
task_work: Call tracehook_notify_signal from get_signal on all architectures
task_work: Introduce task_work_pending
task_work: Remove unnecessary include from posix_timers.h
ptrace: Remove tracehook_signal_handler
ptrace: Remove arch_syscall_{enter,exit}_tracehook
ptrace: Create ptrace_report_syscall_{entry,exit} in ptrace.h
ptrace/arm: Rename tracehook_report_syscall report_syscall
ptrace: Move ptrace_report_syscall into ptrace.h
454 lines
12 KiB
C
454 lines
12 KiB
C
/*
|
|
* PowerPC version
|
|
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
|
|
*
|
|
* Derived from "arch/m68k/kernel/ptrace.c"
|
|
* Copyright (C) 1994 by Hamish Macdonald
|
|
* Taken from linux/kernel/ptrace.c and modified for M680x0.
|
|
* linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
|
|
*
|
|
* Modified by Cort Dougan (cort@hq.fsmlabs.com)
|
|
* and Paul Mackerras (paulus@samba.org).
|
|
*
|
|
* This file is subject to the terms and conditions of the GNU General
|
|
* Public License. See the file README.legal in the main directory of
|
|
* this archive for more details.
|
|
*/
|
|
|
|
#include <linux/regset.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/audit.h>
|
|
#include <linux/context_tracking.h>
|
|
#include <linux/syscalls.h>
|
|
|
|
#include <asm/switch_to.h>
|
|
#include <asm/debug.h>
|
|
|
|
#define CREATE_TRACE_POINTS
|
|
#include <trace/events/syscalls.h>
|
|
|
|
#include "ptrace-decl.h"
|
|
|
|
/*
|
|
* Called by kernel/ptrace.c when detaching..
|
|
*
|
|
* Make sure single step bits etc are not set.
|
|
*/
|
|
void ptrace_disable(struct task_struct *child)
|
|
{
|
|
/* make sure the single step bit is not set. */
|
|
user_disable_single_step(child);
|
|
}
|
|
|
|
long arch_ptrace(struct task_struct *child, long request,
|
|
unsigned long addr, unsigned long data)
|
|
{
|
|
int ret = -EPERM;
|
|
void __user *datavp = (void __user *) data;
|
|
unsigned long __user *datalp = datavp;
|
|
|
|
switch (request) {
|
|
/* read the word at location addr in the USER area. */
|
|
case PTRACE_PEEKUSR: {
|
|
unsigned long index, tmp;
|
|
|
|
ret = -EIO;
|
|
/* convert to index and check */
|
|
index = addr / sizeof(long);
|
|
if ((addr & (sizeof(long) - 1)) || !child->thread.regs)
|
|
break;
|
|
|
|
if (index < PT_FPR0)
|
|
ret = ptrace_get_reg(child, (int) index, &tmp);
|
|
else
|
|
ret = ptrace_get_fpr(child, index, &tmp);
|
|
|
|
if (ret)
|
|
break;
|
|
ret = put_user(tmp, datalp);
|
|
break;
|
|
}
|
|
|
|
/* write the word at location addr in the USER area */
|
|
case PTRACE_POKEUSR: {
|
|
unsigned long index;
|
|
|
|
ret = -EIO;
|
|
/* convert to index and check */
|
|
index = addr / sizeof(long);
|
|
if ((addr & (sizeof(long) - 1)) || !child->thread.regs)
|
|
break;
|
|
|
|
if (index < PT_FPR0)
|
|
ret = ptrace_put_reg(child, index, data);
|
|
else
|
|
ret = ptrace_put_fpr(child, index, data);
|
|
break;
|
|
}
|
|
|
|
case PPC_PTRACE_GETHWDBGINFO: {
|
|
struct ppc_debug_info dbginfo;
|
|
|
|
ppc_gethwdinfo(&dbginfo);
|
|
|
|
if (copy_to_user(datavp, &dbginfo,
|
|
sizeof(struct ppc_debug_info)))
|
|
return -EFAULT;
|
|
return 0;
|
|
}
|
|
|
|
case PPC_PTRACE_SETHWDEBUG: {
|
|
struct ppc_hw_breakpoint bp_info;
|
|
|
|
if (copy_from_user(&bp_info, datavp,
|
|
sizeof(struct ppc_hw_breakpoint)))
|
|
return -EFAULT;
|
|
return ppc_set_hwdebug(child, &bp_info);
|
|
}
|
|
|
|
case PPC_PTRACE_DELHWDEBUG: {
|
|
ret = ppc_del_hwdebug(child, data);
|
|
break;
|
|
}
|
|
|
|
case PTRACE_GET_DEBUGREG:
|
|
ret = ptrace_get_debugreg(child, addr, datalp);
|
|
break;
|
|
|
|
case PTRACE_SET_DEBUGREG:
|
|
ret = ptrace_set_debugreg(child, addr, data);
|
|
break;
|
|
|
|
#ifdef CONFIG_PPC64
|
|
case PTRACE_GETREGS64:
|
|
#endif
|
|
case PTRACE_GETREGS: /* Get all pt_regs from the child. */
|
|
return copy_regset_to_user(child, &user_ppc_native_view,
|
|
REGSET_GPR,
|
|
0, sizeof(struct user_pt_regs),
|
|
datavp);
|
|
|
|
#ifdef CONFIG_PPC64
|
|
case PTRACE_SETREGS64:
|
|
#endif
|
|
case PTRACE_SETREGS: /* Set all gp regs in the child. */
|
|
return copy_regset_from_user(child, &user_ppc_native_view,
|
|
REGSET_GPR,
|
|
0, sizeof(struct user_pt_regs),
|
|
datavp);
|
|
|
|
case PTRACE_GETFPREGS: /* Get the child FPU state (FPR0...31 + FPSCR) */
|
|
return copy_regset_to_user(child, &user_ppc_native_view,
|
|
REGSET_FPR,
|
|
0, sizeof(elf_fpregset_t),
|
|
datavp);
|
|
|
|
case PTRACE_SETFPREGS: /* Set the child FPU state (FPR0...31 + FPSCR) */
|
|
return copy_regset_from_user(child, &user_ppc_native_view,
|
|
REGSET_FPR,
|
|
0, sizeof(elf_fpregset_t),
|
|
datavp);
|
|
|
|
#ifdef CONFIG_ALTIVEC
|
|
case PTRACE_GETVRREGS:
|
|
return copy_regset_to_user(child, &user_ppc_native_view,
|
|
REGSET_VMX,
|
|
0, (33 * sizeof(vector128) +
|
|
sizeof(u32)),
|
|
datavp);
|
|
|
|
case PTRACE_SETVRREGS:
|
|
return copy_regset_from_user(child, &user_ppc_native_view,
|
|
REGSET_VMX,
|
|
0, (33 * sizeof(vector128) +
|
|
sizeof(u32)),
|
|
datavp);
|
|
#endif
|
|
#ifdef CONFIG_VSX
|
|
case PTRACE_GETVSRREGS:
|
|
return copy_regset_to_user(child, &user_ppc_native_view,
|
|
REGSET_VSX,
|
|
0, 32 * sizeof(double),
|
|
datavp);
|
|
|
|
case PTRACE_SETVSRREGS:
|
|
return copy_regset_from_user(child, &user_ppc_native_view,
|
|
REGSET_VSX,
|
|
0, 32 * sizeof(double),
|
|
datavp);
|
|
#endif
|
|
#ifdef CONFIG_SPE
|
|
case PTRACE_GETEVRREGS:
|
|
/* Get the child spe register state. */
|
|
return copy_regset_to_user(child, &user_ppc_native_view,
|
|
REGSET_SPE, 0, 35 * sizeof(u32),
|
|
datavp);
|
|
|
|
case PTRACE_SETEVRREGS:
|
|
/* Set the child spe register state. */
|
|
return copy_regset_from_user(child, &user_ppc_native_view,
|
|
REGSET_SPE, 0, 35 * sizeof(u32),
|
|
datavp);
|
|
#endif
|
|
|
|
default:
|
|
ret = ptrace_request(child, request, addr, data);
|
|
break;
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
#ifdef CONFIG_SECCOMP
|
|
static int do_seccomp(struct pt_regs *regs)
|
|
{
|
|
if (!test_thread_flag(TIF_SECCOMP))
|
|
return 0;
|
|
|
|
/*
|
|
* The ABI we present to seccomp tracers is that r3 contains
|
|
* the syscall return value and orig_gpr3 contains the first
|
|
* syscall parameter. This is different to the ptrace ABI where
|
|
* both r3 and orig_gpr3 contain the first syscall parameter.
|
|
*/
|
|
regs->gpr[3] = -ENOSYS;
|
|
|
|
/*
|
|
* We use the __ version here because we have already checked
|
|
* TIF_SECCOMP. If this fails, there is nothing left to do, we
|
|
* have already loaded -ENOSYS into r3, or seccomp has put
|
|
* something else in r3 (via SECCOMP_RET_ERRNO/TRACE).
|
|
*/
|
|
if (__secure_computing(NULL))
|
|
return -1;
|
|
|
|
/*
|
|
* The syscall was allowed by seccomp, restore the register
|
|
* state to what audit expects.
|
|
* Note that we use orig_gpr3, which means a seccomp tracer can
|
|
* modify the first syscall parameter (in orig_gpr3) and also
|
|
* allow the syscall to proceed.
|
|
*/
|
|
regs->gpr[3] = regs->orig_gpr3;
|
|
|
|
return 0;
|
|
}
|
|
#else
|
|
static inline int do_seccomp(struct pt_regs *regs) { return 0; }
|
|
#endif /* CONFIG_SECCOMP */
|
|
|
|
/**
|
|
* do_syscall_trace_enter() - Do syscall tracing on kernel entry.
|
|
* @regs: the pt_regs of the task to trace (current)
|
|
*
|
|
* Performs various types of tracing on syscall entry. This includes seccomp,
|
|
* ptrace, syscall tracepoints and audit.
|
|
*
|
|
* The pt_regs are potentially visible to userspace via ptrace, so their
|
|
* contents is ABI.
|
|
*
|
|
* One or more of the tracers may modify the contents of pt_regs, in particular
|
|
* to modify arguments or even the syscall number itself.
|
|
*
|
|
* It's also possible that a tracer can choose to reject the system call. In
|
|
* that case this function will return an illegal syscall number, and will put
|
|
* an appropriate return value in regs->r3.
|
|
*
|
|
* Return: the (possibly changed) syscall number.
|
|
*/
|
|
long do_syscall_trace_enter(struct pt_regs *regs)
|
|
{
|
|
u32 flags;
|
|
|
|
flags = read_thread_flags() & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE);
|
|
|
|
if (flags) {
|
|
int rc = ptrace_report_syscall_entry(regs);
|
|
|
|
if (unlikely(flags & _TIF_SYSCALL_EMU)) {
|
|
/*
|
|
* A nonzero return code from
|
|
* ptrace_report_syscall_entry() tells us to prevent
|
|
* the syscall execution, but we are not going to
|
|
* execute it anyway.
|
|
*
|
|
* Returning -1 will skip the syscall execution. We want
|
|
* to avoid clobbering any registers, so we don't goto
|
|
* the skip label below.
|
|
*/
|
|
return -1;
|
|
}
|
|
|
|
if (rc) {
|
|
/*
|
|
* The tracer decided to abort the syscall. Note that
|
|
* the tracer may also just change regs->gpr[0] to an
|
|
* invalid syscall number, that is handled below on the
|
|
* exit path.
|
|
*/
|
|
goto skip;
|
|
}
|
|
}
|
|
|
|
/* Run seccomp after ptrace; allow it to set gpr[3]. */
|
|
if (do_seccomp(regs))
|
|
return -1;
|
|
|
|
/* Avoid trace and audit when syscall is invalid. */
|
|
if (regs->gpr[0] >= NR_syscalls)
|
|
goto skip;
|
|
|
|
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
|
trace_sys_enter(regs, regs->gpr[0]);
|
|
|
|
if (!is_32bit_task())
|
|
audit_syscall_entry(regs->gpr[0], regs->gpr[3], regs->gpr[4],
|
|
regs->gpr[5], regs->gpr[6]);
|
|
else
|
|
audit_syscall_entry(regs->gpr[0],
|
|
regs->gpr[3] & 0xffffffff,
|
|
regs->gpr[4] & 0xffffffff,
|
|
regs->gpr[5] & 0xffffffff,
|
|
regs->gpr[6] & 0xffffffff);
|
|
|
|
/* Return the possibly modified but valid syscall number */
|
|
return regs->gpr[0];
|
|
|
|
skip:
|
|
/*
|
|
* If we are aborting explicitly, or if the syscall number is
|
|
* now invalid, set the return value to -ENOSYS.
|
|
*/
|
|
regs->gpr[3] = -ENOSYS;
|
|
return -1;
|
|
}
|
|
|
|
void do_syscall_trace_leave(struct pt_regs *regs)
|
|
{
|
|
int step;
|
|
|
|
audit_syscall_exit(regs);
|
|
|
|
if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
|
|
trace_sys_exit(regs, regs->result);
|
|
|
|
step = test_thread_flag(TIF_SINGLESTEP);
|
|
if (step || test_thread_flag(TIF_SYSCALL_TRACE))
|
|
ptrace_report_syscall_exit(regs, step);
|
|
}
|
|
|
|
void __init pt_regs_check(void);
|
|
|
|
/*
|
|
* Dummy function, its purpose is to break the build if struct pt_regs and
|
|
* struct user_pt_regs don't match.
|
|
*/
|
|
void __init pt_regs_check(void)
|
|
{
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, gpr) !=
|
|
offsetof(struct user_pt_regs, gpr));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, nip) !=
|
|
offsetof(struct user_pt_regs, nip));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, msr) !=
|
|
offsetof(struct user_pt_regs, msr));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
|
|
offsetof(struct user_pt_regs, orig_gpr3));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, ctr) !=
|
|
offsetof(struct user_pt_regs, ctr));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, link) !=
|
|
offsetof(struct user_pt_regs, link));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, xer) !=
|
|
offsetof(struct user_pt_regs, xer));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, ccr) !=
|
|
offsetof(struct user_pt_regs, ccr));
|
|
#ifdef __powerpc64__
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, softe) !=
|
|
offsetof(struct user_pt_regs, softe));
|
|
#else
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, mq) !=
|
|
offsetof(struct user_pt_regs, mq));
|
|
#endif
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, trap) !=
|
|
offsetof(struct user_pt_regs, trap));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, dar) !=
|
|
offsetof(struct user_pt_regs, dar));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, dear) !=
|
|
offsetof(struct user_pt_regs, dar));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, dsisr) !=
|
|
offsetof(struct user_pt_regs, dsisr));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, esr) !=
|
|
offsetof(struct user_pt_regs, dsisr));
|
|
BUILD_BUG_ON(offsetof(struct pt_regs, result) !=
|
|
offsetof(struct user_pt_regs, result));
|
|
|
|
BUILD_BUG_ON(sizeof(struct user_pt_regs) > sizeof(struct pt_regs));
|
|
|
|
// Now check that the pt_regs offsets match the uapi #defines
|
|
#define CHECK_REG(_pt, _reg) \
|
|
BUILD_BUG_ON(_pt != (offsetof(struct user_pt_regs, _reg) / \
|
|
sizeof(unsigned long)));
|
|
|
|
CHECK_REG(PT_R0, gpr[0]);
|
|
CHECK_REG(PT_R1, gpr[1]);
|
|
CHECK_REG(PT_R2, gpr[2]);
|
|
CHECK_REG(PT_R3, gpr[3]);
|
|
CHECK_REG(PT_R4, gpr[4]);
|
|
CHECK_REG(PT_R5, gpr[5]);
|
|
CHECK_REG(PT_R6, gpr[6]);
|
|
CHECK_REG(PT_R7, gpr[7]);
|
|
CHECK_REG(PT_R8, gpr[8]);
|
|
CHECK_REG(PT_R9, gpr[9]);
|
|
CHECK_REG(PT_R10, gpr[10]);
|
|
CHECK_REG(PT_R11, gpr[11]);
|
|
CHECK_REG(PT_R12, gpr[12]);
|
|
CHECK_REG(PT_R13, gpr[13]);
|
|
CHECK_REG(PT_R14, gpr[14]);
|
|
CHECK_REG(PT_R15, gpr[15]);
|
|
CHECK_REG(PT_R16, gpr[16]);
|
|
CHECK_REG(PT_R17, gpr[17]);
|
|
CHECK_REG(PT_R18, gpr[18]);
|
|
CHECK_REG(PT_R19, gpr[19]);
|
|
CHECK_REG(PT_R20, gpr[20]);
|
|
CHECK_REG(PT_R21, gpr[21]);
|
|
CHECK_REG(PT_R22, gpr[22]);
|
|
CHECK_REG(PT_R23, gpr[23]);
|
|
CHECK_REG(PT_R24, gpr[24]);
|
|
CHECK_REG(PT_R25, gpr[25]);
|
|
CHECK_REG(PT_R26, gpr[26]);
|
|
CHECK_REG(PT_R27, gpr[27]);
|
|
CHECK_REG(PT_R28, gpr[28]);
|
|
CHECK_REG(PT_R29, gpr[29]);
|
|
CHECK_REG(PT_R30, gpr[30]);
|
|
CHECK_REG(PT_R31, gpr[31]);
|
|
CHECK_REG(PT_NIP, nip);
|
|
CHECK_REG(PT_MSR, msr);
|
|
CHECK_REG(PT_ORIG_R3, orig_gpr3);
|
|
CHECK_REG(PT_CTR, ctr);
|
|
CHECK_REG(PT_LNK, link);
|
|
CHECK_REG(PT_XER, xer);
|
|
CHECK_REG(PT_CCR, ccr);
|
|
#ifdef CONFIG_PPC64
|
|
CHECK_REG(PT_SOFTE, softe);
|
|
#else
|
|
CHECK_REG(PT_MQ, mq);
|
|
#endif
|
|
CHECK_REG(PT_TRAP, trap);
|
|
CHECK_REG(PT_DAR, dar);
|
|
CHECK_REG(PT_DSISR, dsisr);
|
|
CHECK_REG(PT_RESULT, result);
|
|
#undef CHECK_REG
|
|
|
|
BUILD_BUG_ON(PT_REGS_COUNT != sizeof(struct user_pt_regs) / sizeof(unsigned long));
|
|
|
|
/*
|
|
* PT_DSCR isn't a real reg, but it's important that it doesn't overlap the
|
|
* real registers.
|
|
*/
|
|
BUILD_BUG_ON(PT_DSCR < sizeof(struct user_pt_regs) / sizeof(unsigned long));
|
|
|
|
#ifdef PPC64_ELF_ABI_v1
|
|
BUILD_BUG_ON(!IS_ENABLED(CONFIG_HAVE_FUNCTION_DESCRIPTORS));
|
|
#else
|
|
BUILD_BUG_ON(IS_ENABLED(CONFIG_HAVE_FUNCTION_DESCRIPTORS));
|
|
#endif
|
|
}
|