* [PATCH] panic: stop CPUs that lose the panic_redirect_cpu race
@ 2026-07-07 17:22 Bradley Morgan
2026-07-07 18:12 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Bradley Morgan @ 2026-07-07 17:22 UTC (permalink / raw)
To: akpm; +Cc: pmladek, feng.tang, include, linux-kernel
Loser of the redirect cmpxchg must stop, not fall through to
panic_try_start().
This issue was found by sashiko [1].
[1] https://sashiko.dev/#/patchset/20260705164123.18746-1-include%40grrlz.net
Signed-off-by: Bradley Morgan <include@grrlz.net>
---
kernel/panic.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/kernel/panic.c b/kernel/panic.c
index 03f1eef07b17..8ba3ec12db3a 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -400,12 +400,9 @@ static bool panic_try_force_cpu(const char *fmt, va_list args)
if (panic_in_progress())
return false;
- /*
- * 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 redirects, the loser stops and lets it finish. */
if (!atomic_try_cmpxchg(&panic_redirect_cpu, &old_cpu, this_cpu))
- return false;
+ return true;
/*
* Use dynamically allocated buffer if available, otherwise
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] panic: stop CPUs that lose the panic_redirect_cpu race
2026-07-07 17:22 [PATCH] panic: stop CPUs that lose the panic_redirect_cpu race Bradley Morgan
@ 2026-07-07 18:12 ` Andrew Morton
2026-07-07 18:15 ` Bradley Morgan
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2026-07-07 18:12 UTC (permalink / raw)
To: Bradley Morgan; +Cc: pmladek, feng.tang, linux-kernel
On Tue, 7 Jul 2026 17:22:52 +0000 Bradley Morgan <include@grrlz.net> wrote:
> Loser of the redirect cmpxchg must stop, not fall through to
> panic_try_start().
>
> This issue was found by sashiko [1].
>
> [1] https://sashiko.dev/#/patchset/20260705164123.18746-1-include%40grrlz.net
>
> ...
>
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -400,12 +400,9 @@ static bool panic_try_force_cpu(const char *fmt, va_list args)
> if (panic_in_progress())
> return false;
>
> - /*
> - * 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 redirects, the loser stops and lets it finish. */
> if (!atomic_try_cmpxchg(&panic_redirect_cpu, &old_cpu, this_cpu))
> - return false;
> + return true;
>
> /*
> * Use dynamically allocated buffer if available, otherwise
Sashiko is at it again:
https://sashiko.dev/#/patchset/20260707172252.4842-1-include@grrlz.net
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] panic: stop CPUs that lose the panic_redirect_cpu race
2026-07-07 18:12 ` Andrew Morton
@ 2026-07-07 18:15 ` Bradley Morgan
0 siblings, 0 replies; 3+ messages in thread
From: Bradley Morgan @ 2026-07-07 18:15 UTC (permalink / raw)
To: Andrew Morton; +Cc: pmladek, feng.tang, linux-kernel
On July 7, 2026 7:12:56 PM GMT+01:00, Andrew Morton
<akpm@linux-foundation.org> wrote:
>On Tue, 7 Jul 2026 17:22:52 +0000 Bradley Morgan <include@grrlz.net>
>wrote:
>
>> Loser of the redirect cmpxchg must stop, not fall through to
>> panic_try_start().
>>
>> This issue was found by sashiko [1].
>>
>> [1]
>https://sashiko.dev/#/patchset/20260705164123.18746-1-include%40grrlz.net
>>
>> ...
>>
>> --- a/kernel/panic.c
>> +++ b/kernel/panic.c
>> @@ -400,12 +400,9 @@ static bool panic_try_force_cpu(const char *fmt,
>va_list args)
>> if (panic_in_progress())
>> return false;
>>
>> - /*
>> - * 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 redirects, the loser stops and lets it finish. */
>> if (!atomic_try_cmpxchg(&panic_redirect_cpu, &old_cpu, this_cpu))
>> - return false;
>> + return true;
>>
>> /*
>> * Use dynamically allocated buffer if available, otherwise
>
>Sashiko is at it again:
> https://sashiko.dev/#/patchset/20260707172252.4842-1-include@grrlz.net
>
>
touche, already onto the fix.
I tend to overengineer, this time I UNDERengineered.
V2 is coming
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-07 18:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 17:22 [PATCH] panic: stop CPUs that lose the panic_redirect_cpu race Bradley Morgan
2026-07-07 18:12 ` Andrew Morton
2026-07-07 18:15 ` Bradley Morgan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox