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=1796389145; b=rzYSKMXkqQhR3vaZeZg/SoOf/67PkPxDnwvOFYPgQZxzwCPlcR2Cga7y3Yxp1Zpws1QI xXpu4QJdt1FPKFd/UPFQXiLcQVwxufSAZun4aQLB/qx0c0Oe4gSSqmZiGEezUk5Kom8kA ZsWpq393eNP6vR39B7mzlVOeCtUd67RP9g2Fn9kKkKivmMrKr7eceSG6JygXB4BEfgZQO HHSogTt+p0crxIM9KTQTFRWI3JgcGf/nptaXLL0ej1hls8jK5lLeyXyiTUMvvTwXRuT/Q /ePokM46i7ZRYKue9MXbdB+oyoSIqkx/8BecXkr3o2uUVLKEwYo+A01qWx5PIaDgszg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389145; 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=GWw7AQ4BNZ8Iu9GvlOIUsVjjJZlU2mW+jVp00Rg8A7k=; b=CGfhbCm+q3E2xB7y7j7j5hj2iRLFUZ0T5DfM8+jb7LYPWdQ3Y9rRvi2NRZQ21nXMJYwM fp0+fhX6npljaOSrmHshZ2Bp4KIdEcxFQy6RhOVh6oM3sRohsx5wcy4WGVNLq+dkoPirJ iVzHBE6IZ6plvSUSQfrceoD3wHnx4+8GFpVyBxui0YiZNY4JbiXKwp7EoW+i/ykxaq42p zr4ob7AvONpb+lTTIFWVwAqXmd1YdOSR6cYb4+fqFg5RDHmGmd5RWoJCWu0JzQa2pWxj2 SKDGN9ygaq9N1SiImM+TgoI/OqvlhKBJBG2y7xSebmwf7uB5uh+KpwO5vW8j1bV65HQ== 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=SvRZMKJ3; 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 5D198606A32C; Fri, 4 Dec 2026 12:59:05 +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=SvRZMKJ3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6D811F00A0B; Fri, 4 Dec 2026 12:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796389145; bh=GWw7AQ4BNZ8Iu9GvlOIUsVjjJZlU2mW+jVp00Rg8A7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SvRZMKJ3YkrIh/e1Lfyzuu5YVsHcu82JYUR3wnsg0heN3Irqv06XxhSw+78IrCh3G 9GAii/9DH7zuQJimqCpmFJdy6ZrFPLd08Kj9j6jBQv0Zw4DyGYahJwB+QreohXxGxf h0GIiKjPiAzNaoMCEbkXqnc4qtNo9TzLut7CRTIg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.1 0880/1059] bpf: Do not allow bpf_d_path() by an id of another BTF Date: Fri, 4 Dec 2026 19:06:51 +0900 Message-ID: <20261204100706.807325634@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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 6.1-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 5521556fedf25..2e0769b7f2fb2 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -957,6 +957,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