linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: Arvind Sankar <nivedita@alum.mit.edu>
Cc: linux-efi <linux-efi@vger.kernel.org>, X86 ML <x86@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 5/5] efi/x86: Check for bad relocations
Date: Thu, 16 Apr 2020 09:38:36 +0200	[thread overview]
Message-ID: <CAMj1kXFMMeYUPirY10JJfs31Z5GnHvUe=gLgG6SUJY9uWj588g@mail.gmail.com> (raw)
In-Reply-To: <20200415221520.2692512-6-nivedita@alum.mit.edu>

On Thu, 16 Apr 2020 at 00:15, Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> Add relocation checking for x86 as well to catch non-PC-relative
> relocations that require runtime processing, since the EFI stub does not
> do any runtime relocation processing.
>
> This will catch, for example, data relocations created by static
> initializers of pointers.
>
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
> ---
>  drivers/firmware/efi/libstub/Makefile | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index 0bb2916eb12b..2aff59812a54 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -96,6 +96,8 @@ STUBCOPY_RELOC-$(CONFIG_ARM)  := R_ARM_ABS
>  # .bss section here so it's easy to pick out in the linker script.
>  #
>  STUBCOPY_FLAGS-$(CONFIG_X86)   += --rename-section .bss=.bss.efistub,load,alloc
> +STUBCOPY_RELOC-$(CONFIG_X86_32) := 'R_X86_32_(8|16|32)'

This should be R_386_xxx

> +STUBCOPY_RELOC-$(CONFIG_X86_64) := 'R_X86_64_(8|16|32|32S|64)'
>

... and in general, I think we only need the native pointer sized ones, so

R_386_32
R_X86_64_64

>  $(obj)/%.stub.o: $(obj)/%.o FORCE
>         $(call if_changed,stubcopy)
> @@ -107,16 +109,14 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
>  # this time, use objcopy and leave all sections in place.
>  #
>
> -cmd_stubrelocs_check-y = /bin/true
> -
> -cmd_stubrelocs_check-$(CONFIG_EFI_ARMSTUB) =                           \
> +cmd_stubrelocs_check =                                                 \
>         $(STRIP) --strip-debug -o $@ $<;                                \
> -       if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); then            \
> +       if $(OBJDUMP) -r $@ | grep -E $(STUBCOPY_RELOC-y); then         \

... which means we don't need to -E either

>                 echo "$@: absolute symbol references not allowed in the EFI stub" >&2; \
>                 /bin/false;                                             \
>         fi
>
>  quiet_cmd_stubcopy = STUBCPY $@
>        cmd_stubcopy =                                                   \
> -       $(cmd_stubrelocs_check-y);                                      \
> +       $(cmd_stubrelocs_check);                                        \
>         $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@
> --
> 2.24.1
>

Could we fold this into the previous x86 patch, and drop the one that
splits off the relocation check from stubcpy?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-04-16  7:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 22:15 [PATCH 0/5] efi: Remove __efistub_global annotation Arvind Sankar
2020-04-15 22:15 ` [PATCH 1/5] efi/arm: " Arvind Sankar
2020-04-16  7:50   ` Ard Biesheuvel
2020-04-15 22:15 ` [PATCH 2/5] efi/libstub: Factor out relocation checking Arvind Sankar
2020-04-15 22:15 ` [PATCH 3/5] efi/x86: Remove __efistub_global annotation Arvind Sankar
2020-04-16  7:51   ` Ard Biesheuvel
2020-04-15 22:15 ` [PATCH 4/5] efi: Kill __efistub_global Arvind Sankar
2020-04-16  7:51   ` Ard Biesheuvel
2020-04-15 22:15 ` [PATCH 5/5] efi/x86: Check for bad relocations Arvind Sankar
2020-04-16  7:38   ` Ard Biesheuvel [this message]
2020-04-16 14:48     ` Arvind Sankar
2020-04-16 15:12 ` [PATCH v2 0/3] efi: Remove __efistub_global annotation Arvind Sankar
2020-04-16 16:01   ` Ard Biesheuvel
2020-04-16 15:12 ` [PATCH v2 1/3] efi/arm: " Arvind Sankar
2020-04-16 15:12 ` [PATCH v2 2/3] efi/x86: Remove __efistub_global and add relocation check Arvind Sankar
2020-04-16 15:12 ` [PATCH v2 3/3] efi: Kill __efistub_global Arvind Sankar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMj1kXFMMeYUPirY10JJfs31Z5GnHvUe=gLgG6SUJY9uWj588g@mail.gmail.com' \
    --to=ardb@kernel.org \
    --cc=bp@alien8.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nivedita@alum.mit.edu \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).