[Top] [All Lists]

Re: [PATCH v6 2/8] module: use relative references for __ksymtab entries

To: Ingo Molnar <>
Subject: Re: [PATCH v6 2/8] module: use relative references for __ksymtab entries
From: Ard Biesheuvel <>
Date: Thu, 28 Dec 2017 12:39:39 +0000
Cc: Linus Torvalds <>, Linux Kernel Mailing List <>, "H. Peter Anvin" <>, Ralf Baechle <>, Arnd Bergmann <>, Heiko Carstens <>, Kees Cook <>, Will Deacon <>, Michael Ellerman <>, Thomas Garnier <>, Thomas Gleixner <>, "Serge E. Hallyn" <>, Bjorn Helgaas <>, Benjamin Herrenschmidt <>, Russell King <>, Paul Mackerras <>, Catalin Marinas <>, "David S. Miller" <>, Petr Mladek <>, Ingo Molnar <>, James Morris <>, Andrew Morton <>, Nicolas Pitre <>, Josh Poimboeuf <>, Steven Rostedt <>, Martin Schwidefsky <>, Sergey Senozhatsky <>, Jessica Yu <>,, linux-mips <>, ppc-dev <>, linux-s390 <>,, "the arch/x86 maintainers" <>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hIwe1LDdr/D9/PBS9tuw3bdY92U2we5+suO7sAYdA5g=; b=MZNN8XJAPBPoUZc6XDWUsQbuQiGMc9qSQCVSq068UwRuiiqWFM48XJBXjLGXn32YWe XH47zNTpY6VD/bL1jmviFHuWBYovZ3EOgTezmb88bI3Bguxf/eoKgkwPJfhvtXRmKeXL qFr7EfHA8t11cndKSaVHPRaJV77v3jEAyWuw8=
In-reply-to: <>
List-archive: <>
List-help: <>
List-id: linux-mips <>
List-owner: <>
List-post: <>
List-software: Ecartis version 1.0.0
List-subscribe: <>
List-unsubscribe: <>
Original-recipient: rfc822;
References: <> <> <> <> <> <> <>
On 28 December 2017 at 12:05, Ingo Molnar <> wrote:
> * Ard Biesheuvel <> wrote:
>> Annoyingly, we need this because there is a single instance of a
>> special section that ends up in the EFI stub code: we build lib/sort.c
>> again as a EFI libstub object, and given that sort() is exported, we
>> end up with a ksymtab section in the EFI stub. The sort() thing has
>> caused issues before [0], so perhaps I should just clone sort.c into
>> drivers/firmware/efi/libstub and get rid of that hack.
>> [0] 
> If the root problem is early bootstrap code randomly using generic facility 
> that
> isn't __init, then we should definitely improve tooling to at least detect 
> these
> problems.
> As bootstrap code gets improved (KASLR, more complex decompression, etc. 
> etc.) we
> keep using new bits of generic facilities...
> So this should definitely not be hidden by open coding that function (which 
> has
> various other disadvantages as well), but should be turned from silent 
> breakage
> either into non-breakage (and do so not only for sort() but for other generic
> functions as well), or should be turned into a build failure.

We already have safeguards in place to ensure that the arm64 EFI stub
(which is essentially the same executable as the kernel proper) only
pulls in code that has been made available to it explicitly. That is
why sort.c is recompiled for the EFI stub, as well as all other C code
that is shared between the stub and the kernel. We also have a build
time check to ensure that the resulting code does not rely on absolute
symbol references, which will be invalid in the UEFI execution

So the only problem is that unneeded ksymtab/kcrctab sections, which
affected ARM for obscure reasons; typically, they just take up some
space. On x86, the kaslr code deals with a similar issue by
#define'ing _LINUX_EXPORT_H before including linux/export.h, which
also gets rid of these sections, but I was a bit reluctant to copy
that pattern. Perhaps we should enhance linux/export.h for reasons
such as these by adding a macro that nops out EXPORT_SYMBOL()

<Prev in Thread] Current Thread [Next in Thread>