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]
Date:   Wed, 1 Mar 2023 17:44:04 +0800
From:   Huacai Chen <chenhuacai@...nel.org>
To:     Ard Biesheuvel <ardb@...nel.org>
Cc:     Huacai Chen <chenhuacai@...ngson.cn>, linux-efi@...r.kernel.org,
        loongarch@...ts.linux.dev, Xuefeng Li <lixuefeng@...ngson.cn>,
        Xuerui Wang <kernel@...0n.name>, linux-kernel@...r.kernel.org,
        loongson-kernel@...ts.loongnix.cn
Subject: Re: [PATCH] efi/loongarch: Reintroduce efi_relocate_kernel() to
 relocate kernel

Hi, Ard,

On Wed, Mar 1, 2023 at 5:17 PM Ard Biesheuvel <ardb@...nel.org> wrote:
>
> On Wed, 1 Mar 2023 at 09:55, Huacai Chen <chenhuacai@...ngson.cn> wrote:
> >
> > Since Linux-6.3, LoongArch supports PIE kernel now, so let's reintroduce
> > efi_relocate_kernel() to relocate the core kernel.
> >
>
> Nice!
>
> I assume you will need to make a similar change for zboot?
zboot is always PIE (even before 6.3), so I suppose we don't need to
do anything?

Huacai
>
> > Signed-off-by: Huacai Chen <chenhuacai@...ngson.cn>
> > ---
> >  drivers/firmware/efi/libstub/loongarch-stub.c | 24 ++++++-------------
> >  1 file changed, 7 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/firmware/efi/libstub/loongarch-stub.c b/drivers/firmware/efi/libstub/loongarch-stub.c
> > index eee7ed43cdfb..72c71ae201f0 100644
> > --- a/drivers/firmware/efi/libstub/loongarch-stub.c
> > +++ b/drivers/firmware/efi/libstub/loongarch-stub.c
> > @@ -21,26 +21,16 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
> >                                  efi_loaded_image_t *image,
> >                                  efi_handle_t image_handle)
> >  {
> > -       int nr_pages = round_up(kernel_asize, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE;
> > -       efi_physical_addr_t kernel_addr = EFI_KIMG_PREFERRED_ADDRESS;
> >         efi_status_t status;
> > +       unsigned long kernel_addr = 0;
> >
> > -       /*
> > -        * Allocate space for the kernel image at the preferred offset. This is
> > -        * the only location in memory from where we can execute the image, so
> > -        * no point in falling back to another allocation.
> > -        */
> > -       status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
> > -                            EFI_LOADER_DATA, nr_pages, &kernel_addr);
> > -       if (status != EFI_SUCCESS)
> > -               return status;
> > -
> > -       *image_addr = EFI_KIMG_PREFERRED_ADDRESS;
> > -       *image_size = kernel_asize;
> > +       kernel_addr = (unsigned long)&kernel_offset - kernel_offset;
> > +
> > +       status = efi_relocate_kernel(&kernel_addr, kernel_fsize, kernel_asize,
> > +                    EFI_KIMG_PREFERRED_ADDRESS, efi_get_kimg_min_align(), 0x0);
> >
> > -       memcpy((void *)EFI_KIMG_PREFERRED_ADDRESS,
> > -              (void *)&kernel_offset - kernel_offset,
> > -              kernel_fsize);
> > +       *image_addr = kernel_addr;
> > +       *image_size = kernel_asize;
> >
> >         return status;
> >  }
> > --
> > 2.39.1
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ