Skip to content

Commit 4363264

Browse files
olsajiriAlexei Starovoitov
authored andcommitted
uprobe: Do not emulate/sstep original instruction when ip is changed
If uprobe handler changes instruction pointer we still execute single step) or emulate the original instruction and increment the (new) ip with its length. This makes the new instruction pointer bogus and application will likely crash on illegal instruction execution. If user decided to take execution elsewhere, it makes little sense to execute the original instruction, so let's skip it. Acked-by: Oleg Nesterov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 7384893 commit 4363264

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/events/uprobes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,6 +2741,13 @@ static void handle_swbp(struct pt_regs *regs)
27412741

27422742
handler_chain(uprobe, regs);
27432743

2744+
/*
2745+
* If user decided to take execution elsewhere, it makes little sense
2746+
* to execute the original instruction, so let's skip it.
2747+
*/
2748+
if (instruction_pointer(regs) != bp_vaddr)
2749+
goto out;
2750+
27442751
if (arch_uprobe_skip_sstep(&uprobe->arch, regs))
27452752
goto out;
27462753

0 commit comments

Comments
 (0)