Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932399AbeAJBFw (ORCPT + 1 other); Tue, 9 Jan 2018 20:05:52 -0500 Received: from mga05.intel.com ([192.55.52.43]:35996 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755324AbeAJBDs (ORCPT ); Tue, 9 Jan 2018 20:03:48 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,337,1511856000"; d="scan'208";a="193590476" From: Andi Kleen To: tglx@linutronix.de Cc: x86@kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, dwmw@amazon.co.uk, pjt@google.com, luto@kernel.org, peterz@infradead.org, thomas.lendacky@amd.com, tim.c.chen@linux.intel.com, gregkh@linux-foundation.org, dave.hansen@intel.com, jikos@kernel.org, Andi Kleen Subject: [PATCH v1 3/8] x86/entry/clearregs: Clear registers for 64bit SYSCALL Date: Tue, 9 Jan 2018 17:03:23 -0800 Message-Id: <20180110010328.22163-4-andi@firstfloor.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180110010328.22163-1-andi@firstfloor.org> References: <20180110010328.22163-1-andi@firstfloor.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Andi Kleen We clear all the non argument registers for 64bit SYSCALLs to minimize any risk of bad speculation using user values. So far unused argument registers still leak. To be addressed in future patches. Signed-off-by: Andi Kleen --- arch/x86/entry/entry_64.S | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index bbdfbdd817d6..632081fd7086 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -236,6 +236,14 @@ GLOBAL(entry_SYSCALL_64_after_hwframe) pushq %r11 /* pt_regs->r11 */ sub $(6*8), %rsp SAVE_EXTRA_REGS + /* Sanitize registers against speculation attacks */ + /* r10 is cleared later, arguments are handled in san_args* */ + CLEAR_R11_TO_R15 +#ifndef CONFIG_FRAME_POINTER + xor %ebp, %ebp +#endif + xor %ebx, %ebx + xor %ecx, %ecx UNWIND_HINT_REGS extra=0 @@ -263,6 +271,7 @@ entry_SYSCALL_64_fastpath: #endif ja 1f /* return -ENOSYS (already in pt_regs->ax) */ movq %r10, %rcx + xor %r10, %r10 #ifdef CONFIG_RETPOLINE movq sys_call_table(, %rax, 8), %rax -- 2.14.3