History

[PATCH] kprobes: no probes on critical path

For Kprobes critical path is the path from debug break exception handler till the control reaches kprobes exception code. No probes can be supported in this path as we will end up in recursion. This patch prevents this by moving the below function to safe __kprobes section onto which no probes can be inserted.

Keshavamurthy Anil S committed 20 years ago

Commit 00d7c051 parent cda315a2 files · +8 −2Browse files

Unified · Split

2 files
  1. include/linux/kprobes.h +6 −1
  2. kernel/sys.c +2 −1
include/linux/kprobes.h+6−1
@@ -37,6 +37,7 @@ · 36 unmodified lines
3737 #include <linux/spinlock.h>
3838 #include <linux/rcupdate.h>
3939
40+#ifdef CONFIG_KPROBES
4041 #include <asm/kprobes.h>
4142
4243 /* kprobe_status settings */
@@ -147,7 +148,6 @@ struct kretprobe_instance { · 104 unmodified lines
147148 struct task_struct *task;
148149 };
149150
150−#ifdef CONFIG_KPROBES
151151 extern spinlock_t kretprobe_lock;
152152 extern int arch_prepare_kprobe(struct kprobe *p);
153153 extern void arch_copy_kprobe(struct kprobe *p);
@@ -195,6 +195,11 @@ void add_rp_inst(struct kretprobe_instance *ri); · 41 unmodified lines
195195 void kprobe_flush_task(struct task_struct *tk);
196196 void recycle_rp_inst(struct kretprobe_instance *ri);
197197 #else /* CONFIG_KPROBES */
198+
199+#define __kprobes /**/
200+struct jprobe;
201+struct kretprobe;
202+
198203 static inline struct kprobe *kprobe_running(void)
199204 {
200205 return NULL;
kernel/sys.c+2−1
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232
3333 #include <linux/compat.h>
3434 #include <linux/syscalls.h>
35+#include <linux/kprobes.h>
3536
3637 #include <asm/uaccess.h>
3738 #include <asm/io.h>
@@ -168,7 +169,7 @@ EXPORT_SYMBOL(notifier_chain_unregister); · 130 unmodified lines
168169 * of the last notifier function called.
169170 */
170171
171−int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v)
172+int __kprobes notifier_call_chain(struct notifier_block **n, unsigned long val, void *v)
172173 {
173174 int ret=NOTIFY_DONE;
174175 struct notifier_block *nb = *n;