From: Jinke Han <jinkehan@didiglobal.com>
To: <linux-kernel@vger.kernel.org>, <tglx@kernel.org>,
<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
<x86@kernel.org>, <hpa@zytor.com>, <nik.borisov@suse.com>,
<rppt@kernel.org>, <peterz@infradead.org>, <mhiramat@redhat.com>,
<jinkehan@didiglobal.com>
Subject: [PATCH] x86/kprobes: Fix boundary check in insn_jump_into_range()
Date: Tue, 17 Nov 2026 20:25:21 +0800 [thread overview]
Message-ID: <20261117122521.GA17792@didi-ThinkCentre-M920t-N000> (raw)
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
next reply other threads:[~2026-11-17 12:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 12:25 Jinke Han [this message]
2026-11-19 19:41 ` Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261117122521.GA17792@didi-ThinkCentre-M920t-N000 \
--to=jinkehan@didiglobal.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@redhat.com \
--cc=mingo@redhat.com \
--cc=nik.borisov@suse.com \
--cc=peterz@infradead.org \
--cc=rppt@kernel.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®