lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210227043257.k3aernmnzsvitp7c@google.com>
Date:   Fri, 26 Feb 2021 20:32:57 -0800
From:   Fangrui Song <maskray@...gle.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     Arnd Bergmann <arnd@...nel.org>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>, Arnd Bergmann <arnd@...db.de>,
        Ard Biesheuvel <ardb@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Marc Zyngier <maz@...nel.org>,
        David Brazdil <dbrazdil@...gle.com>,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] arm64: vmlinux.lds.S: keep .entry.tramp.text section


On 2021-02-26, Kees Cook wrote:
>On Fri, Feb 26, 2021 at 03:03:39PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@...db.de>
>>
>> When building with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION,
>> I sometimes see an assertion
>>
>>  ld.lld: error: Entry trampoline text too big
>
>Heh, "too big" seems a weird report for having it discarded. :)
>
>Any idea on this Fangrui?
>
>( I see this is https://github.com/ClangBuiltLinux/linux/issues/1311 )

This diagnostic is from an ASSERT in arch/arm64/kernel/vmlinux.lds

   ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == (1 << 16),
    "Entry trampoline text too big")

In our case (aarch64-linux-gnu-ld or LLD, --gc-sections), all the input sections with this name
are discarded, so the output section is either absent (GNU ld) or empty (LLD).

KEEP  makes the sections GC roots, and it is appropriate to use here.


However, I worry that many other KEEP keywords in vmlinux.lds are unnecessary:
https://lore.kernel.org/linux-arm-kernel/20210226211323.arkvjnr4hifxapqu@google.com/

git log -S KEEP -- include/asm-generic/vmlinux.lds.h => there is quite a
bit unjustified usage. Sure, adding KEEP (GC root) is easy and
works around problems, but it not good for CONFIG_LD_DEAD_CODE_DATA_ELIMINATION.

Reviewed-by: Fangrui Song <maskray@...gle.com>

>

>>
>> This happens when any reference to the trampoline is discarded at link
>> time. Marking the section as KEEP() avoids the assertion, but I have
>> not figured out whether this is the correct solution for the underlying
>> problem.
>>
>> Signed-off-by: Arnd Bergmann <arnd@...db.de>
>
>As a work-around, it seems fine to me.
>
>Reviewed-by: Kees Cook <keescook@...omium.org>
>
>-Kees
>
>> ---
>>  arch/arm64/kernel/vmlinux.lds.S | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S
>> index 926cdb597a45..c5ee9d5842db 100644
>> --- a/arch/arm64/kernel/vmlinux.lds.S
>> +++ b/arch/arm64/kernel/vmlinux.lds.S
>> @@ -96,7 +96,7 @@ jiffies = jiffies_64;
>>  #define TRAMP_TEXT					\
>>  	. = ALIGN(PAGE_SIZE);				\
>>  	__entry_tramp_text_start = .;			\
>> -	*(.entry.tramp.text)				\
>> +	KEEP(*(.entry.tramp.text))			\
>>  	. = ALIGN(PAGE_SIZE);				\
>>  	__entry_tramp_text_end = .;
>>  #else
>> --
>> 2.29.2
>>
>
>-- 
>Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ