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=1796380522; b=Fexmpg9ne4yusefRbIcoqNuvGNC6URjNtdkP5IAnjjXpIEF5gYF7YcQrlK5JtQ596fxL hKkSSaf+L8tgC/hQ+K1rwlOaeT2gEZwB6bMBJFCSkSnNJFxilfYT/W06khwDfqahp1rxq 7DH9WR8gUuCA1ZVGcn/6yluAgPUJu0PQWPjjufECeM434+C3Vuy7+0mTV0sMvWjnlIbPe K+gbUJaKwtjQCBT28mbdhAPqsgYWORYSPbIxvHl1lG2PLkIKDXBCp++WPKD24XhXYCOXz EIDfC2Lz9lM424P4/nztlyRAW/ntNTF6uKAFEb7rmTWILURTj5hBWCgtRKCVvPMSZtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380522; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=M0TP/a7WhK3rqxeyOz3pw5CGDaeph6cKIA+VbqaviaM=; b=3eOt/vqif4XhSUGpQrSepOe77dRaKLKrG7zokvp3Js2cbrMs5jnx1sQVq49PHFh98us/ NKtrYjNMs1d4Jd2KesBh69Te/RHKKEvcBTlKkcONtKBn2qLcqhUBGMx/1fi6eiTQ2H73N YXuNuhGQX4Kavtcey2vM2R05AFaE0rWCANtilIgw6Faot9ixp8BRaS/2bjQ/n2vC003h+ DhNt4OtkjggF4pjYkEgoQBfsfBCn4zS80Kc54qymRhqLla8s0krWR6DORZRL0mcueJ+2F 3cd1gPqUISZK4je7+M0uoZSpfcw6iKJH8aD0fOB4QT6ZKfh7mO07yv/x7A1mXSSm1KQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OZybZl3q; 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 A7C0E606A33E; Fri, 4 Dec 2026 10:35:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=OZybZl3q Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21DBB1F000CE; Fri, 4 Dec 2026 10:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380522; bh=M0TP/a7WhK3rqxeyOz3pw5CGDaeph6cKIA+VbqaviaM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OZybZl3q3GU/eF2E+xxshtF2LAFc21n2ceauikNLD65zSNE/KI6eacbL7xgPRida9 QVrCub4oMduIczJr2NMkHSUYf82jSZekPk2Mq4h0rc0BaPpIJZ/baZWHP5mu6sB0HZ 2kN/4DRb4TVxmZjdQBpyQ/+6MSI7GPDV5jn4DjCc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 7.3 269/742] bpf: Do not allow bpf_d_path() by an id of another BTF Date: Fri, 4 Dec 2026 19:02:13 +0900 Message-ID: <20261204100642.203302581@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexei Starovoitov [ Upstream commit 1139c7d8ffcd941d4860a75ef37eb1ffd15b4f87 ] For a program that is attached to a program attach_btf_id is an id in the BTF of the target. bpf_d_path_allowed() looks for it in a list of kernel functions, it can match by chance. Do not look at the list when there is a target program. Fixes: 6e22ab9da793 ("bpf: Add d_path helper") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261125032938.670542-5-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- kernel/trace/bpf_trace.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 08ddadd80056c..74ee56cb068f2 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -976,6 +976,10 @@ BTF_SET_END(btf_allowlist_d_path) static bool bpf_d_path_allowed(const struct bpf_prog *prog) { + /* attach_btf_id is a function of the target program */ + if (prog->aux->dst_prog) + return false; + if (prog->type == BPF_PROG_TYPE_TRACING && prog->expected_attach_type == BPF_TRACE_ITER) return true; -- 2.53.0