BPF List
 help / color / mirror / Atom feed
From: "Chris Mason" <mason@kernel.org>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
Cc: brauner@kernel.org, oleg@redhat.com, daniel@iogearbox.net,
	andrii@kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	peterz@infradead.org, mingo@redhat.com, kees@kernel.org,
	tj@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
	yonghong.song@linux.dev, martin.lau@linux.dev, song@kernel.org,
	jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev,
	sched-ext@lists.linux.dev
Subject: Re: [PATCH 0/3] fork, exit: fix BPF use-after-frees on task pointers
Date: Fri, 04 Dec 2026 10:36:36 -0500	[thread overview]
Message-ID: <1796379632.2.26376.0@kernel.org> (raw)
In-Reply-To: <DNBLK9RDUGDB.9IRD3EGPT1GZ@gmail.com>

On Fri, 04 Dec 2026 02:36:25 +0000, Alexei Starovoitov wrote:
> On Thu, Dec 03, 2026 at 12:06 PM Chris Mason <mason@kernel.org> 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.

Please hold off on patches 1-2, it looks like patch 2 leaks.  A BPF program can
keep a thread in its leader's task storage, and then neither of them is freed.
The bots are working on v2, and I'll have them try Oleg's suggestion as well.

You're right about bacct_add_tsk(), claude reproduced that one with KASAN.

-chris


      parent reply	other threads:[~2026-12-04 15:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 20:06 [PATCH 0/3] fork, exit: fix BPF use-after-frees on task pointers Chris Mason
2026-12-03 20:06 ` [PATCH 1/3] fork: make the creator the parent of an unlinked task Chris Mason
2026-12-03 20:31   ` sashiko-bot
2026-12-04 15:27   ` Oleg Nesterov
2026-12-04 16:27     ` Chris Mason
2026-12-03 20:06 ` [PATCH 2/3] exit: don't leave stale parent and leader pointers Chris Mason
2026-12-03 20:31   ` sashiko-bot
2026-12-03 20:55   ` bot+bpf-ci
2026-12-03 20:06 ` [PATCH 3/3] bpf: Don't start a thread walk at a released task Chris Mason
2026-12-03 20:42   ` bot+bpf-ci
2026-12-04  2:36 ` [PATCH 0/3] fork, exit: fix BPF use-after-frees on task pointers Alexei Starovoitov
2026-12-04 12:53   ` Oleg Nesterov
2026-12-04 15:36   ` Chris Mason [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1796379632.2.26376.0@kernel.org \
    --to=mason@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brauner@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=tj@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox