Skip to content

Commit b6b76dd

Browse files
mhiramatborkmann
authored andcommitted
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: 4b1a29a ("error-injection: Support fault injection framework") Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 9e5fb72 commit b6b76dd

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

kernel/fail_function.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515
static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs);
1616

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+
1726
struct fei_attr {
1827
struct list_head list;
1928
struct kprobe kp;
@@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr)
5665
return NULL;
5766
}
5867
attr->kp.pre_handler = fei_kprobe_handler;
68+
attr->kp.post_handler = fei_post_handler;
5969
attr->retval = adjust_error_retval(addr, 0);
6070
INIT_LIST_HEAD(&attr->list);
6171
}

0 commit comments

Comments
 (0)