Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3189941ybv; Mon, 24 Feb 2020 20:12:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyKGycXLgA/21bJRT3ajBFglu0IwCPdF2RQNs8NYyCp9nTydcMIx9kwlPJdLXUdBmCzuNO4 X-Received: by 2002:aca:e084:: with SMTP id x126mr1886851oig.97.1582603926299; Mon, 24 Feb 2020 20:12:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582603926; cv=none; d=google.com; s=arc-20160816; b=t3mX/xYYCCYEvVxegJTksJEqpgbUXe5RIzXqDNzlSJAn08cnBXkWobkM8fVgdreGUq 6P9wClsfFX/Oo7aIPOBJYb73o6r+hbwZMCra5KbqZ60JWubPbTHsEl1uWSItr1rbRZBY 2pfmP5TEmxWLikIYec9acGk7L/o2pp62+OHhK/2yIPj4ZODaQb9afLapDX5XP77TNsh1 852s+5ic7SSjlhkTJXch8u8BKhPIWKOm21R4sW3AoDiOl2amORLN9Jc43A0/pNLTicll 13BxUGgidY8YpyvzsIJ1Ymi9SG6c7i7NaryhHErfioRx9LocmQabtLlax4TXYtb9mzHa SsFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Vusshdc55krHefiBaqz9JgK7J4GXTO3PHrFYufBJIy8=; b=WXJTfdCFkN1qA4FVpq7Bvv0LWI5LK14KMm8rw8mMX2AyciOOqNpkXwH67a9fmdzyIY dASIwuW2XBLbW2RG6onb74a1J7Ril3qTyLVxQc9UnCiW3d4bFTWCQX8j/Hv1aXoAmRMf XUtBtLdRBIqclucL9P4/Fn3Yl9n5RJbUJhdOMWV5MrgA0vvwjOdt4fCPDhYYOlNIqlbC CUUu2df0uVv0mN+A/A+bACOTkFm75EmWa4O53dio6KUlNjdtf1AfzuXLdTrPoDPvLGX4 j8z+Ckedez834mKOvLjXWeMGlTGo5PbPB4Z+XLxut9EQGobbn/7REMZ24I+yHfg0tVYg E2jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LVqXzB6A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e1si7432998otr.8.2020.02.24.20.11.54; Mon, 24 Feb 2020 20:12:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LVqXzB6A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728910AbgBYEKQ (ORCPT + 99 others); Mon, 24 Feb 2020 23:10:16 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46006 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728725AbgBYEKQ (ORCPT ); Mon, 24 Feb 2020 23:10:16 -0500 Received: by mail-pg1-f194.google.com with SMTP id r77so2828846pgr.12 for ; Mon, 24 Feb 2020 20:10:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Vusshdc55krHefiBaqz9JgK7J4GXTO3PHrFYufBJIy8=; b=LVqXzB6A+JGJPJqEKhZBJWn4eYCob5Nq9+y4QHTqsa3h7PUNHjF/T47O5j1eadLhss OAWHrHsfUIRgdGSum6yPmaAHSuaoLnREsztkvFNZovYtniDt/ENe/GoUSeRSJ8ZippC+ H2a+Hr+tQgMuKTHTIay62rAK0p5X3/cCjQqZs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Vusshdc55krHefiBaqz9JgK7J4GXTO3PHrFYufBJIy8=; b=k9gOwzhvRzBTP3CHCVVllEX2Lvo1ak63gy0jwzMyLH5aqvpWrxpzh/Rz4Svk92+ZFu LtQkOHXYrkTpLRS3zxmamKewH9uxPoywhp8J/wRqdjaRP/yiJ/ZOp2F5J6IfXTGPCwog Nta7utte9vEwQO3X2Ar2VEBjjzynmfikQRfai/R+eJ134gVXTTxmhgDzRZI+0ENxvhkt UKxvGHwiJJlO70hpgiUs3YO1I3n3vThgJc9fT2Ku4RDVRyWrHjVU45LCBniUcmoi/XAO 2r3cpHxQ2oDXb8MM9VKPjHyWE03w8FVvYkHVZ4cCBE1OokvAYWHNlZX8RuKsX9tzrwIa 2sxQ== X-Gm-Message-State: APjAAAWQ+1/PIGylPe2Vg5EiKluH2W1tOby3tJLx3+t3it6wGc8o8y7C ncBV3KlYQabj/Vxzb4VYxdwhyQ== X-Received: by 2002:aa7:8804:: with SMTP id c4mr56003796pfo.214.1582603814922; Mon, 24 Feb 2020 20:10:14 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id z30sm14679470pff.131.2020.02.24.20.10.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 20:10:14 -0800 (PST) Date: Mon, 24 Feb 2020 20:10:12 -0800 From: Kees Cook To: Arvind Sankar Cc: Nick Desaulniers , Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, LKML , clang-built-linux , Michael Matz , Fangrui Song , Andy Lutomirski Subject: Re: [PATCH v2 1/2] arch/x86: Use -fno-asynchronous-unwind-tables to suppress .eh_frame sections Message-ID: <202002242009.43E8DFD58@keescook> References: <20200224232129.597160-2-nivedita@alum.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200224232129.597160-2-nivedita@alum.mit.edu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 24, 2020 at 06:21:28PM -0500, Arvind Sankar wrote: > While discussing a patch to discard .eh_frame from the compressed > vmlinux using the linker script, Fangrui Song pointed out [1] that these > sections shouldn't exist in the first place because arch/x86/Makefile > uses -fno-asynchronous-unwind-tables. > > It turns out this is because the Makefiles used to build the compressed > kernel redefine KBUILD_CFLAGS, dropping this flag. > > Add the flag to the Makefile for the compressed kernel, as well as the > EFI stub Makefile to fix this. > > Also add the flag to boot/Makefile and realmode/rm/Makefile so that the > kernel's boot code (boot/setup.elf) and realmode trampoline > (realmode/rm/realmode.elf) won't be compiled with .eh_frame sections, > since their linker scripts also just discard it. > > Signed-off-by: Arvind Sankar Thanks for sorting this out. I think it's much cleaner than adding it to DISCARD. :) Reviewed-by: Kees Cook -Kees > Suggested-By: Fangrui Song > [1] https://lore.kernel.org/lkml/20200222185806.ywnqhfqmy67akfsa@google.com/ > --- > arch/x86/boot/Makefile | 1 + > arch/x86/boot/compressed/Makefile | 1 + > arch/x86/realmode/rm/Makefile | 1 + > drivers/firmware/efi/libstub/Makefile | 3 ++- > 4 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile > index 012b82fc8617..24f011e0adf1 100644 > --- a/arch/x86/boot/Makefile > +++ b/arch/x86/boot/Makefile > @@ -68,6 +68,7 @@ clean-files += cpustr.h > KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) > +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > GCOV_PROFILE := n > UBSAN_SANITIZE := n > > diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile > index 26050ae0b27e..c33111341325 100644 > --- a/arch/x86/boot/compressed/Makefile > +++ b/arch/x86/boot/compressed/Makefile > @@ -39,6 +39,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) > KBUILD_CFLAGS += $(call cc-disable-warning, gnu) > KBUILD_CFLAGS += -Wno-pointer-sign > KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) > +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > GCOV_PROFILE := n > diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile > index 99b6332ba540..b11ec5d8f8ac 100644 > --- a/arch/x86/realmode/rm/Makefile > +++ b/arch/x86/realmode/rm/Makefile > @@ -71,5 +71,6 @@ $(obj)/realmode.relocs: $(obj)/realmode.elf FORCE > KBUILD_CFLAGS := $(REALMODE_CFLAGS) -D_SETUP -D_WAKEUP \ > -I$(srctree)/arch/x86/boot > KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ > +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables > GCOV_PROFILE := n > UBSAN_SANITIZE := n > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index 98a81576213d..a1140c4ee478 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -12,7 +12,8 @@ cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \ > -mno-mmx -mno-sse -fshort-wchar \ > -Wno-pointer-sign \ > $(call cc-disable-warning, address-of-packed-member) \ > - $(call cc-disable-warning, gnu) > + $(call cc-disable-warning, gnu) \ > + -fno-asynchronous-unwind-tables > > # arm64 uses the full KBUILD_CFLAGS so it's necessary to explicitly > # disable the stackleak plugin > -- > 2.24.1 > -- Kees Cook