Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757137AbeAHVUz (ORCPT + 1 other); Mon, 8 Jan 2018 16:20:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49302 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754424AbeAHVUx (ORCPT ); Mon, 8 Jan 2018 16:20:53 -0500 Date: Mon, 8 Jan 2018 15:20:46 -0600 From: Josh Poimboeuf To: David Woodhouse Cc: Thomas Gleixner , David Woodhouse , Andi Kleen , Paul Turner , LKML , Linus Torvalds , Greg Kroah-Hartman , Tim Chen , Dave Hansen , Kees Cook , Rik van Riel , Peter Zijlstra , Andy Lutomirski , Jiri Kosina , gnomes@lxorguk.ukuu.org.uk Subject: Re: [PATCH v6 01/10] x86/retpoline: Add initial retpoline support Message-ID: <20180108212046.3wkqerxkellnqudy@treble> References: <1515363085-4219-1-git-send-email-dwmw@amazon.co.uk> <1515363085-4219-2-git-send-email-dwmw@amazon.co.uk> <20180108134220.2for3pwgqbmkkq2s@treble> <20180108135305.awviy2ae3gxh4ybl@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 08 Jan 2018 21:20:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 02:26:11PM -0000, David Woodhouse wrote: > > > On Mon, Jan 08, 2018 at 02:46:32PM +0100, Thomas Gleixner wrote: > >> On Mon, 8 Jan 2018, Josh Poimboeuf wrote: > >> > On Sun, Jan 07, 2018 at 10:11:16PM +0000, David Woodhouse wrote: > >> > > diff --git a/arch/x86/Makefile b/arch/x86/Makefile > >> > > index a20eacd..918e550 100644 > >> > > --- a/arch/x86/Makefile > >> > > +++ b/arch/x86/Makefile > >> > > @@ -235,6 +235,16 @@ KBUILD_CFLAGS += -Wno-sign-compare > >> > > # > >> > > KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > >> > > > >> > > +# Avoid indirect branches in kernel to deal with Spectre > >> > > +ifdef CONFIG_RETPOLINE > >> > > + RETPOLINE_CFLAGS += $(call > >> cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) > >> > > + ifneq ($(RETPOLINE_CFLAGS),) > >> > > + KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE > >> > > + else > >> > > + $(warning Retpoline not supported in compiler. System may > >> be insecure.) > >> > > + endif > >> > > +endif > >> > > >> > I wonder if an error might be more appropriate than a warning. I > >> > learned from experience that a lot of people don't see these Makefile > >> > warnings, and this would be a dangerous one to miss. > >> > > >> > Also if this were an error, you could get rid of the RETPOLINE define, > >> > and that would be one less define cluttering up the already > >> way-too-long > >> > GCC arg list. > >> > >> It still allows to get the ASM part covered. If that's worth it I can't > >> tell. > > > > If there's a makefile error above, then CONFIG_RETPOLINE would already > > imply compiler support, so the ASM code with the new '%V' option could > > just do 'ifdef CONFIG_RETPOLINE'. > > I did look at ditching the -DRETPOLINE but there is benefit in doing the > sys_call_table jump even when GCC isn't updated. So I put it back. What benefit is that? Doesn't it give the user a false sense of security, since there's no shortage of other indirect branches to attack? -- Josh