From: Frederic Weisbecker <frederic@kernel.org>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Zheng Yejian <zhengyejian1@huawei.com>,
quic_neeraju@quicinc.com, josh@joshtriplett.org,
rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
jiangshanlai@gmail.com, joel@joelfernandes.org,
rcu@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rcu: Fix kernel stack overflow caused by kprobe on rcu_irq_enter_check_tick()
Date: Mon, 5 Dec 2022 14:23:53 +0100 [thread overview]
Message-ID: <20221205132353.GB1796992@lothringen> (raw)
In-Reply-To: <20221121195703.GO4001@paulmck-ThinkPad-P17-Gen-1>
On Mon, Nov 21, 2022 at 11:57:03AM -0800, Paul E. McKenney wrote:
> On Sat, Nov 19, 2022 at 12:00:49PM +0800, Zheng Yejian wrote:
> > Register kprobe on __rcu_irq_enter_check_tick() can cause kernel stack
> > overflow [1]. This issue is first found in v5.10 and can be reproduced
> > by enabling CONFIG_NO_HZ_FULL and doing like:
> > # cd /sys/kernel/debug/tracing/
> > # echo 'p:mp1 __rcu_irq_enter_check_tick' >> kprobe_events
> > # echo 1 > events/kprobes/enable
> >
> > So __rcu_irq_enter_check_tick() should not be kprobed, mark it as noinstr.
>
> Good catch!
>
> I am inclined to queue this, but noticed that one of its callers need
> it to be noinstr but that the others do not.
>
> Need noinstr:
>
> o enter_from_kernel_mode() -> __enter_from_kernel_mode() ->
> rcu_irq_enter_check_tick() -> __rcu_irq_enter_check_tick()
>
> Doesn't need noinstr:
>
> o ct_nmi_enter() -> rcu_irq_enter_check_tick() ->
> __rcu_irq_enter_check_tick(), courtesy of the call to
> instrumentation_begin() in ct_nmi_enter() that precedes the call
> to rcu_irq_enter_check_tick().
>
> o irqentry_enter() -> rcu_irq_enter_check_tick() ->
> __rcu_irq_enter_check_tick(), courtesy of the call to
> instrumentation_begin() in irqentry_enter() that precedes the
> call to rcu_irq_enter_check_tick().
>
> Is tagging __rcu_irq_enter_check_tick() with noinstr as
> proposed in this patch the right thing to do, or should there
> be calls to instrumentation_begin() and instrumentation_end() in
> enter_from_kernel_mode()? Or something else entirely?
Tagging as noinstr doesn't look right as there are functions in
__rcu_irq_enter_check_tick() that can be traced anyway. Also that
function has the constraint that it can't be called while RCU is idle
so it's up to the caller to call instrumentation_begin()/end().
Thanks.
next prev parent reply other threads:[~2022-12-05 13:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-19 4:00 [PATCH] rcu: Fix kernel stack overflow caused by kprobe on rcu_irq_enter_check_tick() Zheng Yejian
2022-11-21 19:57 ` Paul E. McKenney
2022-12-02 9:54 ` Zheng Yejian
2022-12-02 19:24 ` Paul E. McKenney
2022-12-05 15:35 ` Frederic Weisbecker
2022-12-05 13:23 ` Frederic Weisbecker [this message]
2022-12-29 12:27 ` Zheng Yejian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221205132353.GB1796992@lothringen \
--to=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=joel@joelfernandes.org \
--cc=josh@joshtriplett.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=quic_neeraju@quicinc.com \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=zhengyejian1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox