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=1796380470; b=qBZXICRkEREnh3KF1cDkt7iYRaCqm2hcNFjX4OimZc3QZHsUrZTeil7AFsXrjEsOE4gt XqOgO/8AjHnFgdH4meuYzygY3xWlvvmsogLl6E8Ja1OQk8gZ1L8alxhFEw5RKCF2kGEai oIeuK4Zgu/RSyAz0gTL5TxBSpEbIQNizh2mlsFLj9efr5Q1vjGPb8Q60o9pkk2Ge01ru3 pjRFjj2ahueCh2nis6ynwyGuh4Q1I0P2wPHNBKEVa3Mna+Ku3UmkWlABFuGnl9025ESPH ZSc27UCFkv32noP9eb/7zGaJCZsnViAsnYIJD/gyoNzssoorKREssQ88M/ii5FUf8Tw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380470; 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=itvl0kPbooYB6YlhD41/pyc1GSeoPsuKBaCRKnNnW9I=; b=s0+nPN3hVBjK1jbJ5cw+70wy+/SaT+32SCkGsc8/hUmk53yZRSIRZBjNbnCicgv0CEzj 721i23IVcJgaIYvjpHa1QxINZfu0S7t/50Z9NUTA69VX/G+JyZjTgu9829Zeq4WmHea7g Paydq90WHMuoed8d49OcsNUlhDd2NYwEP/p1AlKH4g/lEOoj/X14lzKW+J5iMDY3zkyRL +GPKeuv04pOsVK8E2eow3C+d0nsHsvxYs8bh9VOx9U0Hccx4DsHUamal8ad4OMD3ls/Fs reni/XTAgbtyW4g/ByDprK4/e9kEhT3zrN1nJhNsCZQOwPAzickBoat8AjpGgMhTYHA== 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=1uxHKI8x; 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 436B1606A681; Fri, 4 Dec 2026 10:34:30 +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=1uxHKI8x Received: by smtp.kernel.org (Postfix) with ESMTPSA id B05161F000C2; Fri, 4 Dec 2026 10:34:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380470; bh=itvl0kPbooYB6YlhD41/pyc1GSeoPsuKBaCRKnNnW9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1uxHKI8xERzOry9lyTzLvm2VfFjSgRhlCApoFFJpCGoU4LqTZhZoVjOhx/vqlioDW HYonQf1yv4Mpxlng1JRW5mm5pMz5KX2epvX24BV/IFPdQZgnWOQE82rY7mD/zoXlQ0 AZbAF/K4CuoH3BTYKHAS0cdLYCt/6rDinfQ57Slg= 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 287/742] bpf: Give syscall programs without CAP_PERFMON the base helpers only Date: Fri, 4 Dec 2026 19:02:31 +0900 Message-ID: <20261204100642.668207583@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: stable@vger.kernel.org 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 2ff55b023f637d61a56a893b0a3eb534acfb2ffd ] A syscall program needs CAP_BPF only, and it gets all helpers of tracing programs. These don't ask for CAP_PERFMON, the load of a tracing program does. The helpers for loader programs take current for the loader. It's another task in a callback. bpf_kallsyms_lookup_name() answers in a callback of bpf_wq, as a kworker has all capabilities. bpf_sys_close() in a task work closes a file of any process. Give the program the base helpers. It loses bpf_perf_event_output() too. Loader programs are not affected, bpf_sys_bpf() needs CAP_PERFMON already. Fixes: 79a7f8bdb159 ("bpf: Introduce bpf_sys_bpf() helper and program type.") Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261125032938.670542-26-alexei.starovoitov@gmail.com Signed-off-by: Sasha Levin --- kernel/bpf/syscall.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 152191a6de5b2..ecf4f30b0ad92 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -6698,10 +6698,12 @@ static const struct bpf_func_proto bpf_kallsyms_lookup_name_proto = { static const struct bpf_func_proto * syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) { + if (!bpf_token_capable(prog->aux->token, CAP_PERFMON)) + return bpf_base_func_proto(func_id, prog); + switch (func_id) { case BPF_FUNC_sys_bpf: - return !bpf_token_capable(prog->aux->token, CAP_PERFMON) - ? NULL : &bpf_sys_bpf_proto; + return &bpf_sys_bpf_proto; case BPF_FUNC_btf_find_by_name_kind: return &bpf_btf_find_by_name_kind_proto; case BPF_FUNC_sys_close: -- 2.53.0