Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4005422imj; Tue, 12 Feb 2019 08:14:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IZywgN7tS8eb99Rim/MNC1sJ6tHS7/49duPoPGxIH4Dfi8sZ94Z08y3O66eY8YpijDR3Mkb X-Received: by 2002:a17:902:4681:: with SMTP id p1mr4897904pld.184.1549988087630; Tue, 12 Feb 2019 08:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549988087; cv=none; d=google.com; s=arc-20160816; b=nvpK8+7h6/IirDSgmRXy+Y92ZVYHW66pkIDnCxt06NOkiyvJQGZZDs91AJsogXjjkD 596oAYawLB35ZT2XmmsGkB99UXynbiKvxIZPF7LmkfYzS8NzRW8vUL4paJlsEuarbQa/ Uo7BbLFLozIvwuXiu1IcIQzlQ5zfELO5+spe/+jhWTnpX/YexnszaA9FsywqHHIybrrf pJnETKg2Y/GLWXCqSVJSbyX+iDTKd16rLsjLMoURgyNYzEAO65aZ8FzENfnSXOHa/8Wo gSkb0Q2inZ3RX2HRWFTbylyfv9gOtEbXV2amKuyNPc26tGPbrz7IRh3FAW+qIF6Hk9rX VVGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tL68y1EirHIPM6HD7iLEejuvsxZc+Vl8CnQxCjKEubI=; b=U34rIs7dqagsrpXsEt6N1dd8zMBVsRc/jlmGWni32Qu8EdELoV663uPnnBFwK7aigV 5Q8Kf9jjtCBnlIsir6hx55My26xsFWyucSV0OquWh1CynEes4YX6wznwbi9+7K4ttDlP ZudgDR17pfsuDzLA83oFVsVk1k1zq0WdhjwH1hroxvNa9QZFMcQZGGQQXaJRy9gs8n1E KEUvsaaMxI1kK7yeyibVzIPGjzoaU6OBJ6nKTNg0v3c24Av0XYYMTYIXefjV+VrKICQD TQNLCRcoi2O5LdBrWLywPG9gvuN2HdCVge+qYcTyy7gAkczwUTYEWX6Fo3jh2DyLFpip fX7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pyYst/mp"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 9si8505129plc.40.2019.02.12.08.14.31; Tue, 12 Feb 2019 08:14:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pyYst/mp"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730940AbfBLQMk (ORCPT + 99 others); Tue, 12 Feb 2019 11:12:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:41516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728585AbfBLQMk (ORCPT ); Tue, 12 Feb 2019 11:12:40 -0500 Received: from localhost.localdomain (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A211E21773; Tue, 12 Feb 2019 16:12:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549987958; bh=eDQAQSChJXi5b7ULWr405cpMSDe2ysCPangIzwv5xzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pyYst/mpdN1eLcwG9kEiuM2SemxHORRF1iaaBtg6cdjR6BqSBZChKMdgfdQ/1x/EJ ooOVeOwkZsvha22rFKkTXYmuYJYNronMWUuKdlUgM6OOmXICPIYgx53sPi2AfubxS1 yjHO6GafzyPlDtUqYqoH3HqmBH/FowycNaai7MgM= From: Masami Hiramatsu To: Ingo Molnar Cc: Masami Hiramatsu , peterz@infradead.org, Mathieu Desnoyers , linux-kernel , Andrea Righi , Steven Rostedt Subject: [PATCH -tip v3 03/10] x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() Date: Wed, 13 Feb 2019 01:12:15 +0900 Message-Id: <154998793571.31052.11301258949601150994.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <154998785011.31052.1475728497912659748.stgit@devbox> References: <154998785011.31052.1475728497912659748.stgit@devbox> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prohibit probing on the functions called before kprobe_int3_handler() in do_int3(). More specifically, ftrace_int3_handler(), poke_int3_handler(), and ist_enter(). And since rcu_nmi_enter() is called by ist_enter(), it also should be marked as NOKPROBE_SYMBOL. Since those are handled before kprobe_int3_handler(), probing those functions can cause a breakpoint recursion and crash the kernel. Signed-off-by: Masami Hiramatsu --- arch/x86/kernel/alternative.c | 3 ++- arch/x86/kernel/ftrace.c | 3 ++- arch/x86/kernel/traps.c | 1 + kernel/rcu/tree.c | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index d458c7973c56..9a79c7808f9c 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -764,8 +765,8 @@ int poke_int3_handler(struct pt_regs *regs) regs->ip = (unsigned long) bp_int3_handler; return 1; - } +NOKPROBE_SYMBOL(poke_int3_handler); /** * text_poke_bp() -- update instructions on live kernel on SMP diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 8257a59704ae..3e3789c8f8e1 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -269,7 +269,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func) return ret; } -static int is_ftrace_caller(unsigned long ip) +static nokprobe_inline int is_ftrace_caller(unsigned long ip) { if (ip == ftrace_update_func) return 1; @@ -299,6 +299,7 @@ int ftrace_int3_handler(struct pt_regs *regs) return 1; } +NOKPROBE_SYMBOL(ftrace_int3_handler); static int ftrace_write(unsigned long ip, const char *val, int size) { diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 2684a9d11e66..d26f9e9c3d83 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -111,6 +111,7 @@ void ist_enter(struct pt_regs *regs) /* This code is a bit fragile. Test it. */ RCU_LOCKDEP_WARN(!rcu_is_watching(), "ist_enter didn't work"); } +NOKPROBE_SYMBOL(ist_enter); void ist_exit(struct pt_regs *regs) { diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 9180158756d2..74db52a0a466 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -62,6 +62,7 @@ #include #include #include +#include #include "tree.h" #include "rcu.h" @@ -872,6 +873,7 @@ void rcu_nmi_enter(void) { rcu_nmi_enter_common(false); } +NOKPROBE_SYMBOL(rcu_nmi_enter); /** * rcu_irq_enter - inform RCU that current CPU is entering irq away from idle