Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp794510ybv; Wed, 19 Feb 2020 09:20:23 -0800 (PST) X-Google-Smtp-Source: APXvYqyvNSkiniixH+DFUoNpiBybwSkFabNXeLPtjp/WGoTX53bQyHwBY03MZRc/IMjd/6lzc7PG X-Received: by 2002:a9d:7f81:: with SMTP id t1mr18947616otp.95.1582132823167; Wed, 19 Feb 2020 09:20:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582132823; cv=none; d=google.com; s=arc-20160816; b=yVTUTkjK+B9jex2B1kqhBV2GR9lcLPXBX95dZuwPdOzAsDhcTnTPBas0OedITysDn5 UN5A5cV8d5q9MfYiNhkrImNVHUrskb3kdmmsuK9tZV/kI9XhZvLRfcwwhDXzDWJNNdWc Khi+Q5K8yAAWqNE8ByrjFPSMFbvgvS+ghJK9UQFcRiVAWiv55hXpvIj31TW7M+3/rs2+ lLGWYvF8ujS11FfnnRS5PfyRDknai4qdgn2zqWiqkrF1BSXy1cRDsQfDELSP7z0F0tOg YSGNuJ09sFnO+G8jt8nKFN6tL3JlzVJMhp/OsjeqK3Br0s+ECxLifqRS3dsVuod5DnDM pkVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=eFFLbtKV1wHoHpSbO1vGKr55xKiOdJlHlqvO+VL5miQ=; b=kNu7Tb+0GLXFnPzmcCHv2WUtt8JOhOnL8nroH4i0GALd1ZZDlZgoO5HhgbYBf6GYT9 LMkcIUc8iXay8dvxROQnCsNtV7gHpdWI+mj+qzCP9KP9uBnst+NoYMDRtjD0/O1C/+8P nTzLPzgh8ONWaySPed/DMaMix4h4rxu28Jy2EGjJkswg9cbq+N2wO9sXS5/7Li2rEd8U S6XDHcbB89KtlHCBIgsgN4dsv4YpwG0zeE0rxKpU5dz1+D3a8V+eMGsJOvyjS2sACwYO 3ColW8vv2juOSSqTzN61KPpGNqI5O11uJbdV+RIrdrbhJlGs7E1GVrv8FPWdVGXwIuxk 934Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b="MabFU/LN"; 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 e126si10058646oib.21.2020.02.19.09.20.11; Wed, 19 Feb 2020 09:20:23 -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="MabFU/LN"; 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 S1726667AbgBSRTA (ORCPT + 99 others); Wed, 19 Feb 2020 12:19:00 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:33495 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbgBSRTA (ORCPT ); Wed, 19 Feb 2020 12:19:00 -0500 Received: by mail-io1-f66.google.com with SMTP id z8so1437419ioh.0 for ; Wed, 19 Feb 2020 09:18:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eFFLbtKV1wHoHpSbO1vGKr55xKiOdJlHlqvO+VL5miQ=; b=MabFU/LNJ6iK5i7PFe+0avSvRodkDyxJVTzJwbnwlmFp8ec7HckrwZ5WxlPngA3Lbu m0uacrHQ6Ij6wWXzRbWXh9cb9byO2GB+jpP06/CxTTIdI31eSIVpKXB5U9enJNcfLFxw Dq67E9Hxga7B00YTYr/Eq/p6Cz8AihY8xCBwk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eFFLbtKV1wHoHpSbO1vGKr55xKiOdJlHlqvO+VL5miQ=; b=tng1EtcxiV/x8thSRA+bJBwbuevfDxcWdB7VFPBKUIwTrcCuDyll5LfuArhbQJOokT m0s6hvFEI3fZDY294Lr1TF/wL/vJjqQAqgrE0/42rGCgKm/sjapAjn/xB76gZeX4YXKA 71m3Iu/ab5jELKFDC6VQs+5zP++lv9cUVa5D7CpIQaKI2IkFZNulxNI2B7DnZ+vQck2e WtedjctLFQ6tgcmbxk8z5aFo7fkFMDKDcLx3TA5Xzf/4GHADd2xVK3YCY+yJJp0H5KF5 Jk4nY7VTsV5+SWI0gw7RX2kCfCGukvasjfNbdnogK1tYcfLGaDqw3BcZdwHHAQzOVFJI mUmQ== X-Gm-Message-State: APjAAAUWNgNzcwmA8wrwyT0/psVcyiGPnGxH9BYCm57Wii83IY90ARsL FgdBjzvqkjojALR1qvD3MOJMCzoyr9wakNzgqGXJ9Q== X-Received: by 2002:a6b:db0d:: with SMTP id t13mr20864493ioc.171.1582132739221; Wed, 19 Feb 2020 09:18:59 -0800 (PST) MIME-Version: 1.0 References: <20200219144724.800607165@infradead.org> <20200219150744.661923520@infradead.org> <20200219163156.GY2935@paulmck-ThinkPad-P72> <20200219121609.45548925@gandalf.local.home> In-Reply-To: <20200219121609.45548925@gandalf.local.home> From: Joel Fernandes Date: Wed, 19 Feb 2020 12:18:48 -0500 Message-ID: Subject: Re: [PATCH] rcu/kprobes: Comment why rcu_nmi_enter() is marked NOKPROBE To: Steven Rostedt Cc: "Paul E. McKenney" , Peter Zijlstra , LKML , linux-arch@vger.kernel.org, Ingo Molnar , Greg Kroah-Hartman , "Gustavo A. R. Silva" , Thomas Glexiner , Josh Triplett , Mathieu Desnoyers , Lai Jiangshan , Andy Lutomirski , Tony Luck , Frederic Weisbecker , Dan Carpenter , Masami Hiramatsu Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 19, 2020 at 12:16 PM Steven Rostedt wrote: > > From: Steven Rostedt (VMware) > > It's confusing that rcu_nmi_enter() is marked NOKPROBE and > rcu_nmi_exit() is not. One may think that the exit needs to be marked > for the same reason the enter is, as rcu_nmi_exit() reverts the RCU > state back to what it was before rcu_nmi_enter(). But the reason has > nothing to do with the state of RCU. > > The breakpoint handler (int3 on x86) must not have any kprobe on it > until the kprobe handler is called. Otherwise, it can cause an infinite > recursion and crash the machine. It just so happens that > rcu_nmi_enter() is called by the int3 handler before the kprobe handler > can run, and therefore needs to be marked as NOKPROBE. > > Comment this to remove the confusion to why rcu_nmi_enter() is marked > NOKPROBE but rcu_nmi_exit() is not. > > Link: https://lore.kernel.org/r/20200213163800.5c51a5f1@gandalf.local.home > Signed-off-by: Steven Rostedt (VMware) Reported-by: Joel Fernandes (Google) Acked-by: Joel Fernandes (Google) thanks, - Joel > --- > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 1694a6b57ad8..ada7b2b638fb 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -846,6 +846,14 @@ void rcu_nmi_enter(void) > { > rcu_nmi_enter_common(false); > } > +/* > + * All functions called in the breakpoint trap handler (e.g. do_int3() > + * on x86), must not allow kprobes until the kprobe breakpoint handler > + * is called, otherwise it can cause an infinite recursion. > + * On some archs, rcu_nmi_enter() is called in the breakpoint handler > + * before the kprobe breakpoint handler is called, thus it must be > + * marked as NOKPROBE. > + */ > NOKPROBE_SYMBOL(rcu_nmi_enter); > > /**