[PATCH 0/3] fork, exit: fix BPF use-after-frees on task pointers

From: Chris Mason

Date: Thu Dec 03 2026 - 15:06:19 EST


Hi everyone,

These are AI generated fixes for a few ways that BPF programs can follow
task_struct pointers into freed memory.

Patch 1 fixes the parent pointers of new tasks and idle tasks, patch 2
fixes the parent and leader pointers of released tasks, and patch 3 stops
the BPF thread iterator from starting at a released task.

Patch 2 makes a released thread hold a reference on its group leader,
which I don't love. If there are better ideas, I'm happy to get
the bots cranking on them.

Chris Mason (3):
fork: make the creator the parent of an unlinked task
exit: don't leave stale parent and leader pointers
bpf: Don't start a thread walk at a released task

kernel/bpf/task_iter.c | 3 +++
kernel/exit.c | 22 +++++++++++++++++++++-
kernel/fork.c | 40 ++++++++++++++++++++++++++--------------
3 files changed, 50 insertions(+), 15 deletions(-)


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
--
2.55.0