From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796329868; b=osX4MCYsTtqZHYSRFKqRkgHNzG42DX05zCdEy2iZfjlVRf9irMkaFrpAaIWGm75p2NDQ 99C8i6Q1Fn9bzc3dHQ32Yn7v2yTUzbWylhIv4HJQStXfcBArKf/njm1NEdtyi5LIekT5K hg6iJtVOsQ3yKNJyDeR+Tw2DMNqhgSuH4tCgDj/trXtNvNLle24cD8kgZWItxsS/jnIKY H6gGb8P18aZZNXEOQbAMKPuRMe1n2eHa1wYtz1OwKFSIV1Ri1+8hwn6FKfFwX7zoNvkS1 ZQEC2f2PeO63bF5Ag7zY/IyI+58C1/ywZBIxhfRijS7GeoUXDNGvtF/n6oKD720SJdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796329868; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=ji9k7c0yqEMfl980mcsaxNu93GpatZ0wXBSuvPEiTD4=; b=pBdPh9PRKzfVpffONHmJee/y4rB+2UmcIjGXWol5NULDtnnrLVn9fChv6qHAtu1WKs/C UPJ4o/C77SO2EaOaxmlINysWKs4nhw6ETiF6UCk+RGhQL2Cem46N+p+X7B/p8cR1rF1rP rayLZijCje91CH5R9fH+oPVrFcZR574CfErNf76gktLJgq+gbhU1sBFdcRSN4ZleTcxRs HnNbP2nd0Uyugi9/ixiASwxucMVH+ohZEatNvCMrynBOP4R2MGi/TFt3K/X/F91NBhVB4 jIRkG9LG2FhbIcsO9yJn3/iMYMay3WsmCwIVs/LUSWZhIKZBDLEbZyPLd4uspRgB/QA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=L0FLu8nv; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F60F606A322; Thu, 3 Dec 2026 20:31:08 +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=L0FLu8nv Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEC3B1F000C2; Thu, 3 Dec 2026 20:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796329868; bh=ji9k7c0yqEMfl980mcsaxNu93GpatZ0wXBSuvPEiTD4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=L0FLu8nvTXe5FlCEVlDdVF+KQHJMpq70H2p03GFHQEdwTZN7NQ+w2jU/Pg3oiPVtF +nVOAm/2htHyjZuNJFgXC6sbEwfKz8X/EvyI/GNcUGkhl9fU3RPjJ0fg2CBrWmEUDm m980IKZDGdSp6NQvtcUsz5l/YryQ++UiD+0in0PGTkZbQ/WNhucOq/a9W4PkedYpSa J+gdznaycefhwK8mJ5aNGtJSla6myO3G49aWBImOLhtXH6oTKbyBO7ppQljh7cMeuZ ANerkpIIeXJDR7Thb1SR9F3igIlRwMVLEw0jEm2lzprUCl/jQbR1hh4Fuk/p2+X26r 6xnqyvpWFHisw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 1/3] fork: make the creator the parent of an unlinked task Reply-To: sashiko-reviews@lists.linux.dev To: "Chris Mason" , bpf@vger.kernel.org Cc: sched-ext@lists.linux.dev In-Reply-To: <20261203200612.26376-2-mason@kernel.org> References: <20261203200612.26376-1-mason@kernel.org> <20261203200612.26376-2-mason@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 20:31:07 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] fork: stale parent and group_leader pointers across delayed_free_task() -- commit baa0d889662d0754e858f27233d7dd23f9b6844d Author: Chris Mason fork: make the creator the parent of an unlinked task This commit points a new task's real_parent and parent at the forking task in dup_task_struct() until copy_process() reaches the point of no return, and points idle tasks' parent pointers at init_task. > diff --git a/kernel/fork.c b/kernel/fork.c > index d55a7d21a8fb2..3734aaa717130 100644 > --- a/kernel/fork.c > +++ b/kernel/fork.c > @@ -977,6 +977,12 @@ static struct task_struct *dup_task_struct(struct ta= sk_struct *orig, int node) > refcount_set(&tsk->rcu_users, 0); > /* One for the rcu users */ > refcount_set(&tsk->usage, 1); > + /* > + * Nobody updates the parents of a task that is on no list, and orig > + * stays until copy_process() is done. > + */ > + RCU_INIT_POINTER(tsk->real_parent, orig); > + RCU_INIT_POINTER(tsk->parent, orig); > #ifdef CONFIG_BLK_DEV_IO_TRACE > tsk->btrace_seq =3D 0; > #endif [Severity: Medium] Can tsk->real_parent and tsk->parent dangle past copy_process() when a fork fails under CONFIG_MEMCG? On bad_fork_free, delayed_free_task(p) defers free_task(p) via call_rcu() when CONFIG_MEMCG is enabled. Once copy_process() returns an error, orig c= an exit, be reaped, and be freed before __delayed_free_task() runs on another CPU: CPU0 CPU1 copy_process() dup_task_struct() p->real_parent =3D orig ... (fails -> bad_fork_free) delayed_free_task(p) call_rcu(&p->rcu, ...) orig exits and is reaped delayed_put_task_struct(orig) free_task(orig) __delayed_free_task(p) free_task(p) fentry/free_task: bpf_find_vma(p->real_parent, ...) <-- use-after-free In an fentry/free_task BPF program, walking tsk->real_parent or tsk->parent produces a plain PTR_TO_BTF_ID accepted by legacy helpers such as bpf_find_vma(). bpf_find_vma() directly locks task->alloc_lock without probe-fault protection, resulting in a slab use-after-free. bad_fork_free already clears p->mm for this window from commit dab101c9414d ("fork: clear p->mm when copy_process() fails"), and p->group_leader has the same lifetime issue. Resetting p->real_parent and p->parent to &init_task and p->group_leader to p before delayed_free_task(p) would close this gap. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203200612.2637= 6-1-mason@kernel.org?part=3D1