lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250820091702.512524-5-wangjinchao600@gmail.com>
Date: Wed, 20 Aug 2025 17:14:49 +0800
From: Jinchao Wang <wangjinchao600@...il.com>
To: pmladek@...e.com,
	akpm@...ux-foundation.org,
	Feng Tang <feng.tang@...ux.alibaba.com>,
	John Ogness <john.ogness@...utronix.de>,
	Joel Granados <joel.granados@...nel.org>,
	Jinchao Wang <wangjinchao600@...il.com>,
	Nam Cao <namcao@...utronix.de>,
	Sravan Kumar Gundu <sravankumarlpu@...il.com>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 4/9] panic: use panic_try_start() in nmi_panic()

nmi_panic() duplicated the logic to claim
panic_cpu with atomic_try_cmpxchg. This is
already wrapped in panic_try_start().

Replace the open-coded logic with
panic_try_start(), and use
panic_on_other_cpu() for the fallback path.

This removes duplication and keeps panic
handling code consistent.

Signed-off-by: Jinchao Wang <wangjinchao600@...il.com>
---
 kernel/panic.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index eacb0c972110..cd86d37d124c 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -355,15 +355,9 @@ EXPORT_SYMBOL(panic_on_other_cpu);
  */
 void nmi_panic(struct pt_regs *regs, const char *msg)
 {
-	int old_cpu, this_cpu;
-
-	old_cpu = PANIC_CPU_INVALID;
-	this_cpu = raw_smp_processor_id();
-
-	/* atomic_try_cmpxchg updates old_cpu on failure */
-	if (atomic_try_cmpxchg(&panic_cpu, &old_cpu, this_cpu))
+	if (panic_try_start())
 		panic("%s", msg);
-	else if (old_cpu != this_cpu)
+	else if (panic_on_other_cpu())
 		nmi_panic_self_stop(regs);
 }
 EXPORT_SYMBOL(nmi_panic);
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ