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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQJPf9N1THd4DXbOC=UthYvaPmOm5xQD2rcFunGXp6h5_g@mail.gmail.com>
Date: Thu, 9 Jan 2025 10:38:03 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: linux-modules@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>, 
	Daniel Gomez <da.gomez@...sung.com>, Luis Chamberlain <mcgrof@...nel.org>, 
	"Paul E . McKenney" <paulmck@...nel.org>, Peter Zijlstra <peterz@...radead.org>, 
	Petr Pavlu <petr.pavlu@...e.com>, Sami Tolvanen <samitolvanen@...gle.com>, 
	Thomas Gleixner <tglx@...utronix.de>, Alexei Starovoitov <ast@...nel.org>, Andrii Nakryiko <andrii@...nel.org>, 
	Daniel Borkmann <daniel@...earbox.net>, Eduard Zingerman <eddyz87@...il.com>, Hao Luo <haoluo@...gle.com>, 
	Jiri Olsa <jolsa@...nel.org>, John Fastabend <john.fastabend@...il.com>, 
	KP Singh <kpsingh@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, 
	Masami Hiramatsu <mhiramat@...nel.org>, Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, 
	Matt Bobrowski <mattbobrowski@...gle.com>, Song Liu <song@...nel.org>, 
	Stanislav Fomichev <sdf@...ichev.me>, Steven Rostedt <rostedt@...dmis.org>, 
	Yonghong Song <yonghong.song@...ux.dev>, bpf <bpf@...r.kernel.org>, 
	linux-trace-kernel <linux-trace-kernel@...r.kernel.org>
Subject: Re: [PATCH v3 25/28] bpf: Use RCU in all users of __module_text_address().

On Wed, Jan 8, 2025 at 1:05 AM Sebastian Andrzej Siewior
<bigeasy@...utronix.de> wrote:
>
> __module_address() can be invoked within a RCU section, there is no
> requirement to have preemption disabled.
>
> Replace the preempt_disable() section around __module_address() with
> RCU.
>
> Cc: Alexei Starovoitov <ast@...nel.org>
> Cc: Andrii Nakryiko <andrii@...nel.org>
> Cc: Daniel Borkmann <daniel@...earbox.net>
> Cc: Eduard Zingerman <eddyz87@...il.com>
> Cc: Hao Luo <haoluo@...gle.com>
> Cc: Jiri Olsa <jolsa@...nel.org>
> Cc: John Fastabend <john.fastabend@...il.com>
> Cc: KP Singh <kpsingh@...nel.org>
> Cc: Martin KaFai Lau <martin.lau@...ux.dev>
> Cc: Masami Hiramatsu <mhiramat@...nel.org>
> Cc: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
> Cc: Matt Bobrowski <mattbobrowski@...gle.com>
> Cc: Song Liu <song@...nel.org>
> Cc: Stanislav Fomichev <sdf@...ichev.me>
> Cc: Steven Rostedt <rostedt@...dmis.org>
> Cc: Yonghong Song <yonghong.song@...ux.dev>
> Cc: bpf@...r.kernel.org
> Cc: linux-trace-kernel@...r.kernel.org
> Acked-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
>  kernel/trace/bpf_trace.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 1b8db5aee9d38..020df7b6ff90c 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -2336,10 +2336,9 @@ void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp)
>  {
>         struct module *mod;
>
> -       preempt_disable();
> +       guard(rcu)();
>         mod = __module_address((unsigned long)btp);
>         module_put(mod);
> -       preempt_enable();
>  }
>
>  static __always_inline
> @@ -2907,16 +2906,14 @@ static int get_modules_for_addrs(struct module ***mods, unsigned long *addrs, u3
>         for (i = 0; i < addrs_cnt; i++) {
>                 struct module *mod;
>
> -               preempt_disable();
> -               mod = __module_address(addrs[i]);
> -               /* Either no module or we it's already stored  */
> -               if (!mod || has_module(&arr, mod)) {
> -                       preempt_enable();
> -                       continue;
> +               scoped_guard(rcu) {
> +                       mod = __module_address(addrs[i]);
> +                       /* Either no module or we it's already stored  */
> +                       if (!mod || has_module(&arr, mod))
> +                               continue;
> +                       if (!try_module_get(mod))
> +                               err = -EINVAL;

lgtm.
Should we take into bpf-next or the whole set is handled together
somewhere?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ