Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp355745ybh; Fri, 6 Mar 2020 23:48:12 -0800 (PST) X-Google-Smtp-Source: ADFU+vsGTenPlH0PCi5cLmDCILkLIJLwDVpKDzFMultxCj2qZmQsoik5JOQESjQ3UVjt/SWIWb2t X-Received: by 2002:a05:6830:4c5:: with SMTP id s5mr5765586otd.327.1583567292432; Fri, 06 Mar 2020 23:48:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583567292; cv=none; d=google.com; s=arc-20160816; b=bDZ0AxHzVxa7q8p1DiO9/m7zVgo8NpEBMtpx0fi0ig+oLETfcDuQ4fLqgR2uOOWkmf hQ3DrPZqNpz0i9EoslpyQPui5kk9KQjla/tI4Lc6WnCzDxtGcyu3kDgvBuabyeoBPL+C n18f9s47aYU6UzYo2PRKTCuEoUjkQ5Z7cWOgm2+cxw6MeZwtWb7uGlyZI6GtiqKPTeFr BsG+f8kuaVo3JXKjGdPk6ZroaOVmW6x/fpkNjYxRdYpjvUYXYVgSco+ptFE7eiuwIQhd j+ABFCYkNDEosSqH3Q+skmZjFtAXTtFUVjfRw995yoH+oV6BKzxk/EXqH5n2clwuPGgw wJ8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=CJaGuE6xjlwUdKde+nh834lDDnUaVIY1l9gUCqflQZs=; b=A4pxBa6UrCpAXV2V78GDiZf1w5uWjcvROO0NPw1vEiMA7hN9hHXohwIjeMnZUc3SgA bYfTE516Hn5kQ6eE/5YL6SHG5x5Q3H2BR/C4u2cUUv/L3Zfu40q9PQdI9px8Tyf/beyI Jt0Ex+g8ZQM5OgICP6hW7Zozv97buBRBd8TXEvW/fXF6nGO0YtmpDlL+sUBRS1FGNHr7 ENayAHER7ESXBP/P5cfBq8tL6vYnYntmK8PItVnkt76To4MPjxv0DXTYkYQpjNKGyrd5 PTzkHIOvgexWIKz/O23xnEVOzsOhr0V/qCLw05/07dyeyV7TuFNspng1GglJ9wT+L34d 10KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=mrboOzb0; 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 t7si2499393otc.169.2020.03.06.23.47.58; Fri, 06 Mar 2020 23:48:12 -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=@joelfernandes.org header.s=google header.b=mrboOzb0; 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 S1726086AbgCGHrE (ORCPT + 99 others); Sat, 7 Mar 2020 02:47:04 -0500 Received: from mail-qt1-f195.google.com ([209.85.160.195]:32772 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbgCGHrE (ORCPT ); Sat, 7 Mar 2020 02:47:04 -0500 Received: by mail-qt1-f195.google.com with SMTP id d22so3549831qtn.0 for ; Fri, 06 Mar 2020 23:47:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CJaGuE6xjlwUdKde+nh834lDDnUaVIY1l9gUCqflQZs=; b=mrboOzb015mzZ3cdDvl8jKCqwe6B++cNC3lPjplgSU3Rn2LrOOqmFKlya7+9SnKiKE K9IGQleQRLSPUPNSg3t4FDzKjrls7eqdvZQjcrllrAbZl7OtPfK9NW8FB7y0xDgVZahC UYHbP/kZVR6JzdYRDnaOaRBj3k1aF+6UR14kw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CJaGuE6xjlwUdKde+nh834lDDnUaVIY1l9gUCqflQZs=; b=SruRzSxFr1VbLEcRR1tFpNqn2j1ptzQj1iBOch7f9OwS74d1W3DlkqPhaW2zPJKfTZ atAvb4xUlyGkDL22SQm2Imuy23s/f8yyxr/fs/DZ73ZkSLtI7nEPssBAe8pZ31ExYKBH UwWXGqReogPTy1S/IhqyZCBvsDDd2kSIMq6B4GfTXL956pk62InrOHlyGll6TDxC9Gqv oduJRvGIC8n33jtTQZSELd9emGx+Pr/bZn3H4So397nms2pmhG3yDE9iC9KTolaMcrz5 pJqzK4oiq+RwoeZLkYuymClWGBUWNkcggPtgLbMeRcrffvGmLw5VgdpVYIwOVmqYeAvp aBYQ== X-Gm-Message-State: ANhLgQ13REIjqFhk+b94Qu0RT3ixzRmPfwrYOj0+cpHg0j2o7QNst1cz 6KTofrh/0rrPjR2vzXJ1zagBIw== X-Received: by 2002:aed:38c8:: with SMTP id k66mr3241657qte.50.1583567223388; Fri, 06 Mar 2020 23:47:03 -0800 (PST) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id i132sm19278276qke.41.2020.03.06.23.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 23:47:02 -0800 (PST) Date: Sat, 7 Mar 2020 02:47:02 -0500 From: Joel Fernandes To: "Paul E. McKenney" Cc: Masami Hiramatsu , Ingo Molnar , Peter Zijlstra , Steven Rostedt , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, gregkh@linuxfoundation.org, gustavo@embeddedor.com, tglx@linutronix.de, josh@joshtriplett.org, mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com, stable@vger.kernel.org Subject: Re: [PATCH] x86/kprobes: Prohibit probing on rcu_nmi_exit() and ist_exit() Message-ID: <20200307074702.GA231616@google.com> References: <158355013189.14191.9105069890402942867.stgit@devnote2> <20200307032831.GL2935@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200307032831.GL2935@paulmck-ThinkPad-P72> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 06, 2020 at 07:28:31PM -0800, Paul E. McKenney wrote: > On Sat, Mar 07, 2020 at 12:02:12PM +0900, Masami Hiramatsu wrote: > > Prohibit probing on rcu_nmi_exit() and ist_exit() which > > are called from do_int3()'s kprobe path after kprobe_int3_handler(). > > > > The commit c13324a505c7 ("x86/kprobes: Prohibit probing on > > functions before kprobe_int3_handler()") tried to fix similar > > issue, but it only marks the functions before kprobe_int3_handler() > > in do_int3(). > > > > If we put a kprobe on rcu_nmi_exit() or ist_exit(), the kprobes > > will detect reentrance. However, it only skips the kprobe handler, > > exits from do_int3() and hits ist_exit() and rcu_nmi_exit() again. > > Thus, it causes another int3 exception and finally we will get > > the kernel panic with "Unrecoverable kprobe detected." error message. > > > > This is reproducible by the following commands. > > > > / # echo 0 > /proc/sys/debug/kprobes-optimization > > / # echo p vfs_read > /sys/kernel/debug/tracing/kprobe_events > > / # echo p rcu_nmi_exit >> /sys/kernel/debug/tracing/kprobe_events > > / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/enable > > > > Fixes: c13324a505c7 ("x86/kprobes: Prohibit probing on functions before kprobe_int3_handler()") > > Signed-off-by: Masami Hiramatsu > > Cc: stable@vger.kernel.org > > From an RCU perspective: > > Reviewed-by: Paul E. McKenney > Reviewed-by: Joel Fernandes (Google) thanks, - Joel > > --- > > arch/x86/kernel/traps.c | 1 + > > kernel/rcu/tree.c | 1 + > > 2 files changed, 2 insertions(+) > > > > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c > > index 6ef00eb6fbb9..c63fb7697794 100644 > > --- a/arch/x86/kernel/traps.c > > +++ b/arch/x86/kernel/traps.c > > @@ -115,6 +115,7 @@ void ist_exit(struct pt_regs *regs) > > if (!user_mode(regs)) > > rcu_nmi_exit(); > > } > > +NOKPROBE_SYMBOL(ist_exit); > > > > /** > > * ist_begin_non_atomic() - begin a non-atomic section in an IST exception > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index d91c9156fab2..c49ea0e919f9 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -670,6 +670,7 @@ void rcu_nmi_exit(void) > > { > > rcu_nmi_exit_common(false); > > } > > +NOKPROBE_SYMBOL(rcu_nmi_exit); > > > > /** > > * rcu_irq_exit - inform RCU that current CPU is exiting irq towards idle > >