Skip to contentSkip to conversation

x86/kprobe: Fix crash when probe cs call

PATCH Jinke Han 1 participant 1 message Sep 8

lore
Share & tools
lore

Jinke Han

author
#0 lore raw
Quoted 20 lines

Thanks for fixing! I have just one comment here;

[...]

Review int3_exception_notify(struct notifier_block *self, unsigned long val, void *data · line 2188

Quoted 11 lines
(quoted diff) +5 -2
@@ -2180,8 +2181,14 @@ int3_exception_notify(struct notifier_block *self, unsigned long val, void *data
 
 	if (regs->ip - INT3_INSN_SIZE != selftest)
 		return NOTIFY_DONE;
-
-	int3_emulate_call(regs, (unsigned long)&int3_selftest_callee);
+	/*
+	 * As seen in int3_selftest_asm, the effective return address
+	 * should be placed immediately after the instruction sequence
+	 * [int3; nop; nop; nop; nop.]. Therefore, CALL_INSN_SIZE works
+	 * perfectly well here.

Nit: This explanation is somewhat wrong. alternatives only support 5-byte call. The TEXT_POKE_MAX_OPCODE_SIZE is 5. When len == 6, alternative.c explicitly reserves this only for 0x0f prefixed Jcc.d32

Quoted 8 lines

See alternative.c

Review int3_exception_notify(struct notifier_block *self, unsigned long val, void *data · line 2191

Quoted 3 lines
(quoted diff) +0 -0
 /*
 * NOTE: crazy scheme to allow patching Jcc.d32 but not increase the size of
 * this thing. When len == 6 everything is prefixed with 0x0f and we map

* opcode to Jcc.d8, using len to distinguish.

Quoted 1 line

*/

So we don't need to take care of 6 bytes call here.

Thanks for the correction! I'll fix it in v3 soon. --
Jinke Han

Quoted 10 lines

Others looks good to me.

BTW, can this be picked via tip tree ? or I can pick it.

Thank you,

Signature · 1 line
Masami Hiramatsu (Google) <[email protected]>