llvm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: objtool "'naked' return found in RETHUNK build" with clang + CONFIG_K{A,C}SAN=y
Date: Wed, 13 Jul 2022 18:25:41 +0200	[thread overview]
Message-ID: <Ys7yBcfBRWXPLsLq@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <Ys7vKYJ9tyih8Cng@dev-arch.thelio-3990X>

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.

  reply	other threads:[~2022-07-13 16:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-07-13 16:42       ` Nick Desaulniers
2022-07-13 22:05         ` Nick Desaulniers
2022-07-14  0:31           ` Nick Desaulniers

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=Ys7yBcfBRWXPLsLq@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    /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).