linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
@ 2020-05-20 18:20 Fangrui Song
  2020-05-20 19:19 ` Arvind Sankar
  2020-05-22  2:42 ` Kees Cook
  0 siblings, 2 replies; 7+ messages in thread
From: Fangrui Song @ 2020-05-20 18:20 UTC (permalink / raw)
  To: x86, Arvind Sankar, linux-efi
  Cc: clang-built-linux, Nick Desaulniers, Ard Biesheuvel,
	Fangrui Song, kbuild test robot

In the latest efi tree, ce5e3f909fc0ed67e58367b9c56a54c20a51080b
"efi/printf: Add 64-bit and 8-bit integer support",
arch/x86/boot/compressed/vmlinux may have an undesired
.discard.unreachable section from drivers/firmware/efi/libstub/vsprintf.stub.o

.discard.unreachable contains an R_X86_64_PC32 relocation, which will be
warned by LLD: a non-SHF_ALLOC section (.discard.unreachable) is not
part of the memory image, thus conceptually the distance between a
non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
link time.

% ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''

Reuse the DISCARDS macro which includes .discard.* to drop .discard.unreachable

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Fangrui Song <maskray@google.com>
---
 arch/x86/boot/compressed/vmlinux.lds.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S
index 0dc5c2b9614b..8f1025d1f681 100644
--- a/arch/x86/boot/compressed/vmlinux.lds.S
+++ b/arch/x86/boot/compressed/vmlinux.lds.S
@@ -74,4 +74,6 @@ SECTIONS
 #endif
 	. = ALIGN(PAGE_SIZE);	/* keep ZO size page aligned */
 	_end = .;
+
+	DISCARDS
 }
-- 
2.26.2.761.g0e0b3e54be-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
  2020-05-20 18:20 [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux Fangrui Song
@ 2020-05-20 19:19 ` Arvind Sankar
  2020-05-22  2:42 ` Kees Cook
  1 sibling, 0 replies; 7+ messages in thread
From: Arvind Sankar @ 2020-05-20 19:19 UTC (permalink / raw)
  To: Fangrui Song
  Cc: x86, Arvind Sankar, linux-efi, clang-built-linux,
	Nick Desaulniers, Ard Biesheuvel, kbuild test robot

On Wed, May 20, 2020 at 11:20:10AM -0700, Fangrui Song wrote:
> In the latest efi tree, ce5e3f909fc0ed67e58367b9c56a54c20a51080b
> "efi/printf: Add 64-bit and 8-bit integer support",
> arch/x86/boot/compressed/vmlinux may have an undesired
> .discard.unreachable section from drivers/firmware/efi/libstub/vsprintf.stub.o
> 
> .discard.unreachable contains an R_X86_64_PC32 relocation, which will be
> warned by LLD: a non-SHF_ALLOC section (.discard.unreachable) is not
> part of the memory image, thus conceptually the distance between a
> non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
> link time.
> 
> % ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
> ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''
> 
> Reuse the DISCARDS macro which includes .discard.* to drop .discard.unreachable
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Fangrui Song <maskray@google.com>
> ---
>  arch/x86/boot/compressed/vmlinux.lds.S | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S
> index 0dc5c2b9614b..8f1025d1f681 100644
> --- a/arch/x86/boot/compressed/vmlinux.lds.S
> +++ b/arch/x86/boot/compressed/vmlinux.lds.S
> @@ -74,4 +74,6 @@ SECTIONS
>  #endif
>  	. = ALIGN(PAGE_SIZE);	/* keep ZO size page aligned */
>  	_end = .;
> +
> +	DISCARDS
>  }
> -- 
> 2.26.2.761.g0e0b3e54be-goog
> 

Thanks! Maybe add a note in the commit message that the section is
generated from unreachable() annotations when CONFIG_STACK_VALIDATION is
enabled.

Tested-by: Arvind Sankar <nivedita@alum.mit.edu>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
  2020-05-20 18:20 [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux Fangrui Song
  2020-05-20 19:19 ` Arvind Sankar
@ 2020-05-22  2:42 ` Kees Cook
  2020-05-22  6:51   ` Sedat Dilek
  1 sibling, 1 reply; 7+ messages in thread
From: Kees Cook @ 2020-05-22  2:42 UTC (permalink / raw)
  To: Fangrui Song
  Cc: x86, Arvind Sankar, linux-efi, clang-built-linux,
	Nick Desaulniers, Ard Biesheuvel, kbuild test robot

On Wed, May 20, 2020 at 11:20:10AM -0700, 'Fangrui Song' via Clang Built Linux wrote:
> In the latest efi tree, ce5e3f909fc0ed67e58367b9c56a54c20a51080b
> "efi/printf: Add 64-bit and 8-bit integer support",
> arch/x86/boot/compressed/vmlinux may have an undesired
> .discard.unreachable section from drivers/firmware/efi/libstub/vsprintf.stub.o
> 
> .discard.unreachable contains an R_X86_64_PC32 relocation, which will be
> warned by LLD: a non-SHF_ALLOC section (.discard.unreachable) is not
> part of the memory image, thus conceptually the distance between a
> non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
> link time.
> 
> % ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
> ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''
> 
> Reuse the DISCARDS macro which includes .discard.* to drop .discard.unreachable
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Fangrui Song <maskray@google.com>

Yay macro usage! :)

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
  2020-05-22  2:42 ` Kees Cook
@ 2020-05-22  6:51   ` Sedat Dilek
  2020-05-22 15:54     ` Ard Biesheuvel
  0 siblings, 1 reply; 7+ messages in thread
From: Sedat Dilek @ 2020-05-22  6:51 UTC (permalink / raw)
  To: Kees Cook
  Cc: Fangrui Song, x86, Arvind Sankar, linux-efi,
	Clang-Built-Linux ML, Nick Desaulniers, Ard Biesheuvel,
	kbuild test robot

On Fri, May 22, 2020 at 4:43 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Wed, May 20, 2020 at 11:20:10AM -0700, 'Fangrui Song' via Clang Built Linux wrote:
> > In the latest efi tree, ce5e3f909fc0ed67e58367b9c56a54c20a51080b
> > "efi/printf: Add 64-bit and 8-bit integer support",
> > arch/x86/boot/compressed/vmlinux may have an undesired
> > .discard.unreachable section from drivers/firmware/efi/libstub/vsprintf.stub.o
> >
> > .discard.unreachable contains an R_X86_64_PC32 relocation, which will be
> > warned by LLD: a non-SHF_ALLOC section (.discard.unreachable) is not
> > part of the memory image, thus conceptually the distance between a
> > non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
> > link time.
> >
> > % ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
> > ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''
> >
> > Reuse the DISCARDS macro which includes .discard.* to drop .discard.unreachable
> >
> > Reported-by: kbuild test robot <lkp@intel.com>
> > Signed-off-by: Fangrui Song <maskray@google.com>
>
> Yay macro usage! :)
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>

Feel free to add...

   Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # build and boot on
Linux v5.7-rc6+ with Clang and LLD v10.0.1-rc1

...together with one more patches in the x86/boot area:

x86/boot: Correct relocation destination on old linkers

Next run will include:

x86/boot: Add .text.startup to setup.ld (v2)

- Sedat -

[1] https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.1-rc1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
  2020-05-22  6:51   ` Sedat Dilek
@ 2020-05-22 15:54     ` Ard Biesheuvel
  2020-05-22 15:57       ` Sedat Dilek
  0 siblings, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2020-05-22 15:54 UTC (permalink / raw)
  To: sedat.dilek
  Cc: Kees Cook, Fangrui Song, X86 ML, Arvind Sankar, linux-efi,
	Clang-Built-Linux ML, Nick Desaulniers, kbuild test robot

On Fri, 22 May 2020 at 08:51, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Fri, May 22, 2020 at 4:43 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Wed, May 20, 2020 at 11:20:10AM -0700, 'Fangrui Song' via Clang Built Linux wrote:
> > > In the latest efi tree, ce5e3f909fc0ed67e58367b9c56a54c20a51080b
> > > "efi/printf: Add 64-bit and 8-bit integer support",
> > > arch/x86/boot/compressed/vmlinux may have an undesired
> > > .discard.unreachable section from drivers/firmware/efi/libstub/vsprintf.stub.o
> > >
> > > .discard.unreachable contains an R_X86_64_PC32 relocation, which will be
> > > warned by LLD: a non-SHF_ALLOC section (.discard.unreachable) is not
> > > part of the memory image, thus conceptually the distance between a
> > > non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
> > > link time.
> > >
> > > % ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
> > > ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''
> > >
> > > Reuse the DISCARDS macro which includes .discard.* to drop .discard.unreachable
> > >
> > > Reported-by: kbuild test robot <lkp@intel.com>
> > > Signed-off-by: Fangrui Song <maskray@google.com>
> >
> > Yay macro usage! :)
> >
> > Reviewed-by: Kees Cook <keescook@chromium.org>
> >
>
> Feel free to add...
>
>    Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # build and boot on
> Linux v5.7-rc6+ with Clang and LLD v10.0.1-rc1
>
> ...together with one more patches in the x86/boot area:
>
> x86/boot: Correct relocation destination on old linkers
>
> Next run will include:
>
> x86/boot: Add .text.startup to setup.ld (v2)
>
> - Sedat -
>
> [1] https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.1-rc1

Thanks, I'll queue this up.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
  2020-05-22 15:54     ` Ard Biesheuvel
@ 2020-05-22 15:57       ` Sedat Dilek
  2020-05-22 15:59         ` Ard Biesheuvel
  0 siblings, 1 reply; 7+ messages in thread
From: Sedat Dilek @ 2020-05-22 15:57 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Kees Cook, Fangrui Song, X86 ML, Arvind Sankar, linux-efi,
	Clang-Built-Linux ML, Nick Desaulniers, kbuild test robot

On Fri, May 22, 2020 at 5:54 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Fri, 22 May 2020 at 08:51, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> >
> > On Fri, May 22, 2020 at 4:43 AM Kees Cook <keescook@chromium.org> wrote:
> > >
> > > On Wed, May 20, 2020 at 11:20:10AM -0700, 'Fangrui Song' via Clang Built Linux wrote:
> > > > In the latest efi tree, ce5e3f909fc0ed67e58367b9c56a54c20a51080b
> > > > "efi/printf: Add 64-bit and 8-bit integer support",
> > > > arch/x86/boot/compressed/vmlinux may have an undesired
> > > > .discard.unreachable section from drivers/firmware/efi/libstub/vsprintf.stub.o
> > > >
> > > > .discard.unreachable contains an R_X86_64_PC32 relocation, which will be
> > > > warned by LLD: a non-SHF_ALLOC section (.discard.unreachable) is not
> > > > part of the memory image, thus conceptually the distance between a
> > > > non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
> > > > link time.
> > > >
> > > > % ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
> > > > ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''
> > > >
> > > > Reuse the DISCARDS macro which includes .discard.* to drop .discard.unreachable
> > > >
> > > > Reported-by: kbuild test robot <lkp@intel.com>
> > > > Signed-off-by: Fangrui Song <maskray@google.com>
> > >
> > > Yay macro usage! :)
> > >
> > > Reviewed-by: Kees Cook <keescook@chromium.org>
> > >
> >
> > Feel free to add...
> >
> >    Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # build and boot on
> > Linux v5.7-rc6+ with Clang and LLD v10.0.1-rc1
> >
> > ...together with one more patches in the x86/boot area:
> >
> > x86/boot: Correct relocation destination on old linkers
> >
> > Next run will include:
> >
> > x86/boot: Add .text.startup to setup.ld (v2)
> >
> > - Sedat -
> >
> > [1] https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.1-rc1
>
> Thanks, I'll queue this up.

Just FYI:
It's in tip.git#x86/build already.

- Sedat -

[1] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/build&id=d6ee6529436a15a0541aff6e1697989ee7dc2c44

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux
  2020-05-22 15:57       ` Sedat Dilek
@ 2020-05-22 15:59         ` Ard Biesheuvel
  0 siblings, 0 replies; 7+ messages in thread
From: Ard Biesheuvel @ 2020-05-22 15:59 UTC (permalink / raw)
  To: sedat.dilek
  Cc: Kees Cook, Fangrui Song, X86 ML, Arvind Sankar, linux-efi,
	Clang-Built-Linux ML, Nick Desaulniers, kbuild test robot

On Fri, 22 May 2020 at 17:57, Sedat Dilek <sedat.dilek@gmail.com> wrote:
>
> On Fri, May 22, 2020 at 5:54 PM Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > On Fri, 22 May 2020 at 08:51, Sedat Dilek <sedat.dilek@gmail.com> wrote:
> > >
> > > On Fri, May 22, 2020 at 4:43 AM Kees Cook <keescook@chromium.org> wrote:
> > > >
> > > > On Wed, May 20, 2020 at 11:20:10AM -0700, 'Fangrui Song' via Clang Built Linux wrote:
> > > > > In the latest efi tree, ce5e3f909fc0ed67e58367b9c56a54c20a51080b
> > > > > "efi/printf: Add 64-bit and 8-bit integer support",
> > > > > arch/x86/boot/compressed/vmlinux may have an undesired
> > > > > .discard.unreachable section from drivers/firmware/efi/libstub/vsprintf.stub.o
> > > > >
> > > > > .discard.unreachable contains an R_X86_64_PC32 relocation, which will be
> > > > > warned by LLD: a non-SHF_ALLOC section (.discard.unreachable) is not
> > > > > part of the memory image, thus conceptually the distance between a
> > > > > non-SHF_ALLOC and a SHF_ALLOC is not a constant which can be resolved at
> > > > > link time.
> > > > >
> > > > > % ld.lld -m elf_x86_64 -T arch/x86/boot/compressed/vmlinux.lds ... -o arch/x86/boot/compressed/vmlinux
> > > > > ld.lld: warning: vsprintf.c:(.discard.unreachable+0x0): has non-ABS relocation R_X86_64_PC32 against symbol ''
> > > > >
> > > > > Reuse the DISCARDS macro which includes .discard.* to drop .discard.unreachable
> > > > >
> > > > > Reported-by: kbuild test robot <lkp@intel.com>
> > > > > Signed-off-by: Fangrui Song <maskray@google.com>
> > > >
> > > > Yay macro usage! :)
> > > >
> > > > Reviewed-by: Kees Cook <keescook@chromium.org>
> > > >
> > >
> > > Feel free to add...
> > >
> > >    Tested-by: Sedat Dilek <sedat.dilek@gmail.com> # build and boot on
> > > Linux v5.7-rc6+ with Clang and LLD v10.0.1-rc1
> > >
> > > ...together with one more patches in the x86/boot area:
> > >
> > > x86/boot: Correct relocation destination on old linkers
> > >
> > > Next run will include:
> > >
> > > x86/boot: Add .text.startup to setup.ld (v2)
> > >
> > > - Sedat -
> > >
> > > [1] https://github.com/llvm/llvm-project/releases/tag/llvmorg-10.0.1-rc1
> >
> > Thanks, I'll queue this up.
>
> Just FYI:
> It's in tip.git#x86/build already.
>
> - Sedat -
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=x86/build&id=d6ee6529436a15a0541aff6e1697989ee7dc2c44

Thanks for the head's up. I'll remove it from my branch again.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-22 15:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 18:20 [PATCH] x86/boot: Discard .discard.unreachable for arch/x86/boot/compressed/vmlinux Fangrui Song
2020-05-20 19:19 ` Arvind Sankar
2020-05-22  2:42 ` Kees Cook
2020-05-22  6:51   ` Sedat Dilek
2020-05-22 15:54     ` Ard Biesheuvel
2020-05-22 15:57       ` Sedat Dilek
2020-05-22 15:59         ` Ard Biesheuvel

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).