]> git.baikalelectronics.ru Git - kernel.git/commit
arm64: Fix PTRACE_SYSEMU semantics
authorKeno Fischer <keno@juliacomputing.com>
Fri, 15 May 2020 22:22:53 +0000 (18:22 -0400)
committerCatalin Marinas <catalin.marinas@arm.com>
Wed, 20 May 2020 11:02:42 +0000 (12:02 +0100)
commit94c0191894a13caec5af58e46244bb5c32b250d8
tree1b9650bcfb2cd004500336b1402553b25ccd057f
parent52c95ad81348696bf5e4e23353c00c64d4dc98a7
arm64: Fix PTRACE_SYSEMU semantics

Quoth the man page:
```
       If the tracee was restarted by PTRACE_SYSCALL or PTRACE_SYSEMU, the
       tracee enters syscall-enter-stop just prior to entering any system
       call (which will not be executed if the restart was using
       PTRACE_SYSEMU, regardless of any change made to registers at this
       point or how the tracee is restarted after this stop).
```

The parenthetical comment is currently true on x86 and powerpc,
but not currently true on arm64. arm64 re-checks the _TIF_SYSCALL_EMU
flag after the syscall entry ptrace stop. However, at this point,
it reflects which method was used to re-start the syscall
at the entry stop, rather than the method that was used to reach it.
Fix that by recording the original flag before performing the ptrace
stop, bringing the behavior in line with documentation and x86/powerpc.

Fixes: f20d954accdc ("arm64: ptrace: add support for syscall emulation")
Cc: <stable@vger.kernel.org> # 5.3.x-
Signed-off-by: Keno Fischer <keno@juliacomputing.com>
Acked-by: Will Deacon <will@kernel.org>
Tested-by: Sudeep Holla <sudeep.holla@arm.com>
Tested-by: Bin Lu <Bin.Lu@arm.com>
[catalin.marinas@arm.com: moved 'flags' bit masking]
[catalin.marinas@arm.com: changed 'flags' type to unsigned long]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/ptrace.c