From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08816606A322 for ; Sat, 5 Dec 2026 13:36:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CSL3lAe8 Received: by kanga.kvack.org (Postfix) id 2B0136B05B1; Sat, 5 Dec 2026 08:36:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 287D56B05B3; Sat, 5 Dec 2026 08:36:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C4046B05B4; Sat, 5 Dec 2026 08:36:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1FA346B05B1 for ; Sat, 5 Dec 2026 08:36:17 -0500 (EST) Received: from smtpin20.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0B9BF1C3E75 for ; Sat, 5 Dec 2026 13:36:11 +0000 (UTC) X-FDA: 85510028142.20.030CDC4 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf04.hostedemail.com (Postfix) with ESMTP id 5E0AF40002 for ; Sat, 5 Dec 2026 13:36:09 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=CSL3lAe8; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796477769; b=PzyYc5+56B6NHU9vu9yIGk1RaAHlCuWvXGn5KYa2z5xqjzxjZUgSyzKnZbNVe47PE89z3H Vugb70ikZP+GdjCf+dCF07xOeGWDicK7mmVkEp9ges0xtETCvyJDNuNmcPDiWaePoaQueP LA3TZT4ckawvB9/2dAX7/N1R3p143fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796477769; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Qs82HjsEYfci6HYU4slJh62ZTQbj/ed1ofApjW0SQoc=; b=DKF62dZZ63lkLdhBSOJR0EgvRe0Y4jtrCDyex7GC687EIpET3o3BTmHssxYEbJYoiurAHq kQrnUDcLKlhXeNU5WY0Y9SU5UioqCMvLRHCF0hDs2UF3CqOYmJuwaLieg2a1Cot4TxGpIU Tv8h72PPJSyfoSCI4GMePoHteuF32Wo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=CSL3lAe8; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf04.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E4811601AC; Sat, 5 Dec 2026 13:36:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B78A11F00936; Sat, 5 Dec 2026 13:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796477768; bh=Qs82HjsEYfci6HYU4slJh62ZTQbj/ed1ofApjW0SQoc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=CSL3lAe8MRrv5Jn/vP5pCa8Ax5912uIIZ8aYhZL9bavaEOYAE9zQH17g3TyqeQAOy zeWPk3PwQ+BhuHJClhA6ZotvRHzSBeckqJ1ROp1ldhY09PGbe0sxmDfXvjEo3zVYXV zXUzgOylOsR9E0VfPQvfKy04MRErEH5gLIsLG+UQwHtWNo7+RhIhHVotIhR+lqCm4L 8ERXf5aQ51QnhHSylhyIqXbBM5gpqkFrrIakazXKZKJY/Hl3sn179Z6BF/qtLh1whS QEPyEVSNgFBp5nwX/11PHIkJ+upPNMLRKmRH10GpcvEMNw9dkTOvG9X3xz5PE2vUJ1 5GMq4OBCN9oLQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 3/8] exit: reset a released task's parent and leader Reply-To: sashiko-reviews@lists.linux.dev To: "Chris Mason" , brauner@kernel.org, oleg@redhat.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, bpf@vger.kernel.org Cc: akpm@linux-foundation.org, peterz@infradead.org, mingo@redhat.com, kees@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, bsingharora@gmail.com, 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, linux-mm@kvack.org In-Reply-To: <20261204233428.14861-4-mason@kernel.org> References: <20261204233428.14861-1-mason@kernel.org> <20261204233428.14861-4-mason@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 13:36:07 +0000 X-Rspamd-Server: rspam02 X-Rspam-User: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Stat-Signature: noy8psoh3of5drt3g3axrz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/9+u0RNFCRG40dV/xyjKfHdbVStOSqqYYPcSh9jFm+Sso2XEIHv+X7ihISWhVRZljyJpRii9LgGb8RAPBMoOnGBD/9631b4Q2KfWedHkgPovv0UP4hKzfCDkzuh2Tsw/OqzEvXyKDi1qoxwoghRtOpOAWKjnf+hTlm0HSjiSM1nw2J4ZQ8NwMf6wdITzrlWdVbcUFfi6sFqkU/pyIVZdYqyXZOAUuB2L1UrGjTCSX7zQ0OqhnyFS2puyF0v8U685vckFFK8aC4Rs3sKphycLfKx+HufLY0t9DEVONV8+PpB4eNwZ91as6zUk5CX6nUpFqnBlwrYDABRhYe2+bY4C7E4bT6SQKnK6HxqYf/LOOtXJc8LdT0BvZcydtgEIUJzLhZX7tsZvednWZH9AZ3DuGf/g01jXLzl5qhIDJmeQQoA6MeqMcmTAuVzJhA47B1kcGHttJP/iyVedvG/8iNVAf5C/iWrJBMQLfxU45Y6b38aF7JpBZvrAQPTGE9i3BTmFKmdy3BNZA2buw6BmkNN9sWez1bI8BhWZsW79hf0eGxELNf3VVb6AvV0Gs7jq8L60rYzYdV9PD+beXoyrYVxgGjNV1kAULdMN7vFsYMdu6t/rogcbC5w7s8bQN0CfdCqi2VgM5WsaheyKnyWQCgI7oK+G4pOcu0kKiTu8NgxcQDCazYTSOV31B6yPGKXtoCuLaq+1J0+ZaG/Y8eP7tHzGRnbXZmrrBlAMTpk29/gki4YDb2Q2if5AueDys16FlnVjXidzNoubMaGg0hYl34F8F+CyA== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] exit: reset_parent_and_leader() breaks lockless RCU real_parent walks -- commit 4d9f47097374975327e6ccb2ac8993c54f45179d Author: Chris Mason exit: reset a released task's parent and leader This commit resets real_parent and parent to init_task and group_leader to the task itself in release_task() so BPF programs holding a task reference cannot follow stale pointers after the parent or group leader is freed. > diff --git a/include/linux/sched/task.h b/include/linux/sched/task.h > index 90ed5bc3c7afe..b30a66748af2c 100644 > --- a/include/linux/sched/task.h > +++ b/include/linux/sched/task.h > @@ -80,6 +80,17 @@ extern void fork_init(void); > =20 > extern void release_task(struct task_struct * p); > =20 > +/* > + * Nobody updates these pointers if @p isn't in the process tree, but BPF > + * programs can still follow them. So don't leave any that can go stale. > + */ > +static inline void reset_parent_and_leader(struct task_struct *p) > +{ > + RCU_INIT_POINTER(p->real_parent, &init_task); > + RCU_INIT_POINTER(p->parent, &init_task); > + WRITE_ONCE(p->group_leader, p); > +} > + > extern int copy_thread(struct task_struct *, const struct kernel_clone_a= rgs *); > =20 > extern void flush_thread(void); > diff --git a/kernel/exit.c b/kernel/exit.c > index d5e7bc2af804a..8a5985821e17d 100644 > --- a/kernel/exit.c > +++ b/kernel/exit.c > @@ -288,6 +288,7 @@ void release_task(struct task_struct *p) > leader->exit_state =3D EXIT_DEAD; > } > =20 > + reset_parent_and_leader(p); > write_unlock_irq(&tasklist_lock); > proc_flush_pid(thread_pid); > put_pid(thread_pid); [Severity: High] Can resetting p->real_parent to &init_task in release_task() before an RCU grace period elapses break concurrent lockless RCU ancestor walks? CPU0 (task M exiting) CPU1 (RCU walk from child C) rcu_read_lock() t =3D rcu_dereference(C->real_parent) exit_notify() forget_original_parent(M) release_task(M) reset_parent_and_leader(M) M->real_parent =3D &init_task t =3D rcu_dereference(M->real_parent) <-- jumps to init_task, skips A When M is autoreaped (for example with SIG_IGN on SIGCHLD), exit_notify() reparents C to ancestor A via forget_original_parent() and immediately calls release_task(M). A concurrent RCU reader that already loaded M then jumps to init_task and skips A and all higher ancestors. An unprivileged process inside a monitored subtree can repeatedly trigger this fork/exit race to bypass a BPF LSM ancestor-deny policy. In-tree, task_is_descendant() in security/yama/yama_lsm.c terminates early at init_task and spuriously fails PTRACE_ATTACH with -EPERM. The commit message also misses nfs_access_login_time() in fs/nfs/dir.c, which walks real_parent locklessly under RCU: fs/nfs/dir.c:nfs_access_login_time() { for (;;) { parent =3D rcu_dereference(task->real_parent); pcred =3D __task_cred(parent); if (parent =3D=3D task || cred_fscmp(pcred, cred) !=3D 0) break; task =3D parent; } ret =3D task->start_time; Jumping to init_task stops the walk early for non-root credentials (spurious cache invalidation). For root credentials under a non-root ancestor, it matches init_cred and returns init_task.start_time (0), allowing stale pre-session cached access entries to be reused. In-tree walkers could detect stepping onto init_task from a !pid_alive() task and restart from the live starting task, whose real_parent was already reparented before release_task() ran. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204233428.1486= 1-1-mason@kernel.org?part=3D3