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=1796536768; b=HJ6lGJ2I/P1hrtxyfNy/wKdBzQ+r3O3ToNTK+2BcLfdhAiEiXdwK0t7uXUGCpNsEONr4 B2dzI0NtHb6SL86q0qnQjyXKs2DAlcWboe3s7ahqckZSogXYMDqibLu5Ag+kTpejNGIEm 2c8IFkokjyYauGSjai/t/wMrr2oGOXu1869UyJKXMhYQYYsO088fPjk2V/QKBn2O3ZMan nDmx3JkGjpmEW2FZKbo5SKWTmxB2AmhSoQ+FIpHlVd9SftWyrdIyPgakEsXicEV1lZ7sA DiHven5jHSBanam82EULOa85ATDMCF3GC+Y/iYWnFxAaH5ZqVuq85QgF00gAnvqSgaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796536768; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=N+a0g0RKf+U+Wxq4+b9weTWQlxzXgNSENYm4Y4Mxzo0=; b=fpkSDKf4fkvWiUqZ9WZ8nGSN2tmhwdzlPWWDIWrYFozbZrqL3pCFv2tRmuSlWnQ2EHOL bGoMcBbkSDHjw68dwNVnBfqKiBEDFUleLmIhtWM1m3DkhJ8JS6ozVvZH7Ho0zwTdC9TgZ YjZQ84rydErg1C7OltCYxgBoGW12uBNKJMiSa4wiH9Nifj6GGveaqAQOHVaIOA6t0jEp8 8OaBUK7sCXy5MBPwcMgaBIiH5kGUHgnvT97pdqhEriYrgFYrp31ORp2Iw4Jtqr72ALzRr e6etQeF8TjYBkiHcOpcP8Pjy9+qe9TcARO78UcdY+ixUYQRUAc2+sKUWhFz2RQ3N8WQ== 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=EmEGWeLS; 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 2BDE5606A321 for ; Sun, 6 Dec 2026 05:59:28 +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=EmEGWeLS Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE84D1F0093B; Sun, 6 Dec 2026 05:59:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796536768; bh=N+a0g0RKf+U+Wxq4+b9weTWQlxzXgNSENYm4Y4Mxzo0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=EmEGWeLSW04ioAp5h7CWKTM1eNrfrQ5N8RLx/+9DWm3sdESIAJBi4sUyG8Rvl0jp3 dT6HWvxzt4k9ZTnWOg0rFhnw2dK30a55D0MGrCeVQeQzzJyqrTRYekcm3GVyV0SZ2W qEFfPYF/F8zSB0il+S74kDcbD6AqoJezZZ33qyJfifAqIePJ1HdG6X5wWDsOImCtfd 7TI7pE4Ajnq2U8yzhtIilq3fda0S8GHHTblhdzavo1jNm6BiXUSrgzzCzVEmBZGTTj gYD2oQMYKOwepH9/D/4jveBiYYWgx5hdSULxBRz9aGK3Qc2cOnBDuP7IQDFqydvcOV xZ7AFIY8EoyDQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 5/6] selftests/sched_ext: Test p->scx.bpf_priv across class changes Reply-To: sashiko-reviews@lists.linux.dev To: "Changwoo Min" Cc: sched-ext@lists.linux.dev In-Reply-To: <20261206053728.2026272-6-changwoo@igalia.com> References: <20261206053728.2026272-1-changwoo@igalia.com> <20261206053728.2026272-6-changwoo@igalia.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 05:59:27 +0000 X-Mailing-List: sched-ext@lists.linux.dev 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] selftests/sched_ext: UAF dereferencing p->real_parent in is_target() -- commit 126f4c58d88ef640789b0b03da1a002cdbbc0901 Author: Changwoo Min selftests/sched_ext: Test p->scx.bpf_priv across class changes This commit adds the task_bpf_priv sched_ext selftest to verify that p->scx.bpf_priv persists across scheduling class changes, is cleared for forked children and on scheduler unload, and rejects writes to other tasks. > diff --git a/tools/testing/selftests/sched_ext/task_bpf_priv.bpf.c b/tool= s/testing/selftests/sched_ext/task_bpf_priv.bpf.c > new file mode 100644 > index 0000000000000..8dec22de52888 > --- /dev/null > +++ b/tools/testing/selftests/sched_ext/task_bpf_priv.bpf.c [ ... ] > +/* Whether @p is the test task or its child */ > +static bool is_target(struct task_struct *p) > +{ > + return p->tgid =3D=3D target_tgid || p->real_parent->tgid =3D=3D target= _tgid; > +} [Severity: Medium] Can dereferencing p->real_parent here trigger a use-after-free? Even with SCX_OPS_SWITCH_PARTIAL, sched_ext_dead() invokes ops.exit_task() for every exiting task on the system. Once release_task() unlinks an exiting task in __unhash_process(), its real_parent pointer is no longer updated by forget_original_parent(), so the parent can exit and be freed before sched_ext_dead() runs: CPU0 (exiting task B) CPU1 (parent A) do_exit() exit_notify() release_task(B) __unhash_process(B) /* unlinked; B->real_parent still points to A */ do_exit() forget_original_parent(A) /* misses unlinked B */ ... free_task(A) ... sched_ext_dead(B) task_bpf_priv_exit_task(B) is_target(B) B->real_parent->tgid <-- use-after-free Because struct task_struct::real_parent is listed in BTF_TYPE_SAFE_RCU, the verifier emits an unguarded raw load rather than BPF_PROBE_MEM, so reading from the freed task_struct triggers a KASAN slab-use-after-free or a kernel page fault if the slab page has been unmapped. Instead of dereferencing p->real_parent, task_bpf_priv_enable() could record the child's tgid when cur !=3D p && cur->tgid =3D=3D target_tgid, and is_target() could match p->tgid against target_tgid and that recorded child tgid. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261206053728.2026= 272-1-changwoo@igalia.com?part=3D5