All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3 v2] arm64/ptrace: allow to get all registers on syscall traps
@ 2021-02-01 19:40 ` Andrei Vagin
  0 siblings, 0 replies; 34+ messages in thread
From: Andrei Vagin @ 2021-02-01 19:40 UTC (permalink / raw)
  To: Will Deacon, Catalin Marinas
  Cc: Oleg Nesterov, linux-arm-kernel, linux-kernel, linux-api,
	Anthony Steinhauser, Andrei Vagin, Dave Martin, Keno Fischer

Right now, ip/r12 for AArch32 and x7 for AArch64 is used to indicate
whether or not the stop has been signalled from syscall entry or syscall
exit. This means that:

- Any writes by the tracer to this register during the stop are
  ignored/discarded.

- The actual value of the register is not available during the stop,
  so the tracer cannot save it and restore it later.

For applications like the user-mode Linux or gVisor, it is critical to
have access to the full set of registers in any moment. For example,
they need to change values of all registers to emulate rt_sigreturn or
execve and they need to have the full set of registers to build a signal
frame.

This series introduces the PTRACE_O_ARM64_RAW_REGS option. If it is set,
PTRACE_GETREGSET returns values of all registers, and PTRACE_SETREGSET
allows to change any of them.

Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: Keno Fischer <keno@juliacomputing.com> 
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Will Deacon <will@kernel.org>

Andrei Vagin (3):
  arm64/ptrace: don't clobber task registers on syscall entry/exit traps
  arm64/ptrace: introduce PTRACE_O_ARM64_RAW_REGS
  selftest/arm64/ptrace: add tests for PTRACE_O_ARM64_RAW_REGS

v2: use the ptrace option instead of adding a new regset.

 arch/arm64/include/asm/ptrace.h               |   5 +
 arch/arm64/kernel/ptrace.c                    | 130 +++++++++++-----
 include/uapi/linux/elf.h                      |   1 +
 tools/testing/selftests/arm64/Makefile        |   2 +-
 tools/testing/selftests/arm64/ptrace/Makefile |   6 +
 .../arm64/ptrace/ptrace_syscall_regs_test.c   | 142 ++++++++++++++++++
 6 files changed, 246 insertions(+), 40 deletions(-)
 create mode 100644 tools/testing/selftests/arm64/ptrace/Makefile
 create mode 100644 tools/testing/selftests/arm64/ptrace/ptrace_syscall_regs_test.c

-- 
2.29.2


^ permalink raw reply	[flat|nested] 34+ messages in thread
* [PATCH 0/3] arm64/ptrace: allow to get all registers on syscall traps
@ 2021-01-19 22:06 Andrei Vagin
  2021-01-19 22:06   ` Andrei Vagin
  0 siblings, 1 reply; 34+ messages in thread
From: Andrei Vagin @ 2021-01-19 22:06 UTC (permalink / raw)
  To: Will Deacon, Catalin Marinas
  Cc: Oleg Nesterov, linux-arm-kernel, linux-kernel, Andrei Vagin

Right now, ip/r12 for AArch32 and x7 for AArch64 is used to indicate
whether or not the stop has been signalled from syscall entry or syscall
exit. This means that:

- Any writes by the tracer to this register during the stop are
  ignored/discarded.

- The actual value of the register is not available during the stop,
  so the tracer cannot save it and restore it later.

This series introduces NT_ARM_PRSTATUS to get all registers and makes it
possible to change ip/r12 and x7 registers when tracee is stopped in
syscall traps.

For applications like the user-mode Linux or gVisor, it is critical to
have access to the full set of registers in any moment. For example,
they need to change values of all registers to emulate rt_sigreturn and
they need to have the full set of registers to build a signal frame.

Andrei Vagin (3):
  arm64/ptrace: don't clobber task registers on syscall entry/exit traps
  arm64/ptrace: introduce NT_ARM_PRSTATUS to get a full set of registers
  selftest/arm64/ptrace: add a test for NT_ARM_PRSTATUS

 arch/arm64/include/asm/ptrace.h               |   5 +
 arch/arm64/kernel/ptrace.c                    | 130 +++++++++++-----
 include/uapi/linux/elf.h                      |   1 +
 tools/testing/selftests/arm64/Makefile        |   2 +-
 tools/testing/selftests/arm64/ptrace/Makefile |   6 +
 .../arm64/ptrace/ptrace_syscall_regs_test.c   | 142 ++++++++++++++++++
 6 files changed, 246 insertions(+), 40 deletions(-)
 create mode 100644 tools/testing/selftests/arm64/ptrace/Makefile
 create mode 100644 tools/testing/selftests/arm64/ptrace/ptrace_syscall_regs_test.c

-- 
2.29.2


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2021-02-25 16:03 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 19:40 [PATCH 0/3 v2] arm64/ptrace: allow to get all registers on syscall traps Andrei Vagin
2021-02-01 19:40 ` Andrei Vagin
2021-02-01 19:40 ` [PATCH 1/3] arm64/ptrace: don't clobber task registers on syscall entry/exit traps Andrei Vagin
2021-02-01 19:40   ` Andrei Vagin
2021-02-04 15:23   ` Will Deacon
2021-02-04 15:23     ` Will Deacon
2021-02-04 16:41     ` Dave Martin
2021-02-04 16:41       ` Dave Martin
2021-02-25 16:00     ` Andrei Vagin
2021-02-25 16:00       ` Andrei Vagin
2021-02-01 19:40 ` [PATCH 2/3] arm64/ptrace: introduce PTRACE_O_ARM64_RAW_REGS Andrei Vagin
2021-02-01 19:40   ` Andrei Vagin
2021-02-04 15:36   ` Will Deacon
2021-02-04 15:36     ` Will Deacon
2021-02-08 18:31     ` Andrei Vagin
2021-02-08 18:31       ` Andrei Vagin
2021-02-01 19:40 ` [PATCH 3/3] selftest/arm64/ptrace: add tests for PTRACE_O_ARM64_RAW_REGS Andrei Vagin
2021-02-01 19:40   ` Andrei Vagin
2021-02-04 15:40   ` Will Deacon
2021-02-04 15:40     ` Will Deacon
2021-02-10 20:54     ` Kees Cook
2021-02-10 20:54       ` Kees Cook
2021-02-02  0:11 ` [PATCH 0/3 v2] arm64/ptrace: allow to get all registers on syscall traps Keno Fischer
2021-02-02  0:11   ` Keno Fischer
2021-02-08 18:37   ` Andrei Vagin
2021-02-08 18:37     ` Andrei Vagin
2021-02-08 19:18     ` Keno Fischer
2021-02-08 19:18       ` Keno Fischer
2021-02-04 14:53 ` Will Deacon
2021-02-04 14:53   ` Will Deacon
  -- strict thread matches above, loose matches on Subject: below --
2021-01-19 22:06 [PATCH 0/3] " Andrei Vagin
2021-01-19 22:06 ` [PATCH 1/3] arm64/ptrace: don't clobber task registers on syscall entry/exit traps Andrei Vagin
2021-01-19 22:06   ` Andrei Vagin
2021-01-27 15:14   ` Dave Martin
2021-01-27 15:14     ` Dave Martin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.