From patchwork Thu Dec 28 13:06:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 122840 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3427964qgn; Thu, 28 Dec 2017 05:07:16 -0800 (PST) X-Google-Smtp-Source: ACJfBotITG9oC2dXFh5Jp80+djrxOeSt/J8EbLLmjqOk5DLHuOZe5vNPvras1tnndVsM1XxBi3eQ X-Received: by 10.98.89.4 with SMTP id n4mr31504669pfb.133.1514466436893; Thu, 28 Dec 2017 05:07:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514466436; cv=none; d=google.com; s=arc-20160816; b=Ab29O82QTcjvFojTefBAtNuRqbhQDLsD+9KJs+IIkA761Sj4J0NpfObgG7J9UUWaD2 NYfyNU4g7Byi8GY5/bgiWVORH1Ml5k86Vs2I6M9GefCVAxDmu8MCp6ov9uDgjTfBJZxN BNA/vWj6jeVQsb/gLvVekubtHa4AIxXP3M70rh9mFRVMsXaYjTpOHRTZ61zQ7AyJnDns g3Pa3mwE3uhqRGTdYSCWYbHkpquPAuKsIA4scHb61Lys31jnxsQVlyrHCK0ebWPLFpVH Zd8yjGVUrFsAVAhGMCPSbHwKulUZKEz6RpSsG4x4zsjkpobfdElQBxPpaoQzy7wbPYYA lHWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=/56vHXRVjlswU790OhryF7v3GSYAwEH62hWnEZpPC4Q=; b=a6wUXjAireBGTxtFtbGvBKhVprE4UCN7+qJI5AXj26CWhFeylY585pzvntgCnK0qHC yQjzOO/+0i6VMVgySNpCKdA08bpc2acATEjMAsMaDWJcFRmEC2Y6p0t11X20ynDh9MUN i+DIJgoQh0hrt1OndhzdxnJ61y2/mxUQ7x8gxdqH/FBrF43C2I1SJhlRa5Kyar9Ck+zg qmUqbiaDGo6YTQVFo3lw97Mx5xq4/rFLy/TuEFfiqb3y4Vy9GqEDN7rZ72w6WbaDwkWy I+xPrYyNelqvqd+B4GkTZj7l60r52J6/ctPGKKYCQ0JnsMfoywrnmWhe3gJf/yzqyCnn SFCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=h+VjjYjB; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x33si26516721plb.406.2017.12.28.05.07.16; Thu, 28 Dec 2017 05:07:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=h+VjjYjB; spf=pass (google.com: best guess record for domain of linux-efi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-efi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753335AbdL1NHQ (ORCPT + 2 others); Thu, 28 Dec 2017 08:07:16 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:45755 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751431AbdL1NHP (ORCPT ); Thu, 28 Dec 2017 08:07:15 -0500 Received: by mail-wr0-f194.google.com with SMTP id o15so6972004wrf.12 for ; Thu, 28 Dec 2017 05:07:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=n40ZPrrm4HWRq6liSSxXq8RnNr4BWj+C7tWMUOILM6w=; b=h+VjjYjBzlx4gLLWInwtPVol96V27vkFBCBJrvIi3cgE6C5UlmdnDrM5djv3bcDsWY YH/kYCsKWsQgkjAtYj6RzArQCMDu0L5XKNKPjiq9eW8+fBt99p62IcGSFcUUB/Bh/M+I wxhQCGw3+0B389Y69/dy9V7KA4lpBKkzPPIeM= 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; bh=n40ZPrrm4HWRq6liSSxXq8RnNr4BWj+C7tWMUOILM6w=; b=oyMWP38H21cH8FBL7kzNDM+0wrSEGS1Yy4y0jBvDkYh1+yaQSjAVSLPl22qOzBefXX L/PXeO5+eA0scgvech4u4ESIIM8xTicjOYJzTjO9bH0tcFr6nXYEGnxyWVYRY07yMk+c XoC9HNNBK3DBxPvjoSSlLbVh3uNYV4Nl++RCWTB3sjv+/QBdnR0T9EBTTfdlf35U8WJF UGaHxE6v6zq0vN5Rxb0Appn6tl0PY2PCleNoSTdJDFQ7CXnVWAmIpsadLwFs+uLowv3P 4Gj0fZ0jjykcp17uT12nVDPGmhJR/F1E7x/7LWuDoGOBNcHjVlyuJ66d4a71h1HoVxVY TXlA== X-Gm-Message-State: AKGB3mIjpmqmCAuVJNf8Apng2Y9CRJd8eMypZMgHhQKD1LuDHSLNm6Gz Mswrva+QPqWzheC7Dc2/L5ewfQ== X-Received: by 10.223.163.76 with SMTP id d12mr27000086wrb.85.1514466434214; Thu, 28 Dec 2017 05:07:14 -0800 (PST) Received: from localhost.localdomain ([105.137.110.132]) by smtp.gmail.com with ESMTPSA id p90sm37216816wrb.28.2017.12.28.05.07.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Dec 2017 05:07:13 -0800 (PST) From: Ard Biesheuvel To: hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org Cc: matt@codeblueprint.co.uk, linux-efi@vger.kernel.org, keescook@chromium.org, jeyu@kernel.org, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, Ard Biesheuvel Subject: [PATCH] module: allow symbol exports to be disabled Date: Thu, 28 Dec 2017 13:06:58 +0000 Message-Id: <20171228130658.20277-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org To allow existing C code to be incorporated into the decompressor or the UEFI stub, introduce a CPP macro that turns all EXPORT_SYMBOL_xxx declarations into nops, and #define it in places where such exports are undesirable. Note that this gets rid of a rather dodgy redefine of linux/export.h's header guard. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/kaslr.c | 5 +---- drivers/firmware/efi/libstub/Makefile | 3 ++- include/linux/export.h | 9 +++++++++ 3 files changed, 12 insertions(+), 5 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-efi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 8199a6187251..3a2a6d7049e4 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -23,11 +23,8 @@ * _ctype[] in lib/ctype.c is needed by isspace() of linux/ctype.h. * While both lib/ctype.c and lib/cmdline.c will bring EXPORT_SYMBOL * which is meaningless and will cause compiling error in some cases. - * So do not include linux/export.h and define EXPORT_SYMBOL(sym) - * as empty. */ -#define _LINUX_EXPORT_H -#define EXPORT_SYMBOL(sym) +#define __DISABLE_EXPORTS #include "misc.h" #include "error.h" diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index adaa4a964f0c..312bd0b64a61 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -20,7 +20,8 @@ cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srctree)/scripts/dtc/libfdt KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \ -D__NO_FORTIFY \ $(call cc-option,-ffreestanding) \ - $(call cc-option,-fno-stack-protector) + $(call cc-option,-fno-stack-protector) \ + -D__DISABLE_EXPORTS GCOV_PROFILE := n KASAN_SANITIZE := n diff --git a/include/linux/export.h b/include/linux/export.h index 5112d0c41512..0a46d2176555 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -107,6 +107,15 @@ struct kernel_symbol { */ #define __EXPORT_SYMBOL(sym, sec) === __KSYM_##sym === +#elif defined(__DISABLE_EXPORTS) + +/* + * Allow symbol exports to be disabled completely so that C code that may + * be reused in other execution contexts such as the UEFI stub or the + * decompressor. + */ +#define __EXPORT_SYMBOL(sym, sec) + #elif defined(CONFIG_TRIM_UNUSED_KSYMS) #include