Skip to contentSkip to conversation

panic-sys_info-capture-si_bits_global-before-iterating-over-it.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Nov 20, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: panic: sys_info: capture si_bits_global before iterating over it
has been removed from the -mm tree. Its filename was
panic-sys_info-capture-si_bits_global-before-iterating-over-it.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Andy Shevchenko <[email protected]>
Subject: panic: sys_info: capture si_bits_global before iterating over it
Date: Thu, 30 Oct 2025 12:44:17 +0100

Patch series "panic: sys_info: Refactor and fix a potential issue", v3.

While targeting the compilation issue due to dangling variable, I have noticed more opportunities for refactoring that helps to avoid above mentioned compilation issue in a cleaner way and also fixes a potential problem with global variable access.

This patch (of 6):

The for-loop might re-read the content of the memory the si_bits_global points to on each iteration. Instead, just capture it for the sake of consistency and use that instead.

---

 lib/sys_info.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
lib/sys_info.c renamed from lib/sys_info.c~panic-sys_info-capture-si_bits_global-before-iterating-over-it +5 -2
@@ -58,11 +58,11 @@ int sysctl_sys_info_handler(const struct
 	char names[sizeof(sys_info_avail)];
 	struct ctl_table table;
 	unsigned long *si_bits_global;
+	unsigned long si_bits;
 
 	si_bits_global = ro_table->data;
 
 	if (write) {
-		unsigned long si_bits;
 		int ret;
 
 		table = *ro_table;
@@ -81,9 +81,12 @@ int sysctl_sys_info_handler(const struct
 		char *delim = "";
 		int i, len = 0;
 
+		/* The access to the global value is not synchronized. */
+		si_bits = READ_ONCE(*si_bits_global);
+
 		names[0] = '\0';
 		for (i = 0; i < ARRAY_SIZE(si_names); i++) {
-			if (*si_bits_global & si_names[i].bit) {
+			if (si_bits & si_names[i].bit) {
 				len += scnprintf(names + len, sizeof(names) - len,
 					"%s%s", delim, si_names[i].name);
 				delim = ",";

_

Patches currently in -mm which might be from [email protected] are