The patch titled Subject: module: allow symbol exports to be disabled has been added to the -mm tree. Its filename is module-allow-symbol-exports-to-be-disabled.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/module-allow-symbol-exports-to-be-disabled.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/module-allow-symbol-exports-to-be-disabled.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> Subject: module: allow symbol exports to be disabled 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. Link: http://lkml.kernel.org/r/20180704083651.24360-3-ard.biesheuvel@xxxxxxxxxx Signed-off-by: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> Acked-by: Nicolas Pitre <nico@xxxxxxxxxx> Acked-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Reviewed-by: Will Deacon <will.deacon@xxxxxxx> Acked-by: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> Cc: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: James Morris <james.morris@xxxxxxxxxxxxx> Cc: James Morris <jmorris@xxxxxxxxx> Cc: Jessica Yu <jeyu@xxxxxxxxxx> Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxx> Cc: Petr Mladek <pmladek@xxxxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: "Serge E. Hallyn" <serge@xxxxxxxxxx> Cc: Sergey Senozhatsky <sergey.senozhatsky@xxxxxxxxx> Cc: Steven Rostedt <rostedt@xxxxxxxxxxx> Cc: Thomas Garnier <thgarnie@xxxxxxxxxx> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- diff -puN arch/x86/boot/compressed/kaslr.c~module-allow-symbol-exports-to-be-disabled arch/x86/boot/compressed/kaslr.c --- a/arch/x86/boot/compressed/kaslr.c~module-allow-symbol-exports-to-be-disabled +++ a/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 -puN drivers/firmware/efi/libstub/Makefile~module-allow-symbol-exports-to-be-disabled drivers/firmware/efi/libstub/Makefile --- a/drivers/firmware/efi/libstub/Makefile~module-allow-symbol-exports-to-be-disabled +++ a/drivers/firmware/efi/libstub/Makefile @@ -20,7 +20,8 @@ cflags-$(CONFIG_EFI_ARMSTUB) += -I$(srct 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 -puN include/linux/export.h~module-allow-symbol-exports-to-be-disabled include/linux/export.h --- a/include/linux/export.h~module-allow-symbol-exports-to-be-disabled +++ a/include/linux/export.h @@ -66,7 +66,16 @@ extern struct module __this_module; __attribute__((section("___ksymtab" sec "+" #sym), used)) \ = { (unsigned long)&sym, __kstrtab_##sym } -#if defined(__KSYM_DEPS__) +#if defined(__DISABLE_EXPORTS) + +/* + * Allow symbol exports to be disabled completely so that C code may + * be reused in other execution contexts such as the UEFI stub or the + * decompressor. + */ +#define __EXPORT_SYMBOL(sym, sec) + +#elif defined(__KSYM_DEPS__) /* * For fine grained build dependencies, we want to tell the build system _ Patches currently in -mm which might be from ard.biesheuvel@xxxxxxxxxx are arch-enable-relative-relocations-for-arm64-power-and-x86.patch module-allow-symbol-exports-to-be-disabled.patch module-use-relative-references-for-__ksymtab-entries.patch init-allow-initcall-tables-to-be-emitted-using-relative-references.patch pci-add-support-for-relative-addressing-in-quirk-tables.patch kernel-tracepoints-add-support-for-relative-references.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html