From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbdGYNp5 (ORCPT ); Tue, 25 Jul 2017 09:45:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:46396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750839AbdGYNp4 (ORCPT ); Tue, 25 Jul 2017 09:45:56 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 946D422BC7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org Date: Tue, 25 Jul 2017 22:45:47 +0900 From: Masami Hiramatsu To: Ingo Molnar Cc: Francis Deslauriers , mathieu.desnoyers@efficios.com, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, Ananth N Mavinakayanahalli , Anil S Keshavamurthy , "David S . Miller" , linux-kernel@vger.kernel.org Subject: Re: [PATCH -tip V2] [BUGFIX] kprobes/x86: Do not jump-optimize kprobes on irq entry code Message-Id: <20170725224547.1a756a301c6c57738efe9d95@kernel.org> In-Reply-To: <20170725104005.ugwhr5wlbkfhdylq@gmail.com> References: <150095034226.4921.9289125363675682881.stgit@devbox> <20170725104005.ugwhr5wlbkfhdylq@gmail.com> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 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 On Tue, 25 Jul 2017 12:40:05 +0200 Ingo Molnar wrote: > > * Masami Hiramatsu wrote: > > > Since the kernel segment registers are not prepared at the > > entry of irq-entry code, if a kprobe on such code is > > jump-optimized, accessing per-cpu variables may cause > > kernel panic. > > However, if the kprobe is not optimized, it kicks int3 > > exception and set segment registers correctly. > > > > This checks probe-address and if it is in irq-entry code, > > it prohibits optimizing such kprobes. This means we can > > continuously probing such interrupt handlers by kprobes > > but it is not optimized anymore. > > > > Signed-off-by: Masami Hiramatsu > > Reported-by: Francis Deslauriers > > Tested-by: Francis Deslauriers > > --- > > Changes in V2: > > - Make changes in kprobe/opt.c local, not involving unwind, > > since it requires CONFIG_FRAME_POINTER=y (Thanks Mathieu!) > > This patch doesn't even build on x86-64 defconfig ... > > arch/x86/kernel/kprobes/opt.c: In function ‘can_optimize’: > arch/x86/kernel/kprobes/opt.c:259:32: error: ‘__irqentry_text_start’ undeclared > (first use in this function) > ((paddr >= (unsigned long)__irqentry_text_start) && > ^~~~~~~~~~~~~~~~~~~~~ Oops, yes, hmm, I missed below ifdef... #if defined(CONFIG_FUNCTION_GRAPH_TRACER) || defined(CONFIG_KASAN) Or, I think we can define those as NULL in interrupt.h. Thanks, > > Thanks, > > Ingo -- Masami Hiramatsu