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: <20250327205355.378659-24-mingo@kernel.org>
Date: Thu, 27 Mar 2025 21:53:36 +0100
From: Ingo Molnar <mingo@...nel.org>
To: linux-kernel@...r.kernel.org
Cc: Juergen Gross <jgross@...e.com>,
	"H . Peter Anvin" <hpa@...or.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Borislav Petkov <bp@...en8.de>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH 23/41] x86/alternatives: Remove the 'addr == NULL means forced-flush' hack from text_poke_int3_finish()/text_poke_int3_flush()/tp_addr_ordered()

There's this weird hack used by text_poke_int3_finish() to indicate
a 'forced flush':

	text_poke_int3_flush(NULL);

Just open-code the vector-flush in a straightforward fashion:

	text_poke_int3_batch(tp_vec, tp_vec_nr);
	tp_vec_nr = 0;

And get rid of !addr hack from tp_addr_ordered().

Leave a WARN_ON_ONCE(), just in case some external code learned
to rely on this behavior.

Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 arch/x86/kernel/alternative.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 938e8e70a379..906fb45b9e65 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -2847,12 +2847,11 @@ static bool tp_addr_ordered(void *addr)
 {
 	struct text_poke_int3_loc *tp;
 
+	WARN_ON_ONCE(!addr);
+
 	if (!tp_vec_nr)
 		return true;
 
-	if (!addr) /* force */
-		return false;
-
 	/*
 	 * If the last current entry's address is higher than the
 	 * new entry's address we'd like to add, then ordering
@@ -2866,6 +2865,14 @@ static bool tp_addr_ordered(void *addr)
 	return true;
 }
 
+void text_poke_int3_finish(void)
+{
+	if (tp_vec_nr) {
+		text_poke_int3_batch(tp_vec, tp_vec_nr);
+		tp_vec_nr = 0;
+	}
+}
+
 static void text_poke_int3_flush(void *addr)
 {
 	lockdep_assert_held(&text_mutex);
@@ -2876,11 +2883,6 @@ static void text_poke_int3_flush(void *addr)
 	}
 }
 
-void text_poke_int3_finish(void)
-{
-	text_poke_int3_flush(NULL);
-}
-
 void __ref text_poke_int3_queue(void *addr, const void *opcode, size_t len, const void *emulate)
 {
 	struct text_poke_int3_loc *tp;
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ