All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ihor Solodrai" <ihor.solodrai@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v1 5/5] x86/cpu: Don't reset boot CPU cpuinfo in identify_cpu()
Date: Sat, 04 Jul 2026 00:35:00 +0000	[thread overview]
Message-ID: <20260704003501.7692A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260704002046.3859585-6-ihor.solodrai@linux.dev>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The patch deliberately leaves 32-bit systems vulnerable to the exact same interrupt window race condition that it fixes for 64-bit systems.
--

commit 7225f9ebac0ba182d1da83ea9f37319d7bdecfdb
Author: Ihor Solodrai <ihor.solodrai@linux.dev>

x86/cpu: Don't reset boot CPU cpuinfo in identify_cpu()

This patch moves the init_cpu_info() call out of identify_cpu() into its
callers and skips it for the boot CPU on 64-bit systems. This prevents a window
where interrupts can observe cleared CPU capabilities. 32-bit systems still
reset capabilities in identify_boot_cpu() to maintain the no-CPUID default.

Link: https://lore.kernel.org/bpf/20260610175651.647515-1-ihor.solodrai@linux.dev/

> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 93ad02ceacc24..01d07b1f30788 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c

[ ... ]

> @@ -2156,6 +2154,13 @@ static void identify_cpu_32(struct cpuinfo_x86 *c)
>  
>  static __init void identify_boot_cpu(void)
>  {
> +	/*
> +	 * The boot CPU's capabilities were already scanned in early_identify_cpu().
> +	 * However 32-bit still needs to init_cpu_info() here for the no-CPUID
> +	 * cpuid_level default.
> +	 */
> +	if (IS_ENABLED(CONFIG_X86_32))
> +		init_cpu_info(&boot_cpu_data);

[Severity: High]
This is a pre-existing issue, but does leaving the call to init_cpu_info() here
leave 32-bit systems vulnerable to the exact same interrupt window race condition
that this patch fixes for 64-bit?

Because start_kernel() calls local_irq_enable() before arch_cpu_finalize_init()
calls identify_boot_cpu(), an interrupt can fire immediately after
init_cpu_info() clears the capabilities:

arch/x86/kernel/cpu/common.c:init_cpu_info() {
    ...
    memset(&c->x86_capability, 0, sizeof(c->x86_capability));
    ...
}

If a timer tick or other hardware interrupt fires right after this memset,
and the interrupt handler dynamically evaluates boot_cpu_has(), won't it
falsely observe missing capabilities and potentially cause a crash or
incorrect behavior during boot?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260704002046.3859585-1-ihor.solodrai@linux.dev?part=5

      reply	other threads:[~2026-07-04  0:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-04  0:20 [PATCH v1 0/5] x86/cpu: Refactor identify_cpu() Ihor Solodrai
2026-07-04  0:20 ` [PATCH v1 1/5] x86/cpu: Factor init_cpu_info() out of identify_cpu() Ihor Solodrai
2026-07-04  0:20 ` [PATCH v1 2/5] x86/cpu: Inline generic_identify() into identify_cpu() Ihor Solodrai
2026-07-04  0:20 ` [PATCH v1 3/5] x86/cpu: Introduce identify_cpu_32() helper Ihor Solodrai
2026-07-04  0:20 ` [PATCH v1 4/5] x86/cpu: Set X86_BUG_ESPFIX in identify_cpu_32() Ihor Solodrai
2026-07-04  0:20 ` [PATCH v1 5/5] x86/cpu: Don't reset boot CPU cpuinfo in identify_cpu() Ihor Solodrai
2026-07-04  0:35   ` sashiko-bot [this message]

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=20260704003501.7692A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=ihor.solodrai@linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.