Re: [PATCH v2 1/2] rust: task: limit group_leader() to current

From: Jann Horn

Date: Fri Feb 13 2026 - 08:38:36 EST


On Fri, Feb 13, 2026 at 8:52 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
> On Thu, Feb 12, 2026 at 11:12 PM Jann Horn <jannh@xxxxxxxxxx> wrote:
> >
> > (Note: This is not a bugfix, it just cleans up an incorrect assumption.)
> >
> > Task::group_leader() assumes that task::group_leader remains constant until
> > the task refcount drops to zero.
> >
> > However, Linux has a special quirk where, when execve() is called by a
> > thread other than the thread group leader (the main thread), de_thread()
> > swaps the current thread's identity with the thread group leader's,
> > making the current thread the new thread group leader.
> > This means task::group_leader can't be assumed to be immutable for
> > non-current tasks.
> >
> > For reference, you can see that accessing the ->group_leader of some random
> > task requires extra caution in the prlimit64() syscall, which grabs the
> > tasklist_lock and has a comment explaining that this is done to prevent
> > races with de_thread().
> >
> > Signed-off-by: Jann Horn <jannh@xxxxxxxxxx>
>
> This has already been fixed:
> https://lore.kernel.org/all/20260107-task-group-leader-v2-1-8fbf816f2a2f@xxxxxxxxxx/

Ah, and I didn't notice it because it was in the mm tree while I was
looking at the rust tree. Sorry for the duplicate patch.