Re: [bpf-next v3 1/2] bpf: Offload kptr destructors that run from NMI
Kumar Kartikeya Dwivedi <[email protected]> Tue, 12 May 2026 04:08:51 +0200
| Newsgroups | dev.linux.lists.sashiko,org.kernel.vger.bpf |
|---|---|
| Message-ID | <CAP01T744a+hHqS83jC=eh_kwR1jCqdak=tjAEeQob0N3L4YMsA@mail.gmail.com> |
On Tue, 12 May 2026 at 04:07, Justin Suess <[email protected]> wrote: > > On Mon, May 11, 2026 at 06:55:50PM -0700, Alexei Starovoitov wrote: > > On Mon May 11, 2026 at 6:46 PM PDT, Kumar Kartikeya Dwivedi wrote: > > > On Tue, 12 May 2026 at 03:43, Justin Suess <[email protected]> wrote: > > >> > > >> On Mon, May 11, 2026 at 10:10:07PM +0200, Kumar Kartikeya Dwivedi wrote: > > >> > On Mon, 11 May 2026 at 19:29, Alexei Starovoitov > > >> > <[email protected]> wrote: > > > There is no deferral here. I'm saying that we just cancel for timer, > > > wq, task work, and leave other fields as is. So we don't have active > > > work pending for async items. > > > > > > So as long as the item keeps getting recycled in the allocator, we > > > don't free these fields. Once the memalloc is destroyed, the dtor runs > > > in a known safe context where we can assume bpf_obj_free_fields won't > > > deadlock or run into any problems. > > > > So the plan is to do > > if (in_nmi()) && case BPF_KPTR* | BPF_LIST_HEAD | BPF_RB_ROOT > > just ignore it? > > And no other changes anywhere at all? > > > > That would be too good to be true :) > I guess the last question I have is what would prevent an xchg() out of > a map on a recycled kptr from causing a UAF? xchg() is atomic, so either a program now has the value, or the map has it. Whoever has it will end up freeing it. If the program has it then the program frees it. I don't see why there would be a UAF.