Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kprobes: treewide: Replace arch_deref_entry_point() with dereference_symbol_descriptor()

~15 years ago kprobes grew the 'arch_deref_entry_point()' __weak function:

3d7e33825d87: ("jprobes: make jprobes a little safer for users")

But this is just open-coded dereference_symbol_descriptor() in essence, and
its obscure nature was causing bugs.

Just use the real thing and remove arch_deref_entry_point().

Link: https://lkml.kernel.org/r/163163043630.489837.7924988885652708696.stgit@devnote2

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Tested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
f2ec8d9a a7fe2378

+3 -24
-5
arch/ia64/kernel/kprobes.c
··· 891 891 return ret; 892 892 } 893 893 894 - unsigned long arch_deref_entry_point(void *entry) 895 - { 896 - return ((struct fnptr *)entry)->ip; 897 - } 898 - 899 894 static struct kprobe trampoline_p = { 900 895 .pre_handler = trampoline_probe_handler 901 896 };
-11
arch/powerpc/kernel/kprobes.c
··· 542 542 } 543 543 NOKPROBE_SYMBOL(kprobe_fault_handler); 544 544 545 - unsigned long arch_deref_entry_point(void *entry) 546 - { 547 - #ifdef PPC64_ELF_ABI_v1 548 - if (!kernel_text_address((unsigned long)entry)) 549 - return ppc_global_function_entry(entry); 550 - else 551 - #endif 552 - return (unsigned long)entry; 553 - } 554 - NOKPROBE_SYMBOL(arch_deref_entry_point); 555 - 556 545 static struct kprobe trampoline_p = { 557 546 .addr = (kprobe_opcode_t *) &kretprobe_trampoline, 558 547 .pre_handler = trampoline_probe_handler
-1
include/linux/kprobes.h
··· 381 381 void unregister_kprobe(struct kprobe *p); 382 382 int register_kprobes(struct kprobe **kps, int num); 383 383 void unregister_kprobes(struct kprobe **kps, int num); 384 - unsigned long arch_deref_entry_point(void *); 385 384 386 385 int register_kretprobe(struct kretprobe *rp); 387 386 void unregister_kretprobe(struct kretprobe *rp);
+1 -6
kernel/kprobes.c
··· 1861 1861 .priority = 0x7fffffff /* we need to be notified first */ 1862 1862 }; 1863 1863 1864 - unsigned long __weak arch_deref_entry_point(void *entry) 1865 - { 1866 - return (unsigned long)entry; 1867 - } 1868 - 1869 1864 #ifdef CONFIG_KRETPROBES 1870 1865 1871 1866 unsigned long __kretprobe_trampoline_handler(struct pt_regs *regs, ··· 2322 2327 int ret; 2323 2328 2324 2329 for (iter = start; iter < end; iter++) { 2325 - entry = arch_deref_entry_point((void *)*iter); 2330 + entry = (unsigned long)dereference_symbol_descriptor((void *)*iter); 2326 2331 ret = kprobe_add_ksym_blacklist(entry); 2327 2332 if (ret == -EINVAL) 2328 2333 continue;
+2 -1
lib/error-inject.c
··· 8 8 #include <linux/mutex.h> 9 9 #include <linux/list.h> 10 10 #include <linux/slab.h> 11 + #include <asm/sections.h> 11 12 12 13 /* Whitelist of symbols that can be overridden for error injection. */ 13 14 static LIST_HEAD(error_injection_list); ··· 65 64 66 65 mutex_lock(&ei_mutex); 67 66 for (iter = start; iter < end; iter++) { 68 - entry = arch_deref_entry_point((void *)iter->addr); 67 + entry = (unsigned long)dereference_symbol_descriptor((void *)iter->addr); 69 68 70 69 if (!kernel_text_address(entry) || 71 70 !kallsyms_lookup_size_offset(entry, &size, &offset)) {