Skip to contentSkip to conversation

kernel/kallsyms: Prevent bypassing of kprobes blacklist

PATCH NAK Elly I. Esparza 3 participants 3 messages Feb 18 – Feb 19

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 kernel/kallsyms: Prevent bypassing of kprobes blacklist

Kprobes can be used to get the adress of kallsyms_lookup_name() providing access to blacklisted symbols.

Add kallsyms_lookup_name() to kprobes blacklist.

---
 kernel/kallsyms.c | 1 +
 1 file changed, 1 insertion(+)
kernel/kallsyms.c +1 -0
index 1e7635864124..13a7c0fdb5da 100644
@@ -234,6 +234,7 @@ unsigned long kallsyms_lookup_name(const char *name)
 
 	return module_kallsyms_lookup_name(name);
 }
+NOKPROBE_SYMBOL(kallsyms_lookup_name)
 
 /*
  * Iterate over all symbols in vmlinux.  For symbols from modules use
Signature · 1 line
2.43.0
#1 lore raw
Quoted 4 lines · On Wed, 18 Feb 2026 11:48:19 -0300 "Elly I. Esparza" <[email protected]>…

Kprobes can be used to get the adress of kallsyms_lookup_name() providing access to blacklisted symbols.

Add kallsyms_lookup_name() to kprobes blacklist.

NACK, this NOKPROBE_SYMBOL() should be used for the functions which is called inside the kprobe callback handler. kallsyms_lookup_name() is used when setting up the kprobe, not from the callbacks.

Thanks,

Quoted 21 lines
---
 kernel/kallsyms.c | 1 +
 1 file changed, 1 insertion(+)
kernel/kallsyms.c +1 -0
index 1e7635864124..13a7c0fdb5da 100644
@@ -234,6 +234,7 @@ unsigned long kallsyms_lookup_name(const char *name)
 
 	return module_kallsyms_lookup_name(name);
 }
+NOKPROBE_SYMBOL(kallsyms_lookup_name)
 
 /*
  * Iterate over all symbols in vmlinux.  For symbols from modules use
Signature · 1 line
2.43.0
Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>
#2 lore raw
Quoted 11 lines · Masami Hiramatsu
Quoted 4 lines · On Wed, 18 Feb 2026 11:48:19 -0300 "Elly I. Esparza" <[email protected]>…

Kprobes can be used to get the adress of kallsyms_lookup_name() providing access to blacklisted symbols.

Add kallsyms_lookup_name() to kprobes blacklist.

NACK, this NOKPROBE_SYMBOL() should be used for the functions which is called inside the kprobe callback handler. kallsyms_lookup_name() is used when setting up the kprobe, not from the callbacks.

I don't think that's the point Elly made. The point is that kallsyms_lookup_name + kprobes is used to bypass lacking symbol exports. So preventing it is a good idea, and this seems like a cute hack for that. But it really needs a better commit log, and a big fat comment explaining the slight abuse of NOKPROBE_SYMBOL in the code.