* [PATCH v2] uprobes: Remove unnecessary RCU list traversal in filter_chain()
@ 2024-11-11 14:30 Breno Leitao
0 siblings, 0 replies; only message in thread
From: Breno Leitao @ 2024-11-11 14:30 UTC (permalink / raw)
To: Masami Hiramatsu, Oleg Nesterov, Peter Zijlstra, Ingo Molnar,
Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
Andrii Nakryiko
Cc: linux-kernel, linux-trace-kernel, linux-perf-users, kernel-team,
Breno Leitao
The filter_chain() function was using list_for_each_entry_rcu() to traverse
uprobe->consumers without holding an RCU read lock, causing warnings when
CONFIG_RCU_PROVING is enabled:
kernel/events/uprobes.c:937 RCU-list traversed without holding the required lock!!
5 locks held by bench/182758:
#1: ffff888603aaac90 (&uprobe->register_rwsem){+.+.}-{3:3}, at: uprobe_unregister_nosync+0x28/0xc0
#4: ffff888603aaad28 (&uprobe->consumer_rwsem){++++}-{3:3}, at: filter_chain+0x20/0xe0
The uprobe->consumers list is actually protected by uprobe->consumer_rwsem,
which is already held when the list traversal begins. This means the RCU
primitive is unnecessary here - the rwsem provides sufficient protection
for the list traversal, as reported by Peterz.
Replace list_for_each_entry_rcu() with list_for_each_entry() since the
RCU read lock is not needed when accessing uprobe->consumers under the
protection of consumer_rwsem.
Signed-off-by: Breno Leitao <leitao@debian.org>
Fixes: cc01bd044e6a ("uprobes: travers uprobe's consumer list locklessly under SRCU protection")
Acked-by: Andrii Nakryiko <andrii@kernel.org>
---
Changelog:
v2:
* Move away from the RCU primitive (list_for_each_entry_rcu) to the
non-rcu one, since RCU is not needed here (Peter)
v1:
* https://lore.kernel.org/all/20241107-rcu_probe-v1-1-0ca8cc2dedfb@debian.org/
---
kernel/events/uprobes.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 4b52cb2ae6d620b2526de7e86291bdc137aa4f49..372fde678cefce72650b6c200ebea0093193ad6a 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -934,8 +934,7 @@ static bool filter_chain(struct uprobe *uprobe, struct mm_struct *mm)
bool ret = false;
down_read(&uprobe->consumer_rwsem);
- list_for_each_entry_srcu(uc, &uprobe->consumers, cons_node,
- srcu_read_lock_held(&uprobes_srcu)) {
+ list_for_each_entry(uc, &uprobe->consumers, cons_node) {
ret = consumer_filter(uc, mm);
if (ret)
break;
---
base-commit: 774ca6d3bf24287ff60b7d6dd4171ebb6e47760a
change-id: 20241111-rcu_probe-0b8dfa53a8a1
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-11-11 14:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11 14:30 [PATCH v2] uprobes: Remove unnecessary RCU list traversal in filter_chain() Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).