[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200416144815.GA3267283@rani.riverdale.lan>
Date: Thu, 16 Apr 2020 10:48:15 -0400
From: Arvind Sankar <nivedita@...m.mit.edu>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: Arvind Sankar <nivedita@...m.mit.edu>,
linux-efi <linux-efi@...r.kernel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
X86 ML <x86@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 5/5] efi/x86: Check for bad relocations
On Thu, Apr 16, 2020 at 09:38:36AM +0200, Ard Biesheuvel wrote:
> On Thu, 16 Apr 2020 at 00:15, Arvind Sankar <nivedita@...m.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@...m.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
Oops. I tested 64-bit but not 32-bit. I'll fix.
>
> > +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
Ok.
>
> > $(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?
Will do.
Powered by blists - more mailing lists