Skip to content

Commit ae052e3

Browse files
anadavhansendc
authored andcommitted
x86/kprobes: Fix 1 byte conditional jump target
Commit 3bc753c ("kbuild: treat char as always unsigned") broke kprobes. Setting a probe-point on 1 byte conditional jump can cause the kernel to crash when the (signed) relative jump offset gets treated as unsigned. Fix by replacing the unsigned 'immediate.bytes' (plus a cast) with the signed 'immediate.value' when assigning to the relative jump offset. [ dhansen: clarified changelog ] Fixes: 3bc753c ("kbuild: treat char as always unsigned") Suggested-by: Masami Hiramatsu (Google) <[email protected]> Suggested-by: Dave Hansen <[email protected]> Signed-off-by: Nadav Amit <[email protected]> Signed-off-by: Dave Hansen <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/all/20230208071708.4048-1-namit%40vmware.com
1 parent 9d2c720 commit ae052e3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/kprobes/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int prepare_emulation(struct kprobe *p, struct insn *insn)
625625
/* 1 byte conditional jump */
626626
p->ainsn.emulate_op = kprobe_emulate_jcc;
627627
p->ainsn.jcc.type = opcode & 0xf;
628-
p->ainsn.rel32 = *(char *)insn->immediate.bytes;
628+
p->ainsn.rel32 = insn->immediate.value;
629629
break;
630630
case 0x0f:
631631
opcode = insn->opcode.bytes[1];

0 commit comments

Comments
 (0)