Fix kptr dtor deadlock
Status from this message: This series was applied to bpf/bpf-next.git (master)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest4 patches 0 repliesApplied 4/4
- v24 patches 5 repliesSuperseded
- v15 patches 6 repliesSuperseded
Changes in v3 from the cover letter
v2: https://lore.kernel.org/bpf/[email protected]
* Replace bpf_obj_cancel_fields() to use bpf_map_free_internal_structs(). (Mykyta)
* Fix CI failures.
Patches in v3 All 4 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | bpf: Reject bpf_obj_drop() from tracing progsinclude/ kernel/ tools/ +1 more | +93 | 0 replies | Applied |
| 2/4 | bpf: Cancel special fields on map value recycleinclude/ kernel/ kernel/ +8 more | +146 | 0 replies | Applied |
| 3/4 | selftests/bpf: Exercise unsafe obj drops from tracing progstools/ | +40 | 0 replies | Applied |
| 4/4 | selftests/bpf: Exercise kptr map update lifetimetools/ tools/ | +142 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH bpf-next v3 0/4] Fix kptr dtor deadlock
Referenced kptr destruction can run from tracing/NMI contexts through bpf_obj_drop() and map value update/delete paths, reaching NMI-unsafe special field teardown and deadlocks. Justin reported the issue and iterated on fixes in [0]-[2], and also confirmed the bpf_obj_drop() reproducer in [3].
This series rejects unsafe obj drops from non-iterator tracing programs, limits map value recycle to NMI-safe field cancellation, and adds focused selftests for the obj_drop(), NMI delete, and recycle teardown cases.
See patches for details.
[0]: https://lore.kernel.org/bpf/[email protected]
[1]: https://lore.kernel.org/bpf/[email protected]
[2]: https://lore.kernel.org/bpf/[email protected]
[3]: https://lore.kernel.org/bpf/agyG3eQwgmoJwmj2@suesslenovo
Changelog:
----------
v2 -> v3
v2: https://lore.kernel.org/bpf/[email protected]
* Replace bpf_obj_cancel_fields() to use bpf_map_free_internal_structs(). (Mykyta)
* Fix CI failures.
v1 -> v2
v1: https://lore.kernel.org/bpf/[email protected]
* Drop is_tracing_prog_type() fix due to compat breakage, revisit separately.
* Rework bpf_obj_drop() fix to additionally reject non-iter tracing progs.
Justin Suess (2):
bpf: Reject bpf_obj_drop() from tracing progs
bpf: Cancel special fields on map value recycle
Kumar Kartikeya Dwivedi (2):
selftests/bpf: Exercise unsafe obj drops from tracing progs selftests/bpf: Exercise kptr map update lifetime
include/linux/bpf.h | 30 +++++++ kernel/bpf/arraymap.c | 8 +- kernel/bpf/hashtab.c | 32 ++++--- kernel/bpf/syscall.c | 5 ++ kernel/bpf/verifier.c | 17 ++++ .../selftests/bpf/prog_tests/htab_update.c | 4 +- .../selftests/bpf/prog_tests/linked_list.c | 33 +++---- .../selftests/bpf/prog_tests/map_kptr.c | 66 ++++++++++++-- .../bpf/prog_tests/refcounted_kptr.c | 8 +- .../selftests/bpf/prog_tests/task_kfunc.c | 42 ++++++++- .../testing/selftests/bpf/progs/htab_update.c | 4 +- .../testing/selftests/bpf/progs/linked_list.c | 71 +++++++++++++++ tools/testing/selftests/bpf/progs/map_kptr.c | 89 ++++++++++++++++++- .../selftests/bpf/progs/refcounted_kptr.c | 20 ++++- .../selftests/bpf/progs/task_kfunc_failure.c | 40 +++++++++ .../selftests/bpf/progs/task_kfunc_success.c | 13 ++- 16 files changed, 421 insertions(+), 61 deletions(-)
base-commit: c15261b1bba0bb7921552cdd86c8b0202697a8f9
Signature · 1 line
2.53.0