From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from confino.investici.org (confino.investici.org [93.190.126.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 487162EA154 for ; Tue, 7 Jul 2026 17:22:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.190.126.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783444983; cv=none; b=XjDmZBlQ8UQw/HkKXzNWZkm3ZU+3ubEPQILfs+iEn1xqgpGA6527RwIEVMiDgrVDn5IfjOWokTxgadmT4oyYjVFRjajbMt0USiwsWJbTt3tzQWCboZ75NUaY5fY6OHfUw8FEJlTfB+8CnXAXNqzckG+3w4EwDQmcFZSV0Z2XN0U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783444983; c=relaxed/simple; bh=+OuKiiSdU9odRhqlFQ/RjMWCvpUkSLYHqa7yOpLB1ZU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AKvGiOabxoPEHNGxdMJM7An6mU6yUXXzlJ2cIKyG0+TRJUkV9nAFzhEZ45I5G3eSsM4TWQIJPL6DwN6hqqN4Sl0ZVFBLdV+M5qTlRxYi1BjJ/T5MKe7ZtYFWO+hkuZDYO11DSy+Pn2+gp6uW9D7ZxOANybNM+9Kq9snGUhqg4xM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net; spf=pass smtp.mailfrom=grrlz.net; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b=aMEwkJoZ; arc=none smtp.client-ip=93.190.126.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=grrlz.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=grrlz.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=grrlz.net header.i=@grrlz.net header.b="aMEwkJoZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=grrlz.net; s=stigmate; t=1783444972; bh=xd1UWJUQkt1iTuzrTXhVO7f6BfJALX9RG5NI5p5fDO8=; h=From:To:Cc:Subject:Date:From; b=aMEwkJoZdUBX+Vu6qquEeXCgIqJwtyvRJr4mO+UIfHHY9rYj7PYkPLczbaU9w3jrf Chef3OfFhQJ+UFTa4R2Du12YHgcfO68j8MkpLgcU09aF7o9bRbdNvEmtXWZ3+nJjau XeJRIS0lX2BbzIWR0+V+ucXA0g7vVKlkEoDFLyq4= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4gvp2h2Xc9z10xX; Tue, 07 Jul 2026 17:22:52 +0000 (UTC) Received: by mx1.investici.org (Postfix) id 4gvp2g4zpHz10wt; Tue, 07 Jul 2026 17:22:51 +0000 (UTC) From: Bradley Morgan To: akpm@linux-foundation.org Cc: pmladek@suse.com, feng.tang@linux.alibaba.com, include@grrlz.net, linux-kernel@vger.kernel.org Subject: [PATCH] panic: stop CPUs that lose the panic_redirect_cpu race Date: Tue, 7 Jul 2026 17:22:52 +0000 Message-ID: <20260707172252.4842-1-include@grrlz.net> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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