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: <mhng-8a4a5f85-faf9-405c-95a0-78cd04ec6509@palmer-ri-x1c9>
Date: Fri, 12 Jan 2024 10:56:48 -0800 (PST)
From: Palmer Dabbelt <palmer@...osinc.com>
To: Ard Biesheuvel <ardb@...nel.org>
CC: jan.kiszka@...mens.com, linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject:     Re: [PATCH] riscv/efistub: Ensure GP-relative addressing is not used

On Fri, 12 Jan 2024 10:51:16 PST (-0800), Ard Biesheuvel wrote:
> Hi Jan,
>
> On Fri, 12 Jan 2024 at 19:37, Jan Kiszka <jan.kiszka@...mens.com> wrote:
>>
>> From: Jan Kiszka <jan.kiszka@...mens.com>
>>
>> The cflags for the RISC-V efistub were missing -mno-relax, thus were
>> under the risk that the compiler could use GP-relative addressing. That
>> happened for _edata with binutils-2.41 and kernel 6.1, causing the
>> relocation to fail due to an invalid kernel_size in handle_kernel_image.
>> It was not yet observed with newer versions, but that may just be luck.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@...mens.com>
>> ---
>>
>> Something like this should go to stable as well, but we will need
>> rebased patches.
>>
>>  drivers/firmware/efi/libstub/Makefile | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
>> index 06964a3c130f..d561d7de46a9 100644
>> --- a/drivers/firmware/efi/libstub/Makefile
>> +++ b/drivers/firmware/efi/libstub/Makefile
>> @@ -28,7 +28,7 @@ cflags-$(CONFIG_ARM)          += -DEFI_HAVE_STRLEN -DEFI_HAVE_STRNLEN \
>>                                    -DEFI_HAVE_MEMCHR -DEFI_HAVE_STRRCHR \
>>                                    -DEFI_HAVE_STRCMP -fno-builtin -fpic \
>>                                    $(call cc-option,-mno-single-pic-base)
>> -cflags-$(CONFIG_RISCV)         += -fpic -DNO_ALTERNATIVE
>> +cflags-$(CONFIG_RISCV)         += -fpic -DNO_ALTERNATIVE -mno-relax
>
> Can we detect the presence of these references (via the relocation
> type)? We already do something similar for ordinary absolute
> references too.

If there's no `__global_pointer$` symbol then the linker won't make 
GP-relative relaxations (because it doesn't know where GP is).  We 
usually define that symbol in the linker script, but I'm not entierly 
sure how libstub gets its linker script...

>
>>  cflags-$(CONFIG_LOONGARCH)     += -fpie
>>
>>  cflags-$(CONFIG_EFI_PARAMS_FROM_FDT)   += -I$(srctree)/scripts/dtc/libfdt
>> --
>> 2.35.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ