Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1242548imu; Fri, 11 Jan 2019 18:30:31 -0800 (PST) X-Google-Smtp-Source: ALg8bN68t2e7PQYCbTOyurYsaqjwmiu63tNGRd7D71fiWTQmyG8D1xBbousMk7JGy45WVgyVcpXx X-Received: by 2002:a17:902:6909:: with SMTP id j9mr16471216plk.196.1547260231721; Fri, 11 Jan 2019 18:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547260231; cv=none; d=google.com; s=arc-20160816; b=eWEmqRZ5FHd0b31fQD7lZem8bsIvOyclPuQd/owr67yBKwcvI7LeBgHl39XsyDyvYj 30qW99NxQlMUOwJig8UM89Ihar2aBK84dYUfCvYOznnzmr3KnUw7caHSs2anbSJZ1jaA nsQyfYTNnVyBwIxNv1QX5w0+z5k5OkqRinJBo8qcN4NWQ//dY7slRd77V4NCiQhKFpJ8 RwCkEZzuzR+jdlziEZR5SbtOvjMw4efcG8QmO4LEeBhX13E/uLqxWgvXT1GcUUhB6V3f UYpSQt4D0Kl1QFSOQNrGZT7KAlaPoBLUgsp9xkTgar8nKiGDZ5TWzRSMHurMuTrDSfJW l8Xw== 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=gGUFh77UK/nCLFgo0PyOoDYcukDewYh9gjHcvGEU7nI=; b=uRyLrcxkbck0GQifqG8L/XcUclRzzN4HJY6bsrj5qLI3cy/6m6bmR0eUmoaklg8XlU K9X4nqwWnUxWsHmdtiPwpVydxd0s74a9UnLjvxWba9rfzh241He+SeQqCiJ02phTVyEG xGITu8L/hR6uumVm4ib1koQOL7QZTWceFsFg9+sAP2bNedRcFBQIe5ezZ1RjXpWd8P/j GBJ/DPNYQN5bfzWBlHkHPF2Bd/fibblIqAKuaBuXSQ5ZQH2ApdbvF9X8rogPtcJ108B2 kGA65E1r+pPHYkBcPd5mv5tZT/y1VY5ilFu/Mb9V+7esuyNArvpOgwKaFpgy97ESqU53 Tz8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wrRxBf7Y; 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 s5si51277123pfi.134.2019.01.11.18.30.16; Fri, 11 Jan 2019 18:30:31 -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=wrRxBf7Y; 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 S1726570AbfALC1a (ORCPT + 99 others); Fri, 11 Jan 2019 21:27:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:48128 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbfALC13 (ORCPT ); Fri, 11 Jan 2019 21:27:29 -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 83DF020870; Sat, 12 Jan 2019 02:27:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547260048; bh=jCKgUH7uqc/x2GAyDS7k9iEgFpZYL45XwdcibUh1WEA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wrRxBf7YG18slercGlCEDxRFXhR9rBAYosxBmTG1wylis6+F/gcfCDic5zFjlJK3X wYaCjp9j91NE7FGjn11cO5eP5jBnIz3144O4o8mAn+tjgUYclWxElWa6qYbiOik82c DxuVlsWAIUkQw/H9Rc0UrPhLrnxjMkvzduiC3HUg= From: Masami Hiramatsu To: Ingo Molnar Cc: Masami Hiramatsu , peterz@infradead.org, Mathieu Desnoyers , linux-kernel , Andrea Righi , Steven Rostedt Subject: [PATCH v2 3/9] x86/kprobes: Prohibit probing on functions before kprobe_int3_handler() Date: Sat, 12 Jan 2019 11:27:05 +0900 Message-Id: <154726002552.18060.16235456056729209714.stgit@devbox> X-Mailer: git-send-email 2.13.6 In-Reply-To: <154725993986.18060.2759150647140353514.stgit@devbox> References: <154725993986.18060.2759150647140353514.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 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 7ee8067cbf45..22a548919228 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