linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Kees Cook <kees@kernel.org>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Borislav Petkov" <bp@alien8.de>,
	"Dave Hansen" <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Vitaly Kuznetsov" <vkuznets@redhat.com>,
	"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Len Brown" <lenb@kernel.org>,
	"Masami Hiramatsu" <mhiramat@kernel.org>,
	"Michal Wilczynski" <michal.wilczynski@intel.com>,
	"Juergen Gross" <jgross@suse.com>,
	"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	"Roger Pau Monne" <roger.pau@citrix.com>,
	"David Woodhouse" <dwmw@amazon.co.uk>,
	"Usama Arif" <usama.arif@bytedance.com>,
	"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Brian Gerst" <brgerst@gmail.com>,
	kvm@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net,
	platform-driver-x86@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
	linux-mm@kvack.org, "Will Deacon" <will@kernel.org>,
	"Catalin Marinas" <catalin.marinas@arm.com>,
	"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
	"Gavin Shan" <gshan@redhat.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	"James Morse" <james.morse@arm.com>,
	"Oza Pawandeep" <quic_poza@quicinc.com>,
	"Anshuman Khandual" <anshuman.khandual@arm.com>,
	"Hans de Goede" <hansg@kernel.org>,
	"Kirill A. Shutemov" <kas@kernel.org>,
	"Marco Elver" <elver@google.com>,
	"Andrey Konovalov" <andreyknvl@gmail.com>,
	"Andrey Ryabinin" <ryabinin.a.a@gmail.com>,
	"Hou Wenlong" <houwenlong.hwl@antgroup.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Christophe Leroy" <christophe.leroy@csgroup.eu>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nicolas.schier@linux.dev>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Baoquan He" <bhe@redhat.com>, "Alexander Graf" <graf@amazon.com>,
	"Changyuan Lyu" <changyuanl@google.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"James Morris" <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	"Nick Desaulniers" <nick.desaulniers+lkml@gmail.com>,
	"Bill Wendling" <morbo@google.com>,
	"Justin Stitt" <justinstitt@google.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	"Bibo Mao" <maobibo@loongson.cn>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kasan-dev@googlegroups.com,
	linux-kbuild@vger.kernel.org, linux-hardening@vger.kernel.org,
	kexec@lists.infradead.org, linux-security-module@vger.kernel.org,
	llvm@lists.linux.dev
Subject: Re: [PATCH v4 2/4] x86: Handle KCOV __init vs inline mismatches
Date: Tue, 29 Jul 2025 11:28:14 +0300	[thread overview]
Message-ID: <aIiGHmw8IJb9vsM5@kernel.org> (raw)
In-Reply-To: <20250724055029.3623499-2-kees@kernel.org>

On Wed, Jul 23, 2025 at 10:50:26PM -0700, Kees Cook wrote:
> GCC appears to have kind of fragile inlining heuristics, in the
> sense that it can change whether or not it inlines something based on
> optimizations. It looks like the kcov instrumentation being added (or in
> this case, removed) from a function changes the optimization results,
> and some functions marked "inline" are _not_ inlined. In that case,
> we end up with __init code calling a function not marked __init, and we
> get the build warnings I'm trying to eliminate in the coming patch that
> adds __no_sanitize_coverage to __init functions:
> 
> WARNING: modpost: vmlinux: section mismatch in reference: xbc_exit+0x8 (section: .text.unlikely) -> _xbc_exit (section: .init.text)
> WARNING: modpost: vmlinux: section mismatch in reference: real_mode_size_needed+0x15 (section: .text.unlikely) -> real_mode_blob_end (section: .init.data)
> WARNING: modpost: vmlinux: section mismatch in reference: __set_percpu_decrypted+0x16 (section: .text.unlikely) -> early_set_memory_decrypted (section: .init.text)
> WARNING: modpost: vmlinux: section mismatch in reference: memblock_alloc_from+0x26 (section: .text.unlikely) -> memblock_alloc_try_nid (section: .init.text)
> WARNING: modpost: vmlinux: section mismatch in reference: acpi_arch_set_root_pointer+0xc (section: .text.unlikely) -> x86_init (section: .init.data)
> WARNING: modpost: vmlinux: section mismatch in reference: acpi_arch_get_root_pointer+0x8 (section: .text.unlikely) -> x86_init (section: .init.data)
> WARNING: modpost: vmlinux: section mismatch in reference: efi_config_table_is_usable+0x16 (section: .text.unlikely) -> xen_efi_config_table_is_usable (section: .init.text)
> 
> This problem is somewhat fragile (though using either __always_inline
> or __init will deterministically solve it), but we've tripped over
> this before with GCC and the solution has usually been to just use
> __always_inline and move on.
> 
> For x86 this means forcing several functions to be inline with
> __always_inline.
> 
> Signed-off-by: Kees Cook <kees@kernel.org>

For memblock bit:

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2025-07-29  8:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24  5:50 [PATCH v4 0/4] stackleak: Support Clang stack depth tracking Kees Cook
2025-07-24  5:50 ` [PATCH v4 1/4] arm64: Handle KCOV __init vs inline mismatches Kees Cook
2025-07-29  8:10   ` Will Deacon
2025-07-24  5:50 ` [PATCH v4 2/4] x86: " Kees Cook
2025-07-29  8:28   ` Mike Rapoport [this message]
2025-07-29  9:34   ` Arnd Bergmann
2025-07-24  5:50 ` [PATCH v4 3/4] init.h: Disable sanitizer coverage for __init and __head Kees Cook
2025-07-24  5:50 ` [PATCH v4 4/4] kstack_erase: Support Clang stack depth tracking Kees Cook
2025-07-24 13:08   ` Nicolas Schier
2025-07-26  0:43 ` [PATCH v4 0/4] stackleak: " Nathan Chancellor
2025-07-26  6:27   ` Kees Cook
2025-07-26 21:47   ` Kees Cook

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=aIiGHmw8IJb9vsM5@kernel.org \
    --to=rppt@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=bhe@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=changyuanl@google.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=elver@google.com \
    --cc=gpiccoli@igalia.com \
    --cc=graf@amazon.com \
    --cc=gshan@redhat.com \
    --cc=gustavoars@kernel.org \
    --cc=hansg@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=hmh@hmh.eng.br \
    --cc=houwenlong.hwl@antgroup.com \
    --cc=hpa@zytor.com \
    --cc=ibm-acpi-devel@lists.sourceforge.net \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=james.morse@arm.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=jmorris@namei.org \
    --cc=justinstitt@google.com \
    --cc=kas@kernel.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=kees@kernel.org \
    --cc=kexec@lists.infradead.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=luto@kernel.org \
    --cc=maobibo@loongson.cn \
    --cc=masahiroy@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=michal.wilczynski@intel.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=nicolas.schier@linux.dev \
    --cc=paul@paul-moore.com \
    --cc=paulmck@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=quic_poza@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=roger.pau@citrix.com \
    --cc=ryabinin.a.a@gmail.com \
    --cc=samitolvanen@google.com \
    --cc=serge@hallyn.com \
    --cc=tglx@linutronix.de \
    --cc=thuth@redhat.com \
    --cc=usama.arif@bytedance.com \
    --cc=viresh.kumar@linaro.org \
    --cc=vkuznets@redhat.com \
    --cc=will@kernel.org \
    --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).