diff options
author | Will Deacon <will@kernel.org> | 2020-07-03 14:08:42 +0300 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2020-07-16 13:41:31 +0300 |
commit | 15956689a0e60aa0c795174f3c310b60d8794235 (patch) | |
tree | 7e7e6e911ca9ccbf33c0db2aaa54be3b59e022da /arch/arm64/kernel/syscall.c | |
parent | 3a5a4366cecc25daa300b9a9174f7fdd352b9068 (diff) | |
download | linux-15956689a0e60aa0c795174f3c310b60d8794235.tar.xz |
arm64: compat: Ensure upper 32 bits of x0 are zero on syscall return
Although we zero the upper bits of x0 on entry to the kernel from an
AArch32 task, we do not clear them on the exception return path and can
therefore expose 64-bit sign extended syscall return values to userspace
via interfaces such as the 'perf_regs' ABI, which deal exclusively with
64-bit registers.
Explicitly clear the upper 32 bits of x0 on return from a compat system
call.
Cc: <stable@vger.kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Keno Fischer <keno@juliacomputing.com>
Cc: Luis Machado <luis.machado@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
Diffstat (limited to 'arch/arm64/kernel/syscall.c')
-rw-r--r-- | arch/arm64/kernel/syscall.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 7c14466a12af..98a26d4e7b0c 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -50,6 +50,9 @@ static void invoke_syscall(struct pt_regs *regs, unsigned int scno, ret = do_ni_syscall(regs, scno); } + if (is_compat_task()) + ret = lower_32_bits(ret); + regs->regs[0] = ret; } |