Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0d07c0e

Browse files
mhiramatsuryasaimadhu
authored andcommitted
x86/kprobes: Fix optprobe to detect INT3 padding correctly
Commit7705dc8 ("x86/vmlinux: Use INT3 instead of NOP for linker fill bytes")changed the padding bytes between functions from NOP to INT3. However,when optprobe decodes a target function it finds INT3 and gives up thejump optimization.Instead of giving up any INT3 detection, check whether the rest of thebytes to the end of the function are INT3. If all of them are INT3,those come from the linker. In that case, continue the optprobe jumpoptimization. [ bp: Massage commit message. ]Fixes:7705dc8 ("x86/vmlinux: Use INT3 instead of NOP for linker fill bytes")Reported-by: Adam Zabrocki <pi3@pi3.com.pl>Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>Signed-off-by: Borislav Petkov <bp@suse.de>Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>Reviewed-by: Kees Cook <keescook@chromium.org>Cc: stable@vger.kernel.orgLink:https://lkml.kernel.org/r/160767025681.3880685.16021570341428835411.stgit@devnote2
1 parent190113b commit0d07c0e

File tree

1 file changed

+20
-2
lines changed
  • arch/x86/kernel/kprobes

1 file changed

+20
-2
lines changed

‎arch/x86/kernel/kprobes/opt.c‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,19 @@ static int insn_is_indirect_jump(struct insn *insn)
272272
returnret;
273273
}
274274

275+
staticboolis_padding_int3(unsigned longaddr,unsigned longeaddr)
276+
{
277+
unsignedcharops;
278+
279+
for (;addr<eaddr;addr++) {
280+
if (get_kernel_nofault(ops, (void*)addr)<0||
281+
ops!=INT3_INSN_OPCODE)
282+
return false;
283+
}
284+
285+
return true;
286+
}
287+
275288
/* Decode whole function to ensure any instructions don't jump into target */
276289
staticintcan_optimize(unsigned longpaddr)
277290
{
@@ -310,9 +323,14 @@ static int can_optimize(unsigned long paddr)
310323
return0;
311324
kernel_insn_init(&insn, (void*)recovered_insn,MAX_INSN_SIZE);
312325
insn_get_length(&insn);
313-
/* Another subsystem puts a breakpoint */
326+
/*
327+
* In the case of detecting unknown breakpoint, this could be
328+
* a padding INT3 between functions. Let's check that all the
329+
* rest of the bytes are also INT3.
330+
*/
314331
if (insn.opcode.bytes[0]==INT3_INSN_OPCODE)
315-
return0;
332+
returnis_padding_int3(addr,paddr-offset+size) ?1 :0;
333+
316334
/* Recover address */
317335
insn.kaddr= (void*)addr;
318336
insn.next_byte= (void*)(addr+insn.length);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp