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: <20250924080119.005422353@infradead.org>
Date: Wed, 24 Sep 2025 09:59:54 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: jpoimboe@...nel.org,
 rostedt@...nel.org
Cc: linux-kernel@...r.kernel.org,
 peterz@...radead.org
Subject: [PATCH 06/12] unwind: Fix unwind_deferred_request() vs NMI

task_work_add(RWA_RESUME) isn't NMI-safe, use TWA_NMI_CURRENT when
used from NMI context.

Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
 kernel/unwind/deferred.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

--- a/kernel/unwind/deferred.c
+++ b/kernel/unwind/deferred.c
@@ -231,6 +231,7 @@ void unwind_deferred_task_exit(struct ta
 int unwind_deferred_request(struct unwind_work *work, u64 *cookie)
 {
 	struct unwind_task_info *info = &current->unwind_info;
+	int twa_mode = TWA_RESUME;
 	unsigned long old, bits;
 	unsigned long bit;
 	int ret;
@@ -246,8 +247,11 @@ int unwind_deferred_request(struct unwin
 	 * Trigger a warning to make it obvious that an architecture
 	 * is using this in NMI when it should not be.
 	 */
-	if (WARN_ON_ONCE(!CAN_USE_IN_NMI && in_nmi()))
-		return -EINVAL;
+	if (in_nmi()) {
+		if (WARN_ON_ONCE(!CAN_USE_IN_NMI))
+			return -EINVAL;
+		twa_mode = TWA_NMI_CURRENT;
+	}
 
 	/* Do not allow cancelled works to request again */
 	bit = READ_ONCE(work->bit);
@@ -285,7 +289,7 @@ int unwind_deferred_request(struct unwin
 	}
 
 	/* The work has been claimed, now schedule it. */
-	ret = task_work_add(current, &info->work, TWA_RESUME);
+	ret = task_work_add(current, &info->work, twa_mode);
 
 	if (WARN_ON_ONCE(ret))
 		WRITE_ONCE(info->unwind_mask, 0);



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ