mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/kprobes: Fix boundary check in insn_jump_into_range()
@ 2026-11-17 12:25 Jinke Han
  2026-11-19 19:41 ` Dave Hansen
  0 siblings, 1 reply; 2+ messages in thread
From: Jinke Han @ 2026-11-17 12:25 UTC (permalink / raw)
  To: linux-kernel, tglx, mingo, bp, dave.hansen, x86, hpa,
	nik.borisov, rppt, peterz, mhiramat, jinkehan

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@didiglobal.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/kprobes: Fix boundary check in insn_jump_into_range()
  2026-11-17 12:25 [PATCH] x86/kprobes: Fix boundary check in insn_jump_into_range() Jinke Han
@ 2026-11-19 19:41 ` Dave Hansen
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Hansen @ 2026-11-19 19:41 UTC (permalink / raw)
  To: linux-kernel, tglx, mingo, bp, dave.hansen, x86, hpa,
	nik.borisov, rppt, peterz, mhiramat

On 11/17/26 04:25, Jinke Han wrote:
> 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.

What is the end user visible effect of this issue, and of fixing it?

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-19 19:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-17 12:25 [PATCH] x86/kprobes: Fix boundary check in insn_jump_into_range() Jinke Han
2026-11-19 19:41 ` Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®