Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2963513ybv; Mon, 24 Feb 2020 15:22:43 -0800 (PST) X-Google-Smtp-Source: APXvYqyjuj8nXyhwuBnjDqu73CXJw9R1Xi7hzDFoT71gUUtMWX7hFg+sBoNoZ3TcUW+sxrcE5ykh X-Received: by 2002:a9d:64d8:: with SMTP id n24mr39476294otl.71.1582586563052; Mon, 24 Feb 2020 15:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582586563; cv=none; d=google.com; s=arc-20160816; b=gMGQcrXuXll3pNgZlYNLvn1OZ0iIMohO68e88hk9/x+c1yiW4GtrPwwt5/dD/OrFYi 3lB5yS8L2r/gKlaHzQvz8fnyMGgaGiF9WhRYTHNUCQ/0J2ohfrrAMEyqesjJ/pJOEdrg jOKgbO8oVVJDaKK8LY7pMAzeFuYVzTAUmHl54usOjO+Bl/gltMBDC1Pw4y402uUE+sj+ PCyuvpTZFutZ9kLqTg0j95QUHimuPqm3bIAD022aeLfwVzcCwR8YawG8Gh7idcMmX8yU 6E0yES0+DOz+tJGNuqfvGEyg7CtYtIA3LOeFko/aWi7ZgnUPrMXwKSqx4o+qTRFIsO4s D2nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=8qgdvNENjdppslkpYoe+OSQTy4MavzCmuXPJ3KTJBw0=; b=hpW59bib5ZSDb7U6k6T5vFtvITYYTQI1u129pdn43S37qx3RiqDqMTnbP+ohqx6waI XRAi2VsntIRPxlHvL1WjiqfnpxGPlLCEwoT3D9/s5mTCsrxELf03yeIBxZoNVDbzgfoF KewQq6l5F6H/O0rIuiDjxY1F8/AEjqdDMI70gKymlf6ZRDrASoLTEvsq2UitAVNlwJjj G67bkJdXXArbsVlun54hOz4TKWgt0fgIp/BtMWs/it1zyajcoQxxDVEKbLbUrEcS/0+p AYhjHkY7F7uIibXU9azwf8TPngWHtb/IIdsWJRLyhqaOTwCwf/ak/sXJmKwrSmWkPTHx nySQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21si1607426otp.189.2020.02.24.15.22.30; Mon, 24 Feb 2020 15:22:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728430AbgBXXVd (ORCPT + 99 others); Mon, 24 Feb 2020 18:21:33 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:42535 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727960AbgBXXVd (ORCPT ); Mon, 24 Feb 2020 18:21:33 -0500 Received: by mail-qv1-f67.google.com with SMTP id dc14so4916123qvb.9 for ; Mon, 24 Feb 2020 15:21:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8qgdvNENjdppslkpYoe+OSQTy4MavzCmuXPJ3KTJBw0=; b=eBST/fs+fCe9gKckuo0Rcp0KtSuTiZvs5aJSRzHUOPdiWkWkOw34ODZcia458ZEt/O GG0SIP030dxjC9/h2HNhIy2h9Gz8CQ15I+eT3rkwuBAatMLqekvNxcz8Iuye/GDaONqg 47wUWEUMdboYJlU3cMtnMsmZeBRZEDktW1/kIEJv3lej/RvvTcyq2uNi43N8jGAsUB5/ PyZn1l0g/J6Rg712zihSi9ZhGcFMNldwtmzcqclV+IquL53AN7sHmQsZ/AjGyhVBoLDu er+IdWD1hTy+3daVbrOikWeWaUxEJmfn4VffuWu7nkr4xLQ1YU0ykaq9SaKXEZFgRisB Wp+Q== X-Gm-Message-State: APjAAAWrD8WwCJvc0LUx5KwWvZS+PJGsA42j1MCcvzIS87o025gSeAl2 RhIg+AxeIHsLvc8nPjN5z28= X-Received: by 2002:a0c:ab13:: with SMTP id h19mr46293624qvb.243.1582586491902; Mon, 24 Feb 2020 15:21:31 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id 202sm3757849qkg.132.2020.02.24.15.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 15:21:31 -0800 (PST) From: Arvind Sankar To: Nick Desaulniers Cc: Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, LKML , clang-built-linux , Michael Matz , Fangrui Song , Kees Cook , Andy Lutomirski Subject: [PATCH v2 1/2] arch/x86: Use -fno-asynchronous-unwind-tables to suppress .eh_frame sections Date: Mon, 24 Feb 2020 18:21:28 -0500 Message-Id: <20200224232129.597160-2-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.24.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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