lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzabO7NuSTZ5fKSb2UBZAxA9EnrXVtO2=J38B1UN5ExBrg@mail.gmail.com>
Date: Fri, 8 Nov 2024 09:28:17 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Breno Leitao <leitao@...ian.org>, Masami Hiramatsu <mhiramat@...nel.org>, 
	Oleg Nesterov <oleg@...hat.com>, Ingo Molnar <mingo@...hat.com>, 
	Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>, 
	Mark Rutland <mark.rutland@....com>, 
	Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>, 
	Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>, 
	Andrii Nakryiko <andrii@...nel.org>, linux-perf-users@...r.kernel.org, 
	linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org, 
	kernel-team@...a.com
Subject: Re: [PATCH] uprobes: get RCU trace lock before list iteration

On Fri, Nov 8, 2024 at 1:00 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Thu, Nov 07, 2024 at 09:14:45AM -0800, Breno Leitao wrote:
> > Acquire RCU trace lock in filter_chain() to protect
> > list_for_each_entry_rcu() iteration, protecting the list iteration in a
> > RCU read section.
> >
> > Prior to this fix, list_for_each_entry_srcu() was called without holding
> > the required lock, triggering warnings when RCU_PROVING is enabled:
> >
> >       kernel/events/uprobes.c:937 RCU-list traversed without holding the required lock!!
> >
> > Signed-off-by: Breno Leitao <leitao@...ian.org>
> > Fixes: cc01bd044e6a ("uprobes: travers uprobe's consumer list locklessly under SRCU protection")
> > ---
> >  kernel/events/uprobes.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> > index fa04b14a7d72353adc440742016b813da6c812d2..afdaa45a43ac3948f7983175eda808c989e8738a 100644
> > --- a/kernel/events/uprobes.c
> > +++ b/kernel/events/uprobes.c
> > @@ -1103,11 +1103,13 @@ static bool filter_chain(struct uprobe *uprobe, struct mm_struct *mm)
> >       bool ret = false;
> >
> >       down_read(&uprobe->consumer_rwsem);
> > +     rcu_read_lock_trace();
> >       list_for_each_entry_rcu(uc, &uprobe->consumers, cons_node, rcu_read_lock_trace_held()) {
>
> Maybe I'm confused, but isn't uprobe->consumer list protected by
> uprobe->consumer_rwsem, which we hold for reading?
>
> That is, AFAICT this is a false positive and we should be doing this
> instead, no?

Yep, you are absolutely right. RCU-protected traversal is important
only for handler_chain() and handle_uretprobe_chain(). Here it's all
under lock, so no need for RCU protection.

>
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index a76ddc5fc982..a5405e9ef9f5 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -1104,7 +1104,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) {

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

>                 ret = consumer_filter(uc, mm);
>                 if (ret)
>                         break;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ