All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/1] bpf: Fix deadlock in freeing of special fields in NMI
@ 2026-05-19  1:14 Justin Suess
  2026-05-19  1:14 ` [PATCH bpf-next 1/1] bpf: fix deadlock in special field destruction " Justin Suess
  0 siblings, 1 reply; 13+ messages in thread
From: Justin Suess @ 2026-05-19  1:14 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: martin.lau, song, yonghong.song, jolsa, bpf, mic, Justin Suess

Hello,

While following up on a Sashiko report [1], I found that referenced kptr
destructors can run from NMI context. One way to trigger this is from a
tracing program attached to tp_btf/nmi_handler while a map element is
being torn down.

This is a discards any approach from the previous series [2], thus starting
fresh with a new one.

This changes the existing eager freeing behavior of bpf_obj_free_fields to only
freeing certain fields in irqs_disabled contexts.

These fields not safe to free in irqs_disabled contexts like nmi include
BPF_KPTR_REF, BPF_KPTR_PERCPU, BPF_UPTR, BPF_LIST_HEAD, and BPF_RB_ROOT.

The freeing of the fields under those conditions will now be done by the bpf
memory allocator, which has a safe destructor mechanism that guarantees the
fields are freed in a non-irqs_disabled context.

Some changes were required to the hashtab map specifically. When the above listed
fields are present, the map is converted at initialization time to the non-prealloc
variant. Additionally, the in-place field updates used by LRU and percpu maps were
disabled when these special fields are present, to avoid leaking references and
overwriting those fields when we can't free them immediately.

The relevant discussion for this change is here [2]

Kind regards,
Justin Suess

[1] https://lore.kernel.org/bpf/20260421010536.17FB1C19425@smtp.kernel.org/
[2] https://lore.kernel.org/bpf/20260507175453.1140400-1-utilityemal77@gmail.com/
[3] https://lore.kernel.org/bpf/agCXEJKJh-JGMhjG@zenbox/

Justin Suess (1):
  bpf: fix deadlock in special field destruction in NMI

 kernel/bpf/hashtab.c | 93 +++++++++++++++++++++++++++++++++++++++-----
 kernel/bpf/syscall.c |  8 +++-
 2 files changed, 89 insertions(+), 12 deletions(-)


base-commit: 576482b55c19e7ec00e162a0fde4c4f1a95128c7
-- 
2.53.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-06-07  2:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19  1:14 [PATCH bpf-next 0/1] bpf: Fix deadlock in freeing of special fields in NMI Justin Suess
2026-05-19  1:14 ` [PATCH bpf-next 1/1] bpf: fix deadlock in special field destruction " Justin Suess
2026-05-19  1:51   ` sashiko-bot
2026-05-19 14:42     ` Justin Suess
2026-05-19 15:59       ` Justin Suess
2026-05-19 19:27         ` Kumar Kartikeya Dwivedi
2026-05-19 23:19           ` Justin Suess
2026-06-06 16:27           ` Justin Suess
2026-06-07  2:40             ` Kumar Kartikeya Dwivedi
2026-05-19 10:25   ` kernel test robot
2026-05-19 12:31   ` Mykyta Yatsenko
2026-05-19 13:22     ` Justin Suess
2026-05-19 13:55       ` Mykyta Yatsenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.