Linux Watchdog driver development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bradley Morgan" <brads@mainlining.org>
Cc: linux-watchdog@vger.kernel.org
Subject: Re: [PATCH v7 1/6] panic: fix redirect CPU race in panic_try_force_cpu()
Date: Wed, 16 Sep 2026 18:42:15 +0000	[thread overview]
Message-ID: <20260916184215.8FF411F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260916182957.7788-2-brads@mainlining.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] panic: concurrent panics lose crash state due to early offline
--

commit 28c5124dccd2314d2c1eb6f5688411f6a774d048
Author: Bradley Morgan <brads@mainlining.org>

panic: fix redirect CPU race in panic_try_force_cpu()

The commit updates panic_try_force_cpu() to handle cmpxchg race losers
by returning true so that they stop and don't proceed to panic(). It also
adds a check for panic_in_progress() to correctly stop the CPU if panic
is already running on another CPU.

Closes: https://sashiko.dev/#/patchset/20260705164123.18746-1-include@grrlz.net
Closes: https://sashiko.dev/#/patchset/20260707172252.4842-1-include@grrlz.net

> diff --git a/kernel/panic.c b/kernel/panic.c
> index 213725b612aa1..010b331658b6b 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c

[ ... ]

> @@ -396,16 +397,20 @@ static bool panic_try_force_cpu(const char *fmt, va_list args)
>  		return false;
>  	}
>  
> -	/* Another panic already in progress */
> +	/*
> +	 * Don't redirect when a panic is already in progress. Stop this
> +	 * CPU when it's another one, proceed when it's this one.
> +	 */
>  	if (panic_in_progress())
> -		return false;
> +		return panic_on_other_cpu();

[Severity: High]
When panic is claimed by another CPU, panic_try_force_cpu() returns true and
causes the caller to mark this CPU offline. Does this hide the CPU from the
kdump NMI shootdown?

If multiple CPUs panic simultaneously, the caller in vpanic() blindly sets
the CPU offline for all 'true' returns:

kernel/panic.c:vpanic() {
    ...
	if (panic_try_force_cpu(fmt, args)) {
		set_cpu_online(smp_processor_id(), false);
		panic_smp_self_stop();
	}
    ...
}

Will this cause kdump NMI shootdown to bypass these offline CPUs (e.g., via
cpu_online_mask iteration or aborting early when num_online_cpus() < 2),
resulting in their CPU registers and backtraces being permanently omitted from
the crash dump?

>  
>  	/*
> -	 * Only one CPU can do the redirect. Use atomic cmpxchg to ensure
> -	 * we don't race with another CPU also trying to redirect.
> +	 * Only one CPU can do the redirection. Others should go offline.
> +	 * Continue with panic() when we already tried the redirection
> +	 * from this CPU before, for example via nmi_panic().
>  	 */
>  	if (!atomic_try_cmpxchg(&panic_redirect_cpu, &old_cpu, this_cpu))
> -		return false;
> +		return old_cpu != this_cpu;

[Severity: High]
Similarly, if this CPU loses the redirect cmpxchg race, this returns true.
Does this also cause vpanic() to erroneously set this CPU offline, preventing
kdump from capturing its crash state?

>  
>  	/*
>  	 * Use dynamically allocated buffer if available, otherwise

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916182957.7788-1-brads@mainlining.org?part=1

  reply	other threads:[~2026-09-16 18:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 18:29 [PATCH v7 0/6] panic: fix panic_force_cpu= redirect races and NMI bypass Bradley Morgan
2026-09-16 18:29 ` [PATCH v7 1/6] panic: fix redirect CPU race in panic_try_force_cpu() Bradley Morgan
2026-09-16 18:42   ` sashiko-bot [this message]
2026-09-16 19:48     ` Bradley Morgan
2026-09-16 18:29 ` [PATCH v7 2/6] panic: flatten nmi_panic control flow Bradley Morgan
2026-09-16 18:29 ` [PATCH v7 3/6] panic: fix va_list reuse in panic_try_force_cpu() Bradley Morgan
2026-09-16 18:29 ` [PATCH v7 4/6] panic: restore variable arguments to nmi_panic() Bradley Morgan
2026-09-22 12:14   ` Petr Mladek
2026-09-16 18:29 ` [PATCH v7 5/6] panic: allow force_cpu redirect from an NMI Bradley Morgan
2026-09-16 18:29 ` [PATCH v7 6/6] panic: kill the "buffer unavailable" redirect fallback Bradley Morgan
2026-09-22 12:28   ` Petr Mladek
2026-09-22 12:35 ` [PATCH v7 0/6] panic: fix panic_force_cpu= redirect races and NMI bypass Petr Mladek
2026-09-22 14:41   ` Bradley Morgan
2026-09-22 23:22     ` Andrew Morton

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=20260916184215.8FF411F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=brads@mainlining.org \
    --cc=linux-watchdog@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox