diff options
author | Masami Hiramatsu <mhiramat@kernel.org> | 2018-03-12 06:00:49 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-03-12 11:16:00 -0400 |
commit | b6b76dd62c56f257cdd30900ed22668c42a74030 (patch) | |
tree | 14c8d11284da90abb655fcc9c1da1e5231dde6aa /kernel/fail_function.c | |
parent | 9e5fb7207024e53700bdac23f53d1e44d530a7f6 (diff) |
error-injection: Fix to prohibit jump optimization
Since the kprobe which was optimized by jump can not change
the execution path, the kprobe for error-injection must not
be optimized. To prohibit it, set a dummy post-handler as
officially stated in Documentation/kprobes.txt.
Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework")
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'kernel/fail_function.c')
-rw-r--r-- | kernel/fail_function.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/fail_function.c b/kernel/fail_function.c index 21b0122cb39c..1d5632d8bbcc 100644 --- a/kernel/fail_function.c +++ b/kernel/fail_function.c | |||
@@ -14,6 +14,15 @@ | |||
14 | 14 | ||
15 | static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs); | 15 | static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs); |
16 | 16 | ||
17 | static void fei_post_handler(struct kprobe *kp, struct pt_regs *regs, | ||
18 | unsigned long flags) | ||
19 | { | ||
20 | /* | ||
21 | * A dummy post handler is required to prohibit optimizing, because | ||
22 | * jump optimization does not support execution path overriding. | ||
23 | */ | ||
24 | } | ||
25 | |||
17 | struct fei_attr { | 26 | struct fei_attr { |
18 | struct list_head list; | 27 | struct list_head list; |
19 | struct kprobe kp; | 28 | struct kprobe kp; |
@@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr) | |||
56 | return NULL; | 65 | return NULL; |
57 | } | 66 | } |
58 | attr->kp.pre_handler = fei_kprobe_handler; | 67 | attr->kp.pre_handler = fei_kprobe_handler; |
68 | attr->kp.post_handler = fei_post_handler; | ||
59 | attr->retval = adjust_error_retval(addr, 0); | 69 | attr->retval = adjust_error_retval(addr, 0); |
60 | INIT_LIST_HEAD(&attr->list); | 70 | INIT_LIST_HEAD(&attr->list); |
61 | } | 71 | } |