diff options
-rw-r--r-- | include/linux/kprobes.h | 3 | ||||
-rw-r--r-- | kernel/kprobes.c | 2 | ||||
-rw-r--r-- | kernel/trace/trace_kprobe.c | 5 |
3 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h index 30f90c1a0aaf..541df0b5b815 100644 --- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h | |||
@@ -349,6 +349,9 @@ extern int proc_kprobes_optimization_handler(struct ctl_table *table, | |||
349 | int write, void __user *buffer, | 349 | int write, void __user *buffer, |
350 | size_t *length, loff_t *ppos); | 350 | size_t *length, loff_t *ppos); |
351 | #endif | 351 | #endif |
352 | extern void wait_for_kprobe_optimizer(void); | ||
353 | #else | ||
354 | static inline void wait_for_kprobe_optimizer(void) { } | ||
352 | #endif /* CONFIG_OPTPROBES */ | 355 | #endif /* CONFIG_OPTPROBES */ |
353 | #ifdef CONFIG_KPROBES_ON_FTRACE | 356 | #ifdef CONFIG_KPROBES_ON_FTRACE |
354 | extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, | 357 | extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip, |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 7367e0ec6f81..199243bba554 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -595,7 +595,7 @@ static void kprobe_optimizer(struct work_struct *work) | |||
595 | } | 595 | } |
596 | 596 | ||
597 | /* Wait for completing optimization and unoptimization */ | 597 | /* Wait for completing optimization and unoptimization */ |
598 | static void wait_for_kprobe_optimizer(void) | 598 | void wait_for_kprobe_optimizer(void) |
599 | { | 599 | { |
600 | mutex_lock(&kprobe_mutex); | 600 | mutex_lock(&kprobe_mutex); |
601 | 601 | ||
diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 8485f6738a87..c129fca6ec99 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c | |||
@@ -1535,6 +1535,11 @@ static __init int kprobe_trace_self_tests_init(void) | |||
1535 | 1535 | ||
1536 | end: | 1536 | end: |
1537 | release_all_trace_kprobes(); | 1537 | release_all_trace_kprobes(); |
1538 | /* | ||
1539 | * Wait for the optimizer work to finish. Otherwise it might fiddle | ||
1540 | * with probes in already freed __init text. | ||
1541 | */ | ||
1542 | wait_for_kprobe_optimizer(); | ||
1538 | if (warn) | 1543 | if (warn) |
1539 | pr_cont("NG: Some tests are failed. Please check them.\n"); | 1544 | pr_cont("NG: Some tests are failed. Please check them.\n"); |
1540 | else | 1545 | else |