Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbeAKDgA (ORCPT + 1 other); Wed, 10 Jan 2018 22:36:00 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:34503 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753084AbeAKDf7 (ORCPT ); Wed, 10 Jan 2018 22:35:59 -0500 X-Google-Smtp-Source: ACJfBouETe5NjgOIdESmV/6sBiqqJD8jTsQaq2QUg9r4eRdm3ybCCn5tUDzX/O9/D8bopHARWOOC5c+NEgd0ya/K4JE= MIME-Version: 1.0 In-Reply-To: <20180110010328.22163-4-andi@firstfloor.org> References: <20180110010328.22163-1-andi@firstfloor.org> <20180110010328.22163-4-andi@firstfloor.org> From: Brian Gerst Date: Wed, 10 Jan 2018 22:35:58 -0500 Message-ID: Subject: Re: [PATCH v1 3/8] x86/entry/clearregs: Clear registers for 64bit SYSCALL To: Andi Kleen Cc: Thomas Gleixner , "the arch/x86 maintainers" , Linux Kernel Mailing List , Linus Torvalds , David Woodhouse , Paul Turner , Andy Lutomirski , Peter Zijlstra , Tom Lendacky , Tim Chen , Greg Kroah-Hartman , Dave Hansen , Jiri Kosina , Andi Kleen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Tue, Jan 9, 2018 at 8:03 PM, Andi Kleen wrote: > 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 Don't need to explicitly clear R11 here. It is clobbered with current_task. > +#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 RCX is already clear, so xchgq %r10, %rcx will be simpler. -- Brian Gerst