Skip to contentSkip to conversation

kallsyms-prevent-module-removal-when-printing-module-name-and-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: prevent module removal when printing module name and buildid
has been removed from the -mm tree. Its filename was
kallsyms-prevent-module-removal-when-printing-module-name-and-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: prevent module removal when printing module name and buildid
Date: Fri, 28 Nov 2025 14:59:20 +0100

kallsyms_lookup_buildid() copies the symbol name into the given buffer so that it can be safely read anytime later. But it just copies pointers to mod->name and mod->build_id which might get reused after the related struct module gets removed.

The lifetime of struct module is synchronized using RCU. Take the rcu read lock for the entire __sprint_symbol().

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 |    3 +++
 1 file changed, 3 insertions(+)
kernel/kallsyms.c renamed from kernel/kallsyms.c~kallsyms-prevent-module-removal-when-printing-module-name-and-buildid +3 -0
@@ -474,6 +474,9 @@ static int __sprint_symbol(char *buffer,
 	unsigned long offset, size;
 	int len;
 
+	/* Prevent module removal until modname and modbuildid are printed */
+	guard(rcu)();
+
 	address += symbol_offset;
 	len = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
 				       buffer);

_

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