[PATCH] x86/kprobes: Fix boundary check in insn_jump_into_range()
From: Jinke Han
Date: Tue Nov 17 2026 - 07:26:09 EST
The range checked by insn_jump_into_range() is half-open:
[start, start + len). However, the current check treats the upper
bound as inclusive, so a jump target at `probe address +
JMP32_INSN_SIZE` is incorrectly considered to jump into the
optimized region.
A valid jump target must be an instruction boundary. A target at
`probe address + JMP32_INSN_SIZE` lies just outside the overwritten
region, so allow the jmp optimization in this case.
Fixes: c0f7ac3a9edde ("kprobes/x86: Support kprobes jump optimization on x86")
Signed-off-by: Jinke Han <jinkehan@xxxxxxxxxxxxxx>
---
arch/x86/kernel/kprobes/opt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index 3f8fea52619f..a920ecb99381 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -252,7 +252,7 @@ static int insn_jump_into_range(struct insn *insn, unsigned long start, int len)
}
target = (unsigned long)insn->next_byte + insn->immediate.value;
- return (start <= target && target <= start + len);
+ return (start <= target && target < start + len);
}
/* Decode whole function to ensure any instructions don't jump into target */
--
2.34.1