x86: Unify kpropes MAX_INSN_SIZE definition
PATCH 1/1 x86: Unify kpropes MAX_INSN_SIZE definition
Signed-off-by Harvey Harrison <[email protected]>
--- arch/x86/kernel/kprobes_32.c | 8 ++++---- include/asm-x86/kprobes.h | 5 +---- 2 files changed, 5 insertions(+), 8 deletions(-)
arch/x86/kernel/kprobes_32.c +4 -4
@@ -101,13 +101,13 @@ static __always_inline int can_boost(kprobe_opcode_t *opcodes)kprobe_opcode_t opcode;kprobe_opcode_t *orig_opcodes = opcodes; retry: -if (opcodes - orig_opcodes >MAX_INSN_SIZE -1 ) +if (opcodes - orig_opcodes >MAX_INSN_SIZE )return 0 ; opcode = *(opcodes++);/* 2nd-byte opcode */ if (opcode ==0x0f ) { -if (opcodes - orig_opcodes >MAX_INSN_SIZE -1 ) +if (opcodes - orig_opcodes >MAX_INSN_SIZE )return 0 ;return test_bit (*opcodes, twobyte_is_boostable); }
@@ -164,7 +164,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)if (!p->ainsn.insn)return -ENOMEM ; -memcpy (p->ainsn.insn, p->addr,MAX_INSN_SIZE *sizeof (kprobe_opcode_t)); +memcpy (p->ainsn.insn, p->addr, (MAX_INSN_SIZE +1 ) *sizeof (kprobe_opcode_t)); p->opcode = *p->addr;if (can_boost (p->addr)) { p->ainsn.boostable =0 ;
@@ -539,7 +539,7 @@ static void __kprobes resume_execution(struct kprobe *p,if (p->ainsn.boostable ==0 ) {if ((regs->ip > copy_eip) && - (regs->ip - copy_eip) +5 <MAX_INSN_SIZE ) { + (regs->ip - copy_eip) +5 < (MAX_INSN_SIZE +1 )) {/* * These instructions can be executed directly if it * jumps back to correct address.
include/asm-x86/kprobes.h +1 -4
@@ -35,12 +35,9 @@ struct kprobe;struct pt_regs ;typedef u8 kprobe_opcode_t ; -#ifdef CONFIG_X86_32 +# define RELATIVEJUMP_INSTRUCTION 0xe9 -# define MAX_INSN_SIZE 16 -#else # define MAX_INSN_SIZE 15 -#endif #define BREAKPOINT_INSTRUCTION 0xcc#define MAX_STACK_SIZE 64
Signature · 1 line
1.5.4.rc0.1083.gf568