Re: [PATCH v2 28/28] cfi: Use RCU while invoking __module_address().

From
Sami Tolvanen <samitolvanen@google.com>
Date
2025-01-06 21:25:06
Also in
lkml, llvm
Reply to
Elliot Berman, 2025-01-06
Hi,

On Mon, Jan 6, 2025 at 10:00 AM Elliot Berman
[off-list ref] wrote:
On Thu, Jan 02, 2025 at 04:24:22PM -0800, Sami Tolvanen wrote:
quoted
Hi Elliot,

On Mon, Dec 30, 2024 at 7:33 PM Elliot Berman
[off-list ref] wrote:
quoted
On Fri, Dec 20, 2024 at 06:41:42PM +0100, Sebastian Andrzej Siewior wrote:
quoted
__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)
Which kernel version did you test? I assume something pre-KCFI as
arm64 doesn't use this code since v6.1.
Ah, thanks for calling me out. I dug a bit more, I thought I was looking
at a recursive loop in the ftrace buffers, but was actually the expected
behavior. When I tested on the other configurations, the stm dummy
driver hadn't kicked in yet by the time I looked at the ftrace. Indeed,
this function code is not used on arm64.

I experimented with an x86 build as well and I was able to get the hang
I remember seeing after some tweaks to force a CFI failure. Still,
guard(rcu)() is okay by me :)
OK, great. That makes sense. Thanks for taking the time to test this!

Sami
Thread (43 messages) 43 messages, 9 authors, last reply 2025-01-07
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help