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: <1738629964-11977-2-git-send-email-kazuhiro3.hayashi@toshiba.co.jp>
Date: Tue,  4 Feb 2025 09:46:03 +0900
From: Kazuhiro Hayashi <kazuhiro3.hayashi@...hiba.co.jp>
To: linux-kernel@...r.kernel.org, linux-rt-devel@...ts.linux.dev,
        cip-dev@...ts.cip-project.org
Cc: bigeasy@...utronix.de, tglx@...utronix.de, rostedt@...dmis.org,
        linux-rt-users@...r.kernel.org, pavel@...x.de
Subject: [PATCH 4.4 4.9 v1 1/2] init: Introduce system_scheduling flag for allocate_slab()

Between v4.14-rt and v5.10-rt, allocate_slab() is responsible for enabling
IRQ before running the following SLAB allocation functions if
    system_state >= SYSTEM_SCHEDULING
However, SYSTEM_SCHEDULING is introduced[1] in the mainline v4.13 and
it's not reasonable to backport all related changes into older RT kernels
from functional compatibility and longer term maintenance perspectives.

Thus, as an alternative (but non-mainline) way, introduce an extra flag
"system_scheduling" which becomes true at the same point as
    system_state = SYSTEM_SCHEDULING
in the mainline, so that the existing system_states and users of them
are not affected.

allocate_slab() will use this flag for its IRQ control by the upcoming change.

[1] https://lore.kernel.org/all/20170516184231.564888231@linutronix.de/

Signed-off-by: Kazuhiro Hayashi <kazuhiro3.hayashi@...hiba.co.jp>
Reviewed-by: Pavel Machek <pavel@...x.de>
---
 include/linux/kernel.h |  1 +
 init/main.c            | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d68f639f7330..2a15e829aaec 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -490,6 +490,7 @@ extern enum system_states {
 	SYSTEM_RESTART,
 	SYSTEM_SUSPEND,
 } system_state;
+extern bool system_scheduling;
 
 #define TAINT_PROPRIETARY_MODULE	0
 #define TAINT_FORCED_MODULE		1
diff --git a/init/main.c b/init/main.c
index 9933fca3a5c8..4f382179b61e 100644
--- a/init/main.c
+++ b/init/main.c
@@ -110,6 +110,14 @@ bool early_boot_irqs_disabled __read_mostly;
 enum system_states system_state __read_mostly;
 EXPORT_SYMBOL(system_state);
 
+/*
+ * This corresponds to system_state >= SYSTEM_SCHEDULING in the mainline.
+ * On PREEMPT_RT kernels, slab allocator requires this state to check if
+ * the allocation must be run with IRQ enabled or not.
+ */
+bool system_scheduling __read_mostly = false;
+EXPORT_SYMBOL(system_scheduling);
+
 /*
  * Boot command-line arguments
  */
@@ -401,6 +409,10 @@ static noinline void __init_refok rest_init(void)
 	rcu_read_lock();
 	kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
 	rcu_read_unlock();
+
+	/* Corresponds to system_state = SYSTEM_SCHEDULING in the mainline */
+	system_scheduling = true;
+
 	complete(&kthreadd_done);
 
 	/*
-- 
2.30.2



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ