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=1796398618; b=MDsXYa2Bh7RGy/e3dPpYN5FVzDfWqB7ekLN9pECz5h6PdHDNZhEC+pmC1qyUV4tb/8Ru TquYaldxl1rChMCA2Nyk3GZeoKrKumZG3fbzhxBOmufSXYWwW8FNCvUjKyx0ccqzcnLA6 useEj6Rmv/Z4xiPNBcc5PuuzBR867mSxkCQNAcMi4w6bZYFN64ae4WImRAH7c6cnqZe6L CwQPvRhIeFiDe1+24SToIErsTjzoCDHg8Ify8rLkDOWKnm0inv9B3YcHaeFtZKheWfaw/ ey0g7OzYHQvfqPUlc7mbsDI+Xb7R9hI4OHjCB5ZNtkJDmtS1vXCqegDw4pb4nF3UlSA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796398618; h=Received:DKIM-Signature:Received:Received:X-ME-Sender: X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID:Received:X-Mailer: MIME-Version:X-ThreadId:Date:From:To:Cc:Message-Id:In-Reply-To: References:Subject:Content-Type:Content-Transfer-Encoding; bh=k85bk5xkY//2PzDIknD/7d2ZP0GtUO5ithjnoaHpjw0=; b=VCtWfrKBo9YRKHrEnoqIF9az5ew403PRRk1qiN5xJrOupDz9G/dQMDsep7LKi9HZGkn1 srY0xj5AX+xr/Vu0SS4jQLWIpgD2ff9gWUVegS4PkE85/guhpgHXZ6crssAcjYtBZloIX HoHGuciI7LG+m0BKa1TpCByPgJRkLlXVYrKWZrJySBCfuHolq/HFIaZDh0+emy6t8+w7P tvkJ4nvHd7Cy0rf03dpdJSF+QO+dyqmKKa8YYXr5Nrao0B+2iaaepkU0k+vOOOJF8PAPt 84piO8OFAMhaB0P91EaJYOKJTMDMQXKAGIBVdScJ8qW9B3mKNOe5WBbnbCNvilbgMYg== 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=UGRi1L3g; 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 188DD606A32C; Fri, 4 Dec 2026 15:36:57 +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=UGRi1L3g Received: by smtp.kernel.org (Postfix) with ESMTPSA id 273DE1F000CE; Fri, 4 Dec 2026 15:36:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796398617; bh=k85bk5xkY//2PzDIknD/7d2ZP0GtUO5ithjnoaHpjw0=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=UGRi1L3gTsfVcA7spZMyBcVxL+Up/UOZ2Gk9ldBxFxv2nAeAG+v1m3yi8he1ADEDy /Nf1oBWd+G6Porew+KjrSCYcmWY0Aia3NXK3VTdrEundzaKG8s7k0ESfbFsOUGnWDM iDF3XvG59rBJumW70t1MYTXpZKyaKFyJnVu1WbrV7YkDwn+36+6FKjWO1OtaqF905t Xscpdw1R8GC7rnphN9gPN7Uz/A9764O1UUnuhAA+p9jStr/XVzkE7Fy6J2VeS9ecBf PkVlXdvtzTPlI2IthTkgbt1yCGeHZkAU4OtJJ02UCahdJW4kThNURr8EG8tO/MuTPJ cniAm/WY487pA== Received: from stl-compute-04.internal (stl-compute-04.internal [10.204.2.64]) by mailfauth.stl.internal (Postfix) with ESMTP id 9D39F780043; Fri, 4 Dec 2026 10:36:56 -0500 (EST) Received: from stl-imap-13 ([10.204.2.104]) by stl-compute-04.internal (MEProxy); Fri, 04 Dec 2026 10:36:56 -0500 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTGQ6OVTl6MTTP3e0R88tWtMLt/uq1duEs/yPwOhLkGeL3Yn6XH9JAAeDASaHGcLeL UBEDGI++d5D3coAitNI2Wp8pVTemODKcYxtxpFJA6FjN8zNSS7kIs9bmur5UNdX1GPLGVS nnURdFzeBJ8XthnPB3xQBgp0bBfF9g8UA5QFVOBgFxM91yf6VdjQdTiFFf6YZ/ff8068cW yoxNlI9Nm1tA/xF7yx268DCbbZN/HHHXid66GoPMsgZwXA8cZV28YLITunackLZoqhCDUZ GrVtqiP32TNPAmS/cHofyd+FQXiLee2wxF88B63+REEVfEObMoRAa8dnzSRxqvep8Q7cQY trJW64YTLecsy3SkIlz+QK6IZBFuZeneA4gfjTX043ysMYYmaaoc+OPDVN9Ynh+HbQ89Zx BhZnf28/53yRJ0/6fGQ0xZCpeuo8rZ88XgBD5Bx9BJ0hmBx4lCLkwdn7M5wX6D8z2opAMC yp5BdAALps/iAfGudYHF+sVKGcyiycpI+ya8a5JcaVc+KCaSSKUE4icFK74U+Mq0NWjqRS ZOTJVunI/lA1vPsVR5FfnCAkHvC0Eg7b7/oxxwIPDIrnTmyjFik5yRyOw6fWM9AJQcW4hk vTb1UHzQ6LLLrlNtaQMw8CczawAy77UIuU2cmImbe5Y5q81YEizvGNM09tIg X-ME-Proxy: Feedback-ID: iccae4b50:Fastmail Received: by mailuser.stl.internal (Postfix, from userid 501) id 58B21F60088; Fri, 4 Dec 2026 10:36:56 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-ThreadId: AE_VKM6hn_FN Date: Fri, 04 Dec 2026 10:36:36 -0500 From: "Chris Mason" To: "Alexei Starovoitov" 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 Message-Id: <1796379632.2.26376.0@kernel.org> In-Reply-To: References: <20261203200612.26376-1-mason@kernel.org> Subject: Re: [PATCH 0/3] fork, exit: fix BPF use-after-frees on task pointers Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, 04 Dec 2026 02:36:25 +0000, Alexei Starovoitov wrote: > On Thu, Dec 03, 2026 at 12:06 PM Chris Mason 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