error-injection: Fix to prohibit jump optimization
Subsystems (3)
PATCH 1/1 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.
--- kernel/fail_function.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/fail_function.c +10 -0
@@ -14,6 +14,15 @@static int fei_kprobe_handler (struct kprobe *kp,struct pt_regs *regs); +static void fei_post_handler (struct kprobe *kp,struct pt_regs *regs, +unsigned long flags) +{ +/* +* A dummy post handler is required to prohibit optimizing, because +* jump optimization does not support execution path overriding. +*/ +} +struct fei_attr {struct list_head list;struct kprobe kp;
@@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr)return NULL ; } attr->kp.pre_handler = fei_kprobe_handler; + attr->kp.post_handler = fei_post_handler; attr->retval =adjust_error_retval (addr,0 );INIT_LIST_HEAD (&attr->list); }
Quoted 4 lines · On Mon, 12 Mar 2018 19:00:49 +0900 Masami Hiramatsu <[email protected]> wrote:
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.
Note that trace-probe based BPF is not affected, because it ensures the trace-probe is based on ftrace, which is not jump optimized.
Thanks,
Quoted 36 lines
Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")Signed-off-by Masami Hiramatsu <[email protected]>--- kernel/fail_function.c | 10 ++++++++++ 1 file changed, 10 insertions(+)kernel/fail_function.c +10
-0@@ -14,6 +14,15 @@static int fei_kprobe_handler (struct kprobe *kp,struct pt_regs *regs); +static void fei_post_handler (struct kprobe *kp,struct pt_regs *regs, +unsigned long flags) +{ +/* +* A dummy post handler is required to prohibit optimizing, because +* jump optimization does not support execution path overriding. +*/ +} +struct fei_attr {struct list_head list;struct kprobe kp;@@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr)return NULL ; } attr->kp.pre_handler = fei_kprobe_handler; + attr->kp.post_handler = fei_post_handler; attr->retval =adjust_error_retval (addr,0 );INIT_LIST_HEAD (&attr->list); }
Signature · 1 line
Masami Hiramatsu <[email protected]>
Hi Masami,
Quoted 11 lines · Masami Hiramatsu
Quoted 4 lines · On Mon, 12 Mar 2018 19:00:49 +0900 Masami Hiramatsu <[email protected]> wrote:
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.Note that trace-probe based BPF is not affected, because it ensures the trace-probe is based on ftrace, which is not jump optimized.
Thanks for the fix! I presume this should go via bpf instead of bpf-next tree since 4b1a29a7f542 ("error-injection: Support fault injection framework") is in Linus' tree as well. Unless there are objection I would rather route it that way so it would be for 4.16.
Thanks,
Daniel
Quoted 40 lines
Thanks,
Quoted 36 lines
Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")Signed-off-by Masami Hiramatsu <[email protected]>--- kernel/fail_function.c | 10 ++++++++++ 1 file changed, 10 insertions(+)kernel/fail_function.c +10
-0@@ -14,6 +14,15 @@static int fei_kprobe_handler (struct kprobe *kp,struct pt_regs *regs); +static void fei_post_handler (struct kprobe *kp,struct pt_regs *regs, +unsigned long flags) +{ +/* +* A dummy post handler is required to prohibit optimizing, because +* jump optimization does not support execution path overriding. +*/ +} +struct fei_attr {struct list_head list;struct kprobe kp;@@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr)return NULL ; } attr->kp.pre_handler = fei_kprobe_handler; + attr->kp.post_handler = fei_post_handler; attr->retval =adjust_error_retval (addr,0 );INIT_LIST_HEAD (&attr->list); }
Quoted 11 lines · On Mon, 12 Mar 2018 11:44:21 +0100 Daniel Borkmann <[email protected]> wrote:
Hi Masami,
Quoted 8 lines · Masami Hiramatsu
Quoted 4 lines · On Mon, 12 Mar 2018 19:00:49 +0900 Masami Hiramatsu <[email protected]> wrote:
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.
Quoted 8 lines
Quoted 3 lines
Note that trace-probe based BPF is not affected, because it ensures the trace-probe is based on ftrace, which is not jump optimized.
Thanks for the fix! I presume this should go via bpf instead of bpf-next tree since
4b1a29a7f542("error-injection: Support fault injection framework") is in Linus' tree as well. Unless there are objection I would rather route it that way so it would be for 4.16.
Ah, right! It should go into 4.16. It should be applicable cleanly either tree since there is only the above commit on kernel/fail_function.c :)
Thanks,
Quoted 45 lines
Thanks,
DanielQuoted 40 lines
Thanks,
Quoted 36 lines
Fixes 4b1a29a7f542 ("error-injection: Support fault injection framework")Signed-off-by Masami Hiramatsu <[email protected]>--- kernel/fail_function.c | 10 ++++++++++ 1 file changed, 10 insertions(+)kernel/fail_function.c +10
-0@@ -14,6 +14,15 @@static int fei_kprobe_handler (struct kprobe *kp,struct pt_regs *regs); +static void fei_post_handler (struct kprobe *kp,struct pt_regs *regs, +unsigned long flags) +{ +/* +* A dummy post handler is required to prohibit optimizing, because +* jump optimization does not support execution path overriding. +*/ +} +struct fei_attr {struct list_head list;struct kprobe kp;@@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr)return NULL ; } attr->kp.pre_handler = fei_kprobe_handler; + attr->kp.post_handler = fei_post_handler; attr->retval =adjust_error_retval (addr,0 );INIT_LIST_HEAD (&attr->list); }
Signature · 1 line
Masami Hiramatsu <[email protected]>
Daniel Borkmann
AppliedQuoted 15 lines · Masami Hiramatsu
Quoted 13 lines · On Mon, 12 Mar 2018 11:44:21 +0100 Daniel Borkmann <[email protected]> wrote:
Quoted 11 lines · Masami Hiramatsu
Quoted 4 lines · On Mon, 12 Mar 2018 19:00:49 +0900 Masami Hiramatsu <[email protected]> wrote:
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.Note that trace-probe based BPF is not affected, because it ensures the trace-probe is based on ftrace, which is not jump optimized.
Quoted 7 lines
Quoted 4 lines
Thanks for the fix! I presume this should go via bpf instead of bpf-next tree since
4b1a29a7f542("error-injection: Support fault injection framework") is in Linus' tree as well. Unless there are objection I would rather route it that way so it would be for 4.16.Ah, right! It should go into 4.16. It should be applicable cleanly either tree since there is only the above commit on
kernel/fail_function.c:)
Applied to bpf tree, thanks Masami!