Re: [PATCH 0/3] fork, exit: fix BPF use-after-frees on task pointers
From: Alexei Starovoitov
Date: Thu Dec 03 2026 - 21:36:36 EST
On Thu, Dec 03, 2026 at 12:06 PM Chris Mason <mason@xxxxxxxxxx> wrote:
> These are AI generated fixes for a few ways that BPF programs can follow
> task_struct pointers into freed memory.
The bugs look real. fork and exit are the right place to fix them imo.
The verifier can't tell a released task from a live one.
BUT the title is misleading.
The kernel has the same bug without bpf. fill_stats_for_pid() holds
a reference on tsk and nothing else. Then bacct_add_tsk() reads
tsk->group_leader->start_time.
> 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.
I don't see a different option.
Oleg,
pls review.
Christian,
if it looks good to folks, could you take patches 1-2 via your tree?
I'll take patch 3.