Skip to content

Commit 7131c2e

Browse files
committed
Merge tag 'probes-fixes-v6.7-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull kprobes/x86 fix from Masami Hiramatsu: - Fix to emulate indirect call which size is not 5 byte. Current code expects the indirect call instructions are 5 bytes, but that is incorrect. Usually indirect call based on register is shorter than that, thus the emulation causes a kernel crash by accessing wrong instruction boundary. This uses the instruction size to calculate the return address correctly. * tag 'probes-fixes-v6.7-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: x86/kprobes: fix incorrect return address calculation in kprobe_emulate_call_indirect
2 parents 3eca894 + f5d03da commit 7131c2e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kernel/kprobes/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,8 @@ static void kprobe_emulate_call_indirect(struct kprobe *p, struct pt_regs *regs)
576576
{
577577
unsigned long offs = addrmode_regoffs[p->ainsn.indirect.reg];
578578

579-
int3_emulate_call(regs, regs_get_register(regs, offs));
579+
int3_emulate_push(regs, regs->ip - INT3_INSN_SIZE + p->ainsn.size);
580+
int3_emulate_jmp(regs, regs_get_register(regs, offs));
580581
}
581582
NOKPROBE_SYMBOL(kprobe_emulate_call_indirect);
582583

0 commit comments

Comments
 (0)