linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
@ 2022-07-13 15:47 Nathan Chancellor
  2022-07-13 16:01 ` Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2022-07-13 15:47 UTC (permalink / raw)
  To: Josh Poimboeuf, Peter Zijlstra; +Cc: linux-kernel, llvm

Hi Josh and Peter,

After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and
commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I
see a spew of objtool warnings when building certain configurations with
clang. Examples below, they appear to trigger in every single file.

With x86_64_defconfig + CONFIG_KASAN=y:

arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build
init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build

With x86_64_defconfig + CONFIG_KCSAN=y:

arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build

If there is any additional information I can provide or patches I can
test, I am happy to do so!

Cheers,
Nathan

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

* Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
  2022-07-13 15:47 objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y Nathan Chancellor
@ 2022-07-13 16:01 ` Nick Desaulniers
  2022-07-13 16:13   ` Nathan Chancellor
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2022-07-13 16:01 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Josh Poimboeuf, Peter Zijlstra, linux-kernel, llvm

On Wed, Jul 13, 2022 at 8:48 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi Josh and Peter,
>
> After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and
> commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I
> see a spew of objtool warnings when building certain configurations with
> clang. Examples below, they appear to trigger in every single file.
>
> With x86_64_defconfig + CONFIG_KASAN=y:
>
> arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build
> init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
>
> With x86_64_defconfig + CONFIG_KCSAN=y:
>
> arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build

Thanks for the report. I wonder if this might be a compiler bug; it
seems like the {a|t}san.module_{c|d}tor functions are being emitted
with ret instructions?

If you have one of these builds lying around still, can you provide:

$ llvm-objdump -dr --disassemble-symbols=tsan.module_ctor
arch/x86/kernel/fpu/bugs.o

(I'm about to head into a bunch of meetings now, but can check more
this afternoon; see you at Noon)

If Peter and Josh are bored, feel free to stop by
https://meet.google.com/yjf-jyqk-iaz
at Noon PDT / 19:00 UTV today.

>
> If there is any additional information I can provide or patches I can
> test, I am happy to do so!
>
> Cheers,
> Nathan
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
  2022-07-13 16:01 ` Nick Desaulniers
@ 2022-07-13 16:13   ` Nathan Chancellor
  2022-07-13 16:25     ` Peter Zijlstra
  0 siblings, 1 reply; 7+ messages in thread
From: Nathan Chancellor @ 2022-07-13 16:13 UTC (permalink / raw)
  To: Nick Desaulniers; +Cc: Josh Poimboeuf, Peter Zijlstra, linux-kernel, llvm

On Wed, Jul 13, 2022 at 09:01:58AM -0700, Nick Desaulniers wrote:
> On Wed, Jul 13, 2022 at 8:48 AM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > Hi Josh and Peter,
> >
> > After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and
> > commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I
> > see a spew of objtool warnings when building certain configurations with
> > clang. Examples below, they appear to trigger in every single file.
> >
> > With x86_64_defconfig + CONFIG_KASAN=y:
> >
> > arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build
> > init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> >
> > With x86_64_defconfig + CONFIG_KCSAN=y:
> >
> > arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> 
> Thanks for the report. I wonder if this might be a compiler bug; it
> seems like the {a|t}san.module_{c|d}tor functions are being emitted
> with ret instructions?
> 
> If you have one of these builds lying around still, can you provide:
> 
> $ llvm-objdump -dr --disassemble-symbols=tsan.module_ctor
> arch/x86/kernel/fpu/bugs.o

Sure thing.

With KASAN:

$ llvm-objdump -r --disassemble-symbols=asan.module_ctor,asan.module_dtor build/arch/x86/kernel/fpu/bugs.o

build/arch/x86/kernel/fpu/bugs.o:	file format elf64-x86-64

Disassembly of section .text.asan.module_ctor:

0000000000000000 <asan.module_ctor>:
       0: be 01 00 00 00               	movl	$1, %esi
       5: 48 c7 c7 00 00 00 00         	movq	$0, %rdi
		0000000000000008:  R_X86_64_32S	.data
       c: e8 00 00 00 00               	callq	0x11 <asan.module_ctor+0x11>
		000000000000000d:  R_X86_64_PLT32	__asan_register_globals-0x4
      11: c3                           	retq

Disassembly of section .text.asan.module_dtor:

0000000000000000 <asan.module_dtor>:
       0: be 01 00 00 00               	movl	$1, %esi
       5: 48 c7 c7 00 00 00 00         	movq	$0, %rdi
		0000000000000008:  R_X86_64_32S	.data
       c: e8 00 00 00 00               	callq	0x11 <asan.module_dtor+0x11>
		000000000000000d:  R_X86_64_PLT32	__asan_unregister_globals-0x4
      11: c3                           	retq

With KCSAN:

$ llvm-objdump -r --disassemble-symbols=tsan.module_ctor build/arch/x86/kernel/fpu/bugs.o

build/arch/x86/kernel/fpu/bugs.o:	file format elf64-x86-64

Disassembly of section .text.tsan.module_ctor:

0000000000000000 <tsan.module_ctor>:
       0: e8 00 00 00 00               	callq	0x5 <tsan.module_ctor+0x5>
		0000000000000001:  R_X86_64_PLT32	__tsan_init-0x4
       5: c3                           	retq

Cheers,
Nathan

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

* Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
  2022-07-13 16:13   ` Nathan Chancellor
@ 2022-07-13 16:25     ` Peter Zijlstra
  2022-07-13 16:42       ` Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Zijlstra @ 2022-07-13 16:25 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Nick Desaulniers, Josh Poimboeuf, linux-kernel, llvm

On Wed, Jul 13, 2022 at 09:13:29AM -0700, Nathan Chancellor wrote:
> On Wed, Jul 13, 2022 at 09:01:58AM -0700, Nick Desaulniers wrote:
> > On Wed, Jul 13, 2022 at 8:48 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > Hi Josh and Peter,
> > >
> > > After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and
> > > commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I
> > > see a spew of objtool warnings when building certain configurations with
> > > clang. Examples below, they appear to trigger in every single file.
> > >
> > > With x86_64_defconfig + CONFIG_KASAN=y:
> > >
> > > arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build
> > > init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > >
> > > With x86_64_defconfig + CONFIG_KCSAN=y:
> > >
> > > arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > 
> > Thanks for the report. I wonder if this might be a compiler bug; it
> > seems like the {a|t}san.module_{c|d}tor functions are being emitted
> > with ret instructions?
> > 
> > If you have one of these builds lying around still, can you provide:
> > 
> > $ llvm-objdump -dr --disassemble-symbols=tsan.module_ctor
> > arch/x86/kernel/fpu/bugs.o
> 
> Sure thing.
> 
> With KASAN:
> 
> $ llvm-objdump -r --disassemble-symbols=asan.module_ctor,asan.module_dtor build/arch/x86/kernel/fpu/bugs.o
> 
> build/arch/x86/kernel/fpu/bugs.o:	file format elf64-x86-64
> 
> Disassembly of section .text.asan.module_ctor:
> 
> 0000000000000000 <asan.module_ctor>:
>        0: be 01 00 00 00               	movl	$1, %esi
>        5: 48 c7 c7 00 00 00 00         	movq	$0, %rdi
> 		0000000000000008:  R_X86_64_32S	.data
>        c: e8 00 00 00 00               	callq	0x11 <asan.module_ctor+0x11>
> 		000000000000000d:  R_X86_64_PLT32	__asan_register_globals-0x4
>       11: c3                           	retq

As Nick said; this should be: 'jmp __x86_return_thunk', on those builds.

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

* Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
  2022-07-13 16:25     ` Peter Zijlstra
@ 2022-07-13 16:42       ` Nick Desaulniers
  2022-07-13 22:05         ` Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2022-07-13 16:42 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Josh Poimboeuf, linux-kernel, llvm, Peter Zijlstra

On Wed, Jul 13, 2022 at 9:25 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Wed, Jul 13, 2022 at 09:13:29AM -0700, Nathan Chancellor wrote:
> > On Wed, Jul 13, 2022 at 09:01:58AM -0700, Nick Desaulniers wrote:
> > > On Wed, Jul 13, 2022 at 8:48 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > > >
> > > > Hi Josh and Peter,
> > > >
> > > > After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and
> > > > commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I
> > > > see a spew of objtool warnings when building certain configurations with
> > > > clang. Examples below, they appear to trigger in every single file.
> > > >
> > > > With x86_64_defconfig + CONFIG_KASAN=y:
> > > >
> > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build
> > > > init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > >
> > > > With x86_64_defconfig + CONFIG_KCSAN=y:
> > > >
> > > > arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > >
> > > Thanks for the report. I wonder if this might be a compiler bug; it
> > > seems like the {a|t}san.module_{c|d}tor functions are being emitted
> > > with ret instructions?
> > >
> > > If you have one of these builds lying around still, can you provide:
> > >
> > > $ llvm-objdump -dr --disassemble-symbols=tsan.module_ctor
> > > arch/x86/kernel/fpu/bugs.o
> >
> > Sure thing.
> >
> > With KASAN:
> >
> > $ llvm-objdump -r --disassemble-symbols=asan.module_ctor,asan.module_dtor build/arch/x86/kernel/fpu/bugs.o
> >
> > build/arch/x86/kernel/fpu/bugs.o:     file format elf64-x86-64
> >
> > Disassembly of section .text.asan.module_ctor:
> >
> > 0000000000000000 <asan.module_ctor>:
> >        0: be 01 00 00 00                      movl    $1, %esi
> >        5: 48 c7 c7 00 00 00 00                movq    $0, %rdi
> >               0000000000000008:  R_X86_64_32S .data
> >        c: e8 00 00 00 00                      callq   0x11 <asan.module_ctor+0x11>
> >               000000000000000d:  R_X86_64_PLT32       __asan_register_globals-0x4
> >       11: c3                                  retq
>
> As Nick said; this should be: 'jmp __x86_return_thunk', on those builds.

https://github.com/llvm/llvm-project/issues/56514

-- 
Thanks,
~Nick Desaulniers

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

* Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
  2022-07-13 16:42       ` Nick Desaulniers
@ 2022-07-13 22:05         ` Nick Desaulniers
  2022-07-14  0:31           ` Nick Desaulniers
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Desaulniers @ 2022-07-13 22:05 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Josh Poimboeuf, linux-kernel, llvm, Peter Zijlstra

On Wed, Jul 13, 2022 at 9:42 AM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Wed, Jul 13, 2022 at 9:25 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Wed, Jul 13, 2022 at 09:13:29AM -0700, Nathan Chancellor wrote:
> > > On Wed, Jul 13, 2022 at 09:01:58AM -0700, Nick Desaulniers wrote:
> > > > On Wed, Jul 13, 2022 at 8:48 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > > > >
> > > > > Hi Josh and Peter,
> > > > >
> > > > > After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and
> > > > > commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I
> > > > > see a spew of objtool warnings when building certain configurations with
> > > > > clang. Examples below, they appear to trigger in every single file.
> > > > >
> > > > > With x86_64_defconfig + CONFIG_KASAN=y:
> > > > >
> > > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build
> > > > > init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > >
> > > > > With x86_64_defconfig + CONFIG_KCSAN=y:
> > > > >
> > > > > arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build

It's not just the sanitizers, `CONFIG_GCOV_KERNEL=y` +
`CONFIG_GCOV_PROFILE_ALL=y` also has this issue:
```
...
drivers/base/platform.o: warning: objtool: __llvm_gcov_reset+0xa94:
'naked' return found in RETHUNK build
net/core/netpoll.o: warning: objtool: __llvm_gcov_reset+0xde3: 'naked'
return found in RETHUNK build
net/netfilter/nf_conntrack_netlink.o: warning: objtool:
__llvm_gcov_reset+0x1b94: 'naked' return found in RETHUNK build
fs/fs_parser.o: warning: objtool: __llvm_gcov_reset+0x344: 'naked'
return found in RETHUNK build
drivers/acpi/debugfs.o: warning: objtool: __llvm_gcov_reset+0xb:
'naked' return found in RETHUNK build
mm/pagewalk.o: warning: objtool: __llvm_gcov_reset+0x77f: 'naked'
return found in RETHUNK build
drivers/tty/serial/8250/8250_pnp.o: warning: objtool:
__llvm_gcov_reset+0x231: 'naked' return found in RETHUNK build
fs/init.o: warning: objtool: __llvm_gcov_reset+0x2f7: 'naked' return
found in RETHUNK build
drivers/gpu/drm/drm_fourcc.o: warning: objtool:
__llvm_gcov_reset+0x1ce: 'naked' return found in RETHUNK build
...
```

> > > >
> > > > Thanks for the report. I wonder if this might be a compiler bug; it
> > > > seems like the {a|t}san.module_{c|d}tor functions are being emitted
> > > > with ret instructions?
> > > >
> > > > If you have one of these builds lying around still, can you provide:
> > > >
> > > > $ llvm-objdump -dr --disassemble-symbols=tsan.module_ctor
> > > > arch/x86/kernel/fpu/bugs.o
> > >
> > > Sure thing.
> > >
> > > With KASAN:
> > >
> > > $ llvm-objdump -r --disassemble-symbols=asan.module_ctor,asan.module_dtor build/arch/x86/kernel/fpu/bugs.o
> > >
> > > build/arch/x86/kernel/fpu/bugs.o:     file format elf64-x86-64
> > >
> > > Disassembly of section .text.asan.module_ctor:
> > >
> > > 0000000000000000 <asan.module_ctor>:
> > >        0: be 01 00 00 00                      movl    $1, %esi
> > >        5: 48 c7 c7 00 00 00 00                movq    $0, %rdi
> > >               0000000000000008:  R_X86_64_32S .data
> > >        c: e8 00 00 00 00                      callq   0x11 <asan.module_ctor+0x11>
> > >               000000000000000d:  R_X86_64_PLT32       __asan_register_globals-0x4
> > >       11: c3                                  retq
> >
> > As Nick said; this should be: 'jmp __x86_return_thunk', on those builds.
>
> https://github.com/llvm/llvm-project/issues/56514
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

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

* Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
  2022-07-13 22:05         ` Nick Desaulniers
@ 2022-07-14  0:31           ` Nick Desaulniers
  0 siblings, 0 replies; 7+ messages in thread
From: Nick Desaulniers @ 2022-07-14  0:31 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Josh Poimboeuf, linux-kernel, llvm, Peter Zijlstra

On Wed, Jul 13, 2022 at 3:05 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Wed, Jul 13, 2022 at 9:42 AM Nick Desaulniers
> <ndesaulniers@google.com> wrote:
> >
> > On Wed, Jul 13, 2022 at 9:25 AM Peter Zijlstra <peterz@infradead.org> wrote:
> > >
> > > On Wed, Jul 13, 2022 at 09:13:29AM -0700, Nathan Chancellor wrote:
> > > > On Wed, Jul 13, 2022 at 09:01:58AM -0700, Nick Desaulniers wrote:
> > > > > On Wed, Jul 13, 2022 at 8:48 AM Nathan Chancellor <nathan@kernel.org> wrote:
> > > > > >
> > > > > > Hi Josh and Peter,
> > > > > >
> > > > > > After commit 9bb2ec608a20 ("objtool: Update Retpoline validation") and
> > > > > > commit f43b9876e857 ("x86/retbleed: Add fine grained Kconfig knobs"), I
> > > > > > see a spew of objtool warnings when building certain configurations with
> > > > > > clang. Examples below, they appear to trigger in every single file.
> > > > > >
> > > > > > With x86_64_defconfig + CONFIG_KASAN=y:
> > > > > >
> > > > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > > arch/x86/ia32/audit.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > > init/version.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > > init/version.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/platform-quirks.o: warning: objtool: asan.module_ctor+0x0: 'naked' return found in RETHUNK build
> > > > > > init/calibrate.o: warning: objtool: asan.module_ctor+0x11: 'naked' return found in RETHUNK build
> > > > > > init/calibrate.o: warning: objtool: asan.module_dtor+0x11: 'naked' return found in RETHUNK build
> > > > > >
> > > > > > With x86_64_defconfig + CONFIG_KCSAN=y:
> > > > > >
> > > > > > arch/x86/ia32/audit.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > > init/calibrate.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > > init/version.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/fpu/bugs.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/cpu/rdrand.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > > arch/x86/events/probe.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
> > > > > > arch/x86/kernel/apic/ipi.o: warning: objtool: tsan.module_ctor+0x5: 'naked' return found in RETHUNK build
>
> It's not just the sanitizers, `CONFIG_GCOV_KERNEL=y` +
> `CONFIG_GCOV_PROFILE_ALL=y` also has this issue:
> ```
> ...
> drivers/base/platform.o: warning: objtool: __llvm_gcov_reset+0xa94:
> 'naked' return found in RETHUNK build
> net/core/netpoll.o: warning: objtool: __llvm_gcov_reset+0xde3: 'naked'
> return found in RETHUNK build
> net/netfilter/nf_conntrack_netlink.o: warning: objtool:
> __llvm_gcov_reset+0x1b94: 'naked' return found in RETHUNK build
> fs/fs_parser.o: warning: objtool: __llvm_gcov_reset+0x344: 'naked'
> return found in RETHUNK build
> drivers/acpi/debugfs.o: warning: objtool: __llvm_gcov_reset+0xb:
> 'naked' return found in RETHUNK build
> mm/pagewalk.o: warning: objtool: __llvm_gcov_reset+0x77f: 'naked'
> return found in RETHUNK build
> drivers/tty/serial/8250/8250_pnp.o: warning: objtool:
> __llvm_gcov_reset+0x231: 'naked' return found in RETHUNK build
> fs/init.o: warning: objtool: __llvm_gcov_reset+0x2f7: 'naked' return
> found in RETHUNK build
> drivers/gpu/drm/drm_fourcc.o: warning: objtool:
> __llvm_gcov_reset+0x1ce: 'naked' return found in RETHUNK build
> ...
> ```

https://reviews.llvm.org/D129709

>
> > > > >
> > > > > Thanks for the report. I wonder if this might be a compiler bug; it
> > > > > seems like the {a|t}san.module_{c|d}tor functions are being emitted
> > > > > with ret instructions?
> > > > >
> > > > > If you have one of these builds lying around still, can you provide:
> > > > >
> > > > > $ llvm-objdump -dr --disassemble-symbols=tsan.module_ctor
> > > > > arch/x86/kernel/fpu/bugs.o
> > > >
> > > > Sure thing.
> > > >
> > > > With KASAN:
> > > >
> > > > $ llvm-objdump -r --disassemble-symbols=asan.module_ctor,asan.module_dtor build/arch/x86/kernel/fpu/bugs.o
> > > >
> > > > build/arch/x86/kernel/fpu/bugs.o:     file format elf64-x86-64
> > > >
> > > > Disassembly of section .text.asan.module_ctor:
> > > >
> > > > 0000000000000000 <asan.module_ctor>:
> > > >        0: be 01 00 00 00                      movl    $1, %esi
> > > >        5: 48 c7 c7 00 00 00 00                movq    $0, %rdi
> > > >               0000000000000008:  R_X86_64_32S .data
> > > >        c: e8 00 00 00 00                      callq   0x11 <asan.module_ctor+0x11>
> > > >               000000000000000d:  R_X86_64_PLT32       __asan_register_globals-0x4
> > > >       11: c3                                  retq
> > >
> > > As Nick said; this should be: 'jmp __x86_return_thunk', on those builds.
> >
> > https://github.com/llvm/llvm-project/issues/56514
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
>
>
>
> --
> Thanks,
> ~Nick Desaulniers



-- 
Thanks,
~Nick Desaulniers

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

end of thread, other threads:[~2022-07-14  0:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-13 15:47 objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y Nathan Chancellor
2022-07-13 16:01 ` Nick Desaulniers
2022-07-13 16:13   ` Nathan Chancellor
2022-07-13 16:25     ` Peter Zijlstra
2022-07-13 16:42       ` Nick Desaulniers
2022-07-13 22:05         ` Nick Desaulniers
2022-07-14  0:31           ` Nick Desaulniers

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