Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932136AbbFAVvp (ORCPT ); Mon, 1 Jun 2015 17:51:45 -0400 Received: from mail7.hitachi.co.jp ([133.145.228.42]:55601 "EHLO mail7.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751889AbbFAVvi (ORCPT ); Mon, 1 Jun 2015 17:51:38 -0400 Message-ID: <556CD3E3.1080605@hitachi.com> Date: Tue, 02 Jun 2015 06:51:31 +0900 From: Masami Hiramatsu Organization: Hitachi, Ltd., Japan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Eugene Shatokhin , Ingo Molnar CC: Andy Lutomirski , Ingo Molnar , LKML Subject: Re: [PATCH 1/2] kprobes/x86: boost: Fix checking if there is enough room for a jump References: <1433176331-479-1-git-send-email-eugene.shatokhin@rosalab.ru> <1433176331-479-2-git-send-email-eugene.shatokhin@rosalab.ru> In-Reply-To: <1433176331-479-2-git-send-email-eugene.shatokhin@rosalab.ru> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2050 Lines: 54 On 2015/06/02 1:32, Eugene Shatokhin wrote: > Kprobes' "boost" feature allows to avoid single-stepping in some cases, > along with its overhead. It needs a relative jump placed in the insn > slot right after the instruction. So the length of the instruction plus > 5 (the length of the near relative unconditional jump) must not exceed > the length of the slot. > > However, the code currently checks if that sum is strictly less than > the length of the slot. So "boost" cannot be used for the instructions > of 10 bytes in size (with MAX_INSN_SIZE == 15), like > "movabs $0x45525f4b434f4c43,%rax" (48 b8 43 4c 4f 43 4b 5f 52 45), > "movl $0x1,0xf8dd(%rip)" (c7 05 dd f8 00 00 01 00 00 00), etc. > > This patch fixes that conditional. Looks good to me, Acked-by: Masami Hiramatsu Thanks! > > Signed-off-by: Eugene Shatokhin > --- > arch/x86/kernel/kprobes/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c > index 1deffe6..0a42b76 100644 > --- a/arch/x86/kernel/kprobes/core.c > +++ b/arch/x86/kernel/kprobes/core.c > @@ -881,7 +881,7 @@ static void resume_execution(struct kprobe *p, struct pt_regs *regs, > > if (p->ainsn.boostable == 0) { > if ((regs->ip > copy_ip) && > - (regs->ip - copy_ip) + 5 < MAX_INSN_SIZE) { > + (regs->ip - copy_ip) + 5 <= MAX_INSN_SIZE) { > /* > * These instructions can be executed directly if it > * jumps back to correct address. > -- Masami HIRAMATSU Linux Technology Research Center, System Productivity Research Dept. Center for Technology Innovation - Systems Engineering Hitachi, Ltd., Research & Development Group E-mail: masami.hiramatsu.pt@hitachi.com -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/