[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMB2axPEmykdt2Wcvb49j1iG8b+ZTxvDoRgRYKmJAnTvbLsN9g@mail.gmail.com>
Date: Mon, 17 Nov 2025 12:37:45 -0800
From: Amery Hung <ameryhung@...il.com>
To: Alexei Starovoitov <alexei.starovoitov@...il.com>
Cc: bpf <bpf@...r.kernel.org>, Network Development <netdev@...r.kernel.org>,
Andrii Nakryiko <andrii@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...nel.org>, Kumar Kartikeya Dwivedi <memxor@...il.com>, KP Singh <kpsingh@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, Song Liu <song@...nel.org>,
Kernel Team <kernel-team@...a.com>
Subject: Re: [PATCH v2 bpf-next 4/4] bpf: Replace bpf memory allocator with
kmalloc_nolock() in local storage
On Fri, Nov 14, 2025 at 6:01 PM Alexei Starovoitov
<alexei.starovoitov@...il.com> wrote:
>
> On Fri, Nov 14, 2025 at 12:13 PM Amery Hung <ameryhung@...il.com> wrote:
> >
> >
> > - if (smap->bpf_ma) {
> > + if (smap->use_kmalloc_nolock) {
> > rcu_barrier_tasks_trace();
> > - if (!rcu_trace_implies_rcu_gp())
> > - rcu_barrier();
> > - bpf_mem_alloc_destroy(&smap->selem_ma);
> > - bpf_mem_alloc_destroy(&smap->storage_ma);
> > + rcu_barrier();
>
> Why unconditional rcu_barrier() ?
> It's implied in rcu_barrier_tasks_trace().
Hmm, I am not sure.
> What am I missing?
I hit a UAF in v1 in bpf_selem_free_rcu() when running selftests and
making rcu_barrier() unconditional addressed it. I think the bug was
due to map_free() not waiting for bpf_selem_free_rcu() (an RCU
callback) to finish.
Looking at rcu_barrier() and rcu_barrier_tasks_trace(), they pass
different rtp to rcu_barrier_tasks_generic() so I think both are
needed to make sure in-flight RCU and RCU tasks trace callbacks are
done.
Not an expert in RCU so I might be wrong and it was something else.
>
> The rest looks good.
> If that's the only issue, I can fix it up while applying.
Powered by blists - more mailing lists