From: Elliot Berman <elliot.berman@oss.qualcomm.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
Daniel Gomez <da.gomez@samsung.com>,
Luis Chamberlain <mcgrof@kernel.org>,
"Paul E . McKenney" <paulmck@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Sami Tolvanen <samitolvanen@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Elliot Berman <quic_eberman@quicinc.com>,
Kees Cook <kees@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
llvm@lists.linux.dev
Subject: Re: [PATCH v2 28/28] cfi: Use RCU while invoking __module_address().
Date: Mon, 30 Dec 2024 19:33:45 -0800 [thread overview]
Message-ID: <20241230185812429-0800.eberman@hu-eberman-lv.qualcomm.com> (raw)
In-Reply-To: <20241220174731.514432-29-bigeasy@linutronix.de>
On Fri, Dec 20, 2024 at 06:41:42PM +0100, Sebastian Andrzej Siewior wrote:
> __module_address() can be invoked within a RCU section, there is no
> requirement to have preemption disabled.
>
> I'm not sure if using rcu_read_lock() will introduce the regression that
> has been fixed in commit 14c4c8e41511a ("cfi: Use
> rcu_read_{un}lock_sched_notrace").
>
You can replace the rcu_read_lock_sched_notrace() with guard(rcu)().
Regular rcu lock doesn't generate function traces, so the recursive loop
isn't possible.
I've tested:
- the current kernel (no recursive loop)
- Revert back to rcu_read_lock_sched() (fails)
- Your series as-is (no recurisve loop)
- Replace with guard(rcu)() (no recursive loop)
Whether you'd like to stick with the current patch or replace with
guard(rcu)():
Tested-by: Elliot Berman <elliot.berman@oss.qualcomm.com> # sm8650-qrd
-
I don't know why I didn't mention steps to reproduce, even for my own
benefit. Lesson learned :)
Here are the steps to reproduce; you'll need a system with support for
CFI: qemu arm64 probably does the trick and you'll need clang>=16. I'm
happy to help test future revisions of this series since I have the
setup all done.
```
modprobe -a dummy_stm stm_ftrace stm_p_basic
mkdir -p /sys/kernel/config/stp-policy/dummy_stm.0.my-policy/default
echo function > /sys/kernel/tracing/current_tracer
echo 1 > /sys/kernel/tracing/tracing_on
echo dummy_stm.0 > /sys/class/stm_source/ftrace/stm_source_link
```
The trace buffer should not be full of stm calls due to the recursive
loop as mentioned in my original commit.
Regards,
Elliot Berman
> Cc: Elliot Berman <quic_eberman@quicinc.com>
> Cc: Kees Cook <kees@kernel.org>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Sami Tolvanen <samitolvanen@google.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: llvm@lists.linux.dev
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
> kernel/cfi.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/kernel/cfi.c b/kernel/cfi.c
> index 08caad7767176..c8f2b5a51b2e6 100644
> --- a/kernel/cfi.c
> +++ b/kernel/cfi.c
> @@ -71,6 +71,10 @@ static bool is_module_cfi_trap(unsigned long addr)
> struct module *mod;
> bool found = false;
>
> + /*
> + * XXX this could be RCU protected but would it introcude the regression
> + * fixed in 14c4c8e41511a ("cfi: Use rcu_read_{un}lock_sched_notrace")
> + */
> rcu_read_lock_sched_notrace();
>
> mod = __module_address(addr);
> --
> 2.45.2
>
next prev parent reply other threads:[~2024-12-31 3:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241220174731.514432-1-bigeasy@linutronix.de>
2024-12-20 17:41 ` [PATCH v2 28/28] cfi: Use RCU while invoking __module_address() Sebastian Andrzej Siewior
2024-12-30 21:13 ` Petr Pavlu
2025-01-02 23:59 ` Sami Tolvanen
2024-12-31 3:33 ` Elliot Berman [this message]
2025-01-03 0:24 ` Sami Tolvanen
2025-01-06 18:00 ` Elliot Berman
2025-01-06 21:24 ` Sami Tolvanen
2025-01-07 15:44 ` Sebastian Andrzej Siewior
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=20241230185812429-0800.eberman@hu-eberman-lv.qualcomm.com \
--to=elliot.berman@oss.qualcomm.com \
--cc=bigeasy@linutronix.de \
--cc=da.gomez@samsung.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mcgrof@kernel.org \
--cc=nathan@kernel.org \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=petr.pavlu@suse.com \
--cc=quic_eberman@quicinc.com \
--cc=rostedt@goodmis.org \
--cc=samitolvanen@google.com \
--cc=tglx@linutronix.de \
/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