Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp102143imj; Wed, 13 Feb 2019 05:26:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ4gNZzeI+HMiNn0aF9NDwFBLejvbtvTt4sc8ia95BstWm9o4QBXUwoxgMEDk32Wvc1w0wp X-Received: by 2002:a63:5518:: with SMTP id j24mr491427pgb.208.1550064385807; Wed, 13 Feb 2019 05:26:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550064385; cv=none; d=google.com; s=arc-20160816; b=PvTOlXipYlZUtg6j8aGSdUXvOCfV7UxMtO00pjokvdgAbH2MFFRXX+t4Esx2PeSDnw IUvugquq5i/72xOPMQzpoL046UqtBwavx9prPrQKbw1QnFh9ibP9GrAljqHJcudT493W AFPy0KS/R0Uq76ZFjixf+bZjbaIQWqPEJDcw7osYcgORl3nmO+wpMupSjbZsBoIoULZd UNGLsaPTik/mqIYsSMYJVFiDO6+F7P0tt0rokw7oLbGfBTfTcOKknkhTGsWzw2h+ADDK MmyZSVb51Is89dkC25ZjsYUimA4m6uEnU+nS2QsvPkeELzMgWRib5lUkDlmkkBeAHP57 I3jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=JIVYhaB/l6X6xt3OxXrT7i6npGIPgDlvRUzw3iSnzVg=; b=o0eSZMnkbU+mm9Nju5SweVtxdSAIDCreY4J3nxL3OAWJ3aQK2u+wCMEyFyQxqPwFSr 6Jm9sT7dmmVc3w6y5GqN3BtLJc9oRDeNaRWYOvjt/fjMFOkIC/TEnQt0RJwiPW4TeNLk V6MrWaiXlFXyw68CmWEqxD0f55dYG+G7Ggd+PrOIWUEUwjszs9tiMJN+QhEa2SwvJj07 TbLTE00MOTWonVKg0PaMXdt8XezE/AA0IzInUmiAo3/uAM71MnsyExiZwMGbtF5C8g0B Dz6NHcAXKzOHfpwO0FpRe/EqtLqYFsGbVkS8bC8xzaeZ6xG2OyjbQc2MxfBG1o7lMkTh XKIg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i19si450334pgb.263.2019.02.13.05.26.10; Wed, 13 Feb 2019 05:26:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389816AbfBMJBF (ORCPT + 99 others); Wed, 13 Feb 2019 04:01:05 -0500 Received: from terminus.zytor.com ([198.137.202.136]:36519 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727206AbfBMJBE (ORCPT ); Wed, 13 Feb 2019 04:01:04 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x1D909gu196018 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 13 Feb 2019 01:00:09 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x1D909sE196015; Wed, 13 Feb 2019 01:00:09 -0800 Date: Wed, 13 Feb 2019 01:00:09 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Masami Hiramatsu Message-ID: Cc: mathieu.desnoyers@efficios.com, mingo@kernel.org, hpa@zytor.com, mhiramat@kernel.org, acme@redhat.com, torvalds@linux-foundation.org, rostedt@goodmis.org, jolsa@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, alexander.shishkin@linux.intel.com, righi.andrea@gmail.com, tglx@linutronix.de Reply-To: acme@redhat.com, mathieu.desnoyers@efficios.com, mingo@kernel.org, jolsa@redhat.com, peterz@infradead.org, mhiramat@kernel.org, hpa@zytor.com, righi.andrea@gmail.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, rostedt@goodmis.org, torvalds@linux-foundation.org, alexander.shishkin@linux.intel.com In-Reply-To: <154998793571.31052.11301258949601150994.stgit@devbox> References: <154998793571.31052.11301258949601150994.stgit@devbox> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() Git-Commit-ID: c13324a505c7790fe91a9df35be2e0462abccdb0 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,BAYES_00, FREEMAIL_FORGED_REPLYTO,T_DATE_IN_FUTURE_96_Q autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c13324a505c7790fe91a9df35be2e0462abccdb0 Gitweb: https://git.kernel.org/tip/c13324a505c7790fe91a9df35be2e0462abccdb0 Author: Masami Hiramatsu AuthorDate: Wed, 13 Feb 2019 01:12:15 +0900 Committer: Ingo Molnar CommitDate: Wed, 13 Feb 2019 08:16:39 +0100 x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() 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 Cc: Alexander Shishkin Cc: Andrea Righi Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Mathieu Desnoyers Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/154998793571.31052.11301258949601150994.stgit@devbox Signed-off-by: Ingo Molnar --- 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 ebeac487a20c..e8b628b1b279 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 9b7c4ca8f0a7..e289ce1332ab 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