From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4A943B52FB for ; Tue, 11 Aug 2026 02:55:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786416947; cv=none; b=UcLSywjj+N894xaaok8/air1RIm3jMHsN7G10Sec0n01Dp1ShmrjRsY1+/I5y7yHn5gZwZdEqYRptyzLkL8elXHoYIVbSe0xswcePIHD9NFCV4Q+3kmXuxhLHx5w63vN1fatxkyyhmhtUZuzwZuvPxHlr+drugtqGOknNpRoYMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786416947; c=relaxed/simple; bh=sLCRk6/uSism7PBL6YsWZlfNGp+Bcx2uJV7GEoytOEc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=fsl6a8EtRXFD0obYwGBC4UlwEHAe4PGuhXq83dDkvG3GMAA361foRexj9Ay7/jF060lJsuIdyEQlzUhFGrAGRGSadGETPYpNZ+jh3Tu2wAyjAVwQKqHtDAwprfrme5E5FEWOtr/E67VaZVGsHYQ7s05cK2+ZT+tAIFVUaqQdDaY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=i9ygx0rk; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="i9ygx0rk" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786416942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=aG3L4pZ1FR2dyN32epn3qJmKPYriOUXFnmtM/oEMKSA=; b=i9ygx0rkJo4eCEAnOxTzVmUSkuqJDS99pecALEmRr3rW8AGgGXtL2Lk9NZj8Melp02i6qd MJYuMQXxfKtQCqsUqvj63xc8F2oHueS5wKKs6D9Rju5VAXSxkph/cvXNjB9JorVsOXGKWQ /fTmlfJfx9MvAUdDbLfN5dgvOZeQNpw= From: "Hui Zhu" To: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , KP Singh , Matt Bobrowski , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: Hui Zhu Subject: [PATCH bpf-next v5 0/2] bpf: Fix trampoline image UAF on multi detach failure Date: Tue, 11 Aug 2026 10:46:18 +0800 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT From: Hui Zhu This series fixes a UAF in bpf_trampoline_multi_attach_free() where old_image is freed while ftrace still calls into it, and makes bpf_trampoline_multi_detach() return void as suggested by Jiri Olsa. Patch 1 fixes the UAF. Patch 2 is an independent cleanup that changes the return type to void and drops the WARN_ON_ONCE at the call site. Changelog: v5: According to the comments of bot+bpf-ci, split the single patch into two: the bug fix and the return-type cleanup. v4: According to the comments of bot+bpf-ci, add Fixes: and update comments of bpf_trampoline_multi_attach_free. v3: According to the comments of Jiri Olsa, drop patches 2/3 and the prog-side machinery. keep only the simplified image-side fix in bpf_trampoline_multi_attach_free() and make bpf_trampoline_multi_detach() return void. v2: Folded v1's two detach patches into patch 1. According to the comments of Jiri Olsa, Pin the prog (pinned_prog) on cur_image so it stays alive while ftrace may still call into it. Make bpf_trampoline_multi_detach() return void. Fix the same UAF in standard (non-multi) trampolines. According to the comments of sashiko, Fix the prog UAF in bpf_trampoline_multi_attach() rollback. Leak the trampoline in bpf_trampoline_put() when cur_image is left by a rollback. Hui Zhu (2): bpf: Fix UAF in bpf_trampoline_multi_attach_free on update failure bpf: Make bpf_trampoline_multi_detach return void include/linux/bpf.h | 9 ++++----- kernel/bpf/trampoline.c | 16 +++++++++++++--- kernel/trace/bpf_trace.c | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) -- 2.53.0