Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1648242ybv; Sun, 23 Feb 2020 11:37:49 -0800 (PST) X-Google-Smtp-Source: APXvYqyRNGzEUVNKv3Y3dYmPC//fmmvVbLQOkanbrN+XFEPODOLt1sE/pV9fSAW25tZZS7xhq+Hv X-Received: by 2002:a9d:de9:: with SMTP id 96mr37445206ots.222.1582486669718; Sun, 23 Feb 2020 11:37:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582486669; cv=none; d=google.com; s=arc-20160816; b=E99/bnF2ch7vdqxhJZfeb8H/6/B9Q/ld14m4TMu+2p8l5bbmeCiNSbwvaJGjRsOA3W HwqjdEUXYVxK0NrcUn/yIHJcefhlLjFlX8+aE15FynkqQkIIWGbShywH1IG4RP0P5U2m 5PQ7m7rCztFH8Sv1b9s1IjHuZp7uvS6qWzmEY6bgCJwTO/xJVtsrmp78HkiUJz2qDvWB ceR6QqZuQoomd37B780dgj6zHobeJKJMwZXXnxYCx/ACF1Eggm+2dQZvWksTHfQI6jx7 6KaT+vDI4EUHn51dlXFVkb9DbDrl6JIeYP9AKHR+WNORLOUIDqdJM6R+X0ATo9VMZH3N B9dg== 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=cEqZetVwvI2it6nvaADA132WipCDJGbaWa0sBBWu69cXrKD6ZoFUZ+73GUmtVbfRL4 MKLqwu+qZ8Qlqx1tfp/dv3jFdlgmR8oJ3rbaKZgQn4IHLr8QXsSGqkcki4+izBBRBntW qAh/bZ25SyLQDStA4bH52rvX8smb4P7XBdy5HDSHOfJlW7zK4EFIrtrIsH8RlDzeWhuN EVyp8nzsKCi9EpKqqmCYw20NblNZAonnQ8+Twj/Yto9u35RZLB/FTi3Ju3yK55WA2Afl ffJX398bKf2AJPEKsSl/6rt+6ubDI0et+hKO6p2IZd4NJtkM3KcSrq6vJb4HcdP9u0Ud 9VQg== 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 h22si3493405oie.189.2020.02.23.11.37.38; Sun, 23 Feb 2020 11:37:49 -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 S1727177AbgBWThU (ORCPT + 99 others); Sun, 23 Feb 2020 14:37:20 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:33081 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727151AbgBWThT (ORCPT ); Sun, 23 Feb 2020 14:37:19 -0500 Received: by mail-qk1-f194.google.com with SMTP id h4so6958148qkm.0 for ; Sun, 23 Feb 2020 11:37:18 -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=bu676Uj4uzw2XkgR0F7083kHfq6ehxN9nbFqo3oCGIr9mTYPlrc72VlGzFKSmo13G9 YasNnJ54P7QtqE9ztO2IIVVQ1XnPyTpCUJ0C6esKMXJRkAromo9YGl0pn4HblIM4P9RY am+ueI4xMyphs5NAc6hgIW8loUZdSMl79wFoORpI6T0R3aeBYAiPgOJPMVnBXe/yIm2c +UZZkIK0avvx/EKfkCcVd3R7IbnRgewhywrnGabRhbCUsUo61RYIQTnJZQXQ7MJsztbt C99Zkx4vQuv0klqY2M4MI8piVqtBTnLcH1Y9oodJFtZtbuUPKo+QBick3uO3Uq1oetxz 3VpQ== X-Gm-Message-State: APjAAAWL284XkcT3FIXLJt/xkex7ct8FxaavD49GurjOQcBeSQkCuNY7 7Ng3FFMhz2mPT5hBTKwWsYc= X-Received: by 2002:a05:620a:2185:: with SMTP id g5mr2098240qka.4.1582486638325; Sun, 23 Feb 2020 11:37:18 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id 204sm4780976qkg.74.2020.02.23.11.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Feb 2020 11:37:18 -0800 (PST) From: Arvind Sankar To: Arvind Sankar Cc: Nick Desaulniers , Borislav Petkov , Nathan Chancellor , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Michael Matz , Fangrui Song , Kees Cook Subject: [PATCH 1/2] arch/x86: Use -fno-asynchronous-unwind-tables to suppress .eh_frame sections Date: Sun, 23 Feb 2020 14:37:14 -0500 Message-Id: <20200223193715.83729-2-nivedita@alum.mit.edu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200222235709.GA3786197@rani.riverdale.lan> References: <20200222235709.GA3786197@rani.riverdale.lan> 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