Re: [PATCH] panic: stop CPUs that lose the panic_redirect_cpu race
From: Bradley Morgan
Date: Tue Jul 07 2026 - 14:17:53 EST
On July 7, 2026 7:12:56 PM GMT+01:00, Andrew Morton
<akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>On Tue, 7 Jul 2026 17:22:52 +0000 Bradley Morgan <include@xxxxxxxxx>
>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@xxxxxxxxx
>
>
touche, already onto the fix.
I tend to overengineer, this time I UNDERengineered.
V2 is coming
Thanks!