Skip to contentSkip to conversation

kallsyms-cleanup-code-for-appending-the-module-buildid.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jan 21

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: kallsyms: cleanup code for appending the module buildid
has been removed from the -mm tree. Its filename was
kallsyms-cleanup-code-for-appending-the-module-buildid.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: Petr Mladek <[email protected]>
Subject: kallsyms: cleanup code for appending the module buildid
Date: Fri, 28 Nov 2025 14:59:17 +0100

Put the code for appending the optional "buildid" into a helper function, It makes __sprint_symbol() better readable.

Also print a warning when the "modname" is set and the "buildid" isn't. It might catch a situation when some lookup function in kallsyms_lookup_buildid() does not handle the "buildid".

Use pr_*_once() to avoid an infinite recursion when the function is called from printk(). The recursion is rather theoretical but better be on the safe side.

Cc Aaron Tomlin <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkman <[email protected]>
Cc Daniel Gomez <[email protected]>
Cc John Fastabend <[email protected]>
Cc Kees Cook <[email protected]>
Cc Luis Chamberalin <[email protected]>
Cc Marc Rutland <[email protected]>
Cc "Masami Hiramatsu (Google)" <[email protected]>
Cc Petr Pavlu <[email protected]>
Cc Sami Tolvanen <[email protected]>
Cc Steven Rostedt (Google) <[email protected]>

---

 kernel/kallsyms.c |   42 +++++++++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 9 deletions(-)
kernel/kallsyms.c renamed from kernel/kallsyms.c~kallsyms-cleanup-code-for-appending-the-module-buildid +33 -9
@@ -435,6 +435,37 @@ int lookup_symbol_name(unsigned long add
 	return lookup_module_symbol_name(addr, symname);
 }
 
+#ifdef CONFIG_STACKTRACE_BUILD_ID
+
+static int append_buildid(char *buffer,  const char *modname,
+			  const unsigned char *buildid)
+{
+	if (!modname)
+		return 0;
+
+	if (!buildid) {
+		pr_warn_once("Undefined buildid for the module %s\n", modname);
+		return 0;
+	}
+
+	/* build ID should match length of sprintf */
+#ifdef CONFIG_MODULES
+	static_assert(sizeof(typeof_member(struct module, build_id)) == 20);
+#endif
+
+	return sprintf(buffer, " %20phN", buildid);
+}
+
+#else /* CONFIG_STACKTRACE_BUILD_ID */
+
+static int append_buildid(char *buffer,   const char *modname,
+			  const unsigned char *buildid)
+{
+	return 0;
+}
+
+#endif /* CONFIG_STACKTRACE_BUILD_ID */
+
 /* Look up a kernel symbol and return it in a text buffer. */
 static int __sprint_symbol(char *buffer, unsigned long address,
 			   int symbol_offset, int add_offset, int add_buildid)
@@ -457,15 +488,8 @@ static int __sprint_symbol(char *buffer,
 
 	if (modname) {
 		len += sprintf(buffer + len, " [%s", modname);
-#if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
-		if (add_buildid && buildid) {
-			/* build ID should match length of sprintf */
-#if IS_ENABLED(CONFIG_MODULES)
-			static_assert(sizeof(typeof_member(struct module, build_id)) == 20);
-#endif
-			len += sprintf(buffer + len, " %20phN", buildid);
-		}
-#endif
+		if (add_buildid)
+			len += append_buildid(buffer + len, modname, buildid);
 		len += sprintf(buffer + len, "]");
 	}
 

_

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