[PATCH] uprobes: fix incorrect lockdep condition in filter_chain()

Breno Leitao posted 1 patch 1 week, 4 days ago
There is a newer version of this series
kernel/events/uprobes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] uprobes: fix incorrect lockdep condition in filter_chain()
Posted by Breno Leitao 1 week, 4 days ago
The list_for_each_entry_rcu() in filter_chain() uses
rcu_read_lock_trace_held() as the lockdep condition, but the function
holds consumer_rwsem, not the RCU trace lock.

This gives me the following output when running with some locking debug
option enabled:

  kernel/events/uprobes.c:1141 RCU-list traversed in non-reader section!!
    filter_chain
    register_for_each_vma
    uprobe_unregister_nosync
    __probe_event_disable

Remove the incorrect lockdep condition since the rwsem provides
sufficient protection for the list traversal.

Cc: stable@vger.kernel.org
Fixes: 87195a1ee332a ("uprobes: switch to RCU Tasks Trace flavor for better performance")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
 kernel/events/uprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index d546d32390a81..726d13b375f3d 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1138,7 +1138,7 @@ static bool filter_chain(struct uprobe *uprobe, struct mm_struct *mm)
 	bool ret = false;
 
 	down_read(&uprobe->consumer_rwsem);
-	list_for_each_entry_rcu(uc, &uprobe->consumers, cons_node, rcu_read_lock_trace_held()) {
+	list_for_each_entry(uc, &uprobe->consumers, cons_node) {
 		ret = consumer_filter(uc, mm);
 		if (ret)
 			break;

---
base-commit: 1f97d9dcf53649c41c33227b345a36902cbb08ad
change-id: 20260128-uprobe_rcu-e21867ab4c1b

Best regards,
--  
Breno Leitao <leitao@debian.org>
Re: [PATCH] uprobes: fix incorrect lockdep condition in filter_chain()
Posted by Oleg Nesterov 1 week, 4 days ago
On 01/28, Breno Leitao wrote:
>
> The list_for_each_entry_rcu() in filter_chain() uses
> rcu_read_lock_trace_held() as the lockdep condition, but the function
> holds consumer_rwsem, not the RCU trace lock.
> 
> This gives me the following output when running with some locking debug
> option enabled:
> 
>   kernel/events/uprobes.c:1141 RCU-list traversed in non-reader section!!
>     filter_chain
>     register_for_each_vma
>     uprobe_unregister_nosync
>     __probe_event_disable
>
> Remove the incorrect lockdep condition since the rwsem provides
> sufficient protection for the list traversal.

I hope Andrii will recheck, but looks obviously correct to me.

> Fixes: 87195a1ee332a ("uprobes: switch to RCU Tasks Trace flavor for better performance")

This commit just change the __list_check_rcu() condition...

Perhaps
Fixes: cc01bd044e6a ("uprobes: travers uprobe's consumer list locklessly under SRCU protection")

makes more sense?

Acked-by: Oleg Nesterov <oleg@redhat.com>
Re: [PATCH] uprobes: fix incorrect lockdep condition in filter_chain()
Posted by Andrii Nakryiko 1 week, 3 days ago
On Wed, Jan 28, 2026 at 5:51 AM Oleg Nesterov <oleg@redhat.com> wrote:
>
> On 01/28, Breno Leitao wrote:
> >
> > The list_for_each_entry_rcu() in filter_chain() uses
> > rcu_read_lock_trace_held() as the lockdep condition, but the function
> > holds consumer_rwsem, not the RCU trace lock.
> >
> > This gives me the following output when running with some locking debug
> > option enabled:
> >
> >   kernel/events/uprobes.c:1141 RCU-list traversed in non-reader section!!
> >     filter_chain
> >     register_for_each_vma
> >     uprobe_unregister_nosync
> >     __probe_event_disable
> >
> > Remove the incorrect lockdep condition since the rwsem provides
> > sufficient protection for the list traversal.
>
> I hope Andrii will recheck, but looks obviously correct to me.

yeah, I did, and it also looks obviously correct to me, I didn't need
to use rcu flavor there in the first place, I think.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>
> > Fixes: 87195a1ee332a ("uprobes: switch to RCU Tasks Trace flavor for better performance")
>
> This commit just change the __list_check_rcu() condition...
>
> Perhaps
> Fixes: cc01bd044e6a ("uprobes: travers uprobe's consumer list locklessly under SRCU protection")
>

yep, this one is the earliest change adding unnecessary rcu flavor of
list_for_each_entry


> makes more sense?
>
> Acked-by: Oleg Nesterov <oleg@redhat.com>
>
Re: [PATCH] uprobes: fix incorrect lockdep condition in filter_chain()
Posted by Breno Leitao 1 week, 3 days ago
On Wed, Jan 28, 2026 at 09:23:45AM -0800, Andrii Nakryiko wrote:
> On Wed, Jan 28, 2026 at 5:51 AM Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > On 01/28, Breno Leitao wrote:
> > >
> > > The list_for_each_entry_rcu() in filter_chain() uses
> > > rcu_read_lock_trace_held() as the lockdep condition, but the function
> > > holds consumer_rwsem, not the RCU trace lock.
> > >
> > > This gives me the following output when running with some locking debug
> > > option enabled:
> > >
> > >   kernel/events/uprobes.c:1141 RCU-list traversed in non-reader section!!
> > >     filter_chain
> > >     register_for_each_vma
> > >     uprobe_unregister_nosync
> > >     __probe_event_disable
> > >
> > > Remove the incorrect lockdep condition since the rwsem provides
> > > sufficient protection for the list traversal.
> >
> > I hope Andrii will recheck, but looks obviously correct to me.
> 
> yeah, I did, and it also looks obviously correct to me, I didn't need
> to use rcu flavor there in the first place, I think.
> 
> Acked-by: Andrii Nakryiko <andrii@kernel.org>
> 
> >
> > > Fixes: 87195a1ee332a ("uprobes: switch to RCU Tasks Trace flavor for better performance")
> >
> > This commit just change the __list_check_rcu() condition...
> >
> > Perhaps
> > Fixes: cc01bd044e6a ("uprobes: travers uprobe's consumer list locklessly under SRCU protection")
> >
> 
> yep, this one is the earliest change adding unnecessary rcu flavor of
> list_for_each_entry

Ack. I will respin with the correct "fixes" tag.

--breno