From: "Jürgen Groß" <jgross@suse.com>
To: 李则良 <lizeliang.linux@gmail.com>,
"Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <peterz@infradead.org>,
Kees Cook <kees@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/alternatives: gracefully skip unrecognized indirect call instructions
Date: Tue, 11 Aug 2026 13:50:53 +0200 [thread overview]
Message-ID: <191300ae-0f0d-430e-955f-bdd2aea4997e@suse.com> (raw)
In-Reply-To: <CANd6bgL=v+uReoQznRGKunZQApwV5ESHAQn2_MOt-J-=cPkm9g@mail.gmail.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 2462 bytes --]
On 11.08.26 13:41, 李则良 wrote:
> From cd58bd112a6178593c6bc9c0f9b307d6897ae3d0 Mon Sep 17 00:00:00 2001
> From: Zeliang Li <lizeliang.linux@gmail.com <mailto:lizeliang.linux@gmail.com>>
> Date: Tue, 11 Aug 2026 19:09:09 +0800
> Subject: [PATCH] x86/alternatives: gracefully skip unrecognized indirect call
> instructions
>
> When the kernel is compiled at a non-default optimization level
> (e.g., KCFLAGS=-O1), the compiler may emit call instruction
> patterns that differ from the expected 6-byte sequence
> (opcodes 0xff 0x15 followed by a 32-bit displacement) checked
> by alt_replace_call().
>
> Currently this triggers a BUG() in apply_alternatives(), causing
> an immediate kernel panic during early boot:
>
> kernel BUG at arch/x86/kernel/alternative.c:558!
>
> Instead of crashing, print a warning (once per boot) and preserve
> the original call instruction verbatim. The call will execute as
> compiled, without any alternatives patching applied. This is a
> graceful degradation: the indirect call remains indirect, which is
> functionally correct albeit slower than the direct-call patching
> that was skipped.
>
> No change to normal -O2 builds, where call instructions continue
> to match the expected pattern.
>
> Signed-off-by: Zeliang Li <lizeliang.linux@gmail.com
> <mailto:lizeliang.linux@gmail.com>>
Please don't send patches as HTML mails!
> ---
> arch/x86/kernel/alternative.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index 62936a3bde19..0e3903e76b55 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -554,8 +554,15 @@ static unsigned int alt_replace_call(u8 *instr, u8
> *insn_buff, struct alt_instr
> if (a->instrlen != 6 ||
> instr[0] != CALL_RIP_REL_OPCODE ||
> instr[1] != CALL_RIP_REL_MODRM) {
> - pr_err("ALT_FLAG_DIRECT_CALL set for unrecognized indirect call\n");
> - BUG();
> + static bool warned;
> +
> + if (!warned) {
> + warned = true;
> + pr_warn("%s: skipping unrecognized indirect call (instrlen=%d)\n",
> + __func__, a->instrlen);
> + }
You are open coding pr_warn_once() here.
> + memcpy(insn_buff, instr, a->instrlen);
> + return a->instrlen;
And now you are letting an indirect call survive which is not subject to
any cpu bug mitigations.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next parent reply other threads:[~2026-08-11 11:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CANd6bgL=v+uReoQznRGKunZQApwV5ESHAQn2_MOt-J-=cPkm9g@mail.gmail.com>
2026-08-11 11:50 ` Jürgen Groß [this message]
2026-08-12 9:22 ` [PATCH] x86/alternatives: gracefully skip unrecognized indirect call instructions 李则良
2026-08-12 11:00 ` Peter Zijlstra
2026-08-12 11:24 ` H. Peter Anvin
2026-08-12 15:30 ` Borislav Petkov
2026-08-12 17:14 ` 李则良
2026-08-12 19:01 ` H. Peter Anvin
2026-08-12 19:02 ` H. Peter Anvin
2026-08-13 9:51 ` Peter Zijlstra
2026-08-13 19:35 ` 李则良
2026-08-13 19:57 ` 李则良
2026-08-14 10:15 ` Jürgen Groß
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=191300ae-0f0d-430e-955f-bdd2aea4997e@suse.com \
--to=jgross@suse.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizeliang.linux@gmail.com \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.