[PATCH v1 4/8] x86/entry/retpoline: Clear extra registers for compat syscalls

From: Andi Kleen
Date: Tue Jan 09 2018 - 20:04:59 EST


From: Andi Kleen <ak@xxxxxxxxxxxxxxx>

Clear all registers for compat calls on 64bit kernels. All arguments
are initially passed through the stack, so this is fairly simple
without additional stubs.

Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
---
arch/x86/entry/entry_64_compat.S | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 98d5358e4041..16fd2643a77f 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -95,6 +95,8 @@ ENTRY(entry_SYSENTER_compat)
pushq $0 /* pt_regs->r14 = 0 */
pushq $0 /* pt_regs->r15 = 0 */
cld
+ /* Can clear all because arguments are passed through the stack */
+ CLEAR_ALL_REGS

/*
* SYSENTER doesn't filter flags, so we need to clear NT and AC
@@ -223,6 +225,8 @@ GLOBAL(entry_SYSCALL_compat_after_hwframe)
pushq $0 /* pt_regs->r13 = 0 */
pushq $0 /* pt_regs->r14 = 0 */
pushq $0 /* pt_regs->r15 = 0 */
+ /* Can clear all because arguments are passed through the stack */
+ CLEAR_ALL_REGS

/*
* User mode is traced as though IRQs are on, and SYSENTER
@@ -348,6 +352,8 @@ ENTRY(entry_INT80_compat)
pushq %r14 /* pt_regs->r14 */
pushq %r15 /* pt_regs->r15 */
cld
+ /* Can clear all because arguments are passed through the stack */
+ CLEAR_ALL_REGS

/*
* User mode is traced as though IRQs are on, and the interrupt
--
2.14.3