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] [day] [month] [year] [list]
Message-ID: <20260203065721.46089-1-suzhidao@xiaomi.com>
Date: Tue,  3 Feb 2026 14:57:21 +0800
From: zhidao su <soolaugust@...il.com>
To: soolaugust@...il.com
Cc: arighi@...dia.com,
	changwoo@...lia.com,
	emil@...alapatis.com,
	linux-kernel@...r.kernel.org,
	sched-ext@...ts.linux.dev,
	tj@...nel.org,
	void@...ifault.com,
	zhidao su <suzhidao@...omi.com>
Subject: [PATCH] tools/sched_ext: Improve BPF verifier arena detection workaround

Replace bpf_printk() with volatile access in scx_sdt scheduler's
BPF verifier workaround to eliminate console output while maintaining
the required LD.IMM instruction generation for arena detection.

This addresses the side effect issue of the previous hack while
preserving the essential functionality needed by the BPF verifier.

Signed-off-by: zhidao su <suzhidao@...omi.com>
---
 tools/sched_ext/scx_sdt.bpf.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/sched_ext/scx_sdt.bpf.c b/tools/sched_ext/scx_sdt.bpf.c
index 31b09958e8d5..13d3060c99ff 100644
--- a/tools/sched_ext/scx_sdt.bpf.c
+++ b/tools/sched_ext/scx_sdt.bpf.c
@@ -64,14 +64,10 @@ DEFINE_SDT_STAT(select_busy_cpu);
 static __u64 zero = 0;
 
 /*
- * XXX Hack to get the verifier to find the arena for sdt_exit_task.
- * As of 6.12-rc5, The verifier associates arenas with programs by
- * checking LD.IMM instruction operands for an arena and populating
- * the program state with the first instance it finds. This requires
- * accessing our global arena variable, but scx methods do not necessarily
- * do so while still using pointers from that arena. Insert a bpf_printk
- * statement that triggers at most once to generate an LD.IMM instruction
- * to access the arena and help the verifier.
+ * Workaround to help BPF verifier track arena usage.
+ * The verifier needs to see an explicit reference to the arena variable
+ * to properly track arena memory usage. This generates the required
+ * LD.IMM instruction without producing unnecessary output.
  */
 static volatile bool scx_arena_verify_once;
 
@@ -80,7 +76,11 @@ __hidden void scx_arena_subprog_init(void)
 	if (scx_arena_verify_once)
 		return;
 
-	bpf_printk("%s: arena pointer %p", __func__, &arena);
+	/*
+	 * Use volatile access to generate LD.IMM instruction without
+	 * producing console output like bpf_printk does.
+	 */
+	(void)*(volatile void **)&arena;
 	scx_arena_verify_once = true;
 }
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ