]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpf: Return prog btf_id without capable check
authorMykyta Yatsenko <yatsenko@meta.com>
Mon, 17 Mar 2025 17:40:37 +0000 (17:40 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:12:39 +0000 (11:12 +0200)
[ Upstream commit 07651ccda9ff10a8ca427670cdd06ce2c8e4269c ]

Return prog's btf_id from bpf_prog_get_info_by_fd regardless of capable
check. This patch enables scenario, when freplace program, running
from user namespace, requires to query target prog's btf.

Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20250317174039.161275-3-mykyta.yatsenko5@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/syscall.c

index 1c2caae0d894602afa7b221330f9fa6c6585c6b1..87f886ed33bc3daaf5cd5ec33bcd7c868a74d231 100644 (file)
@@ -4733,6 +4733,8 @@ static int bpf_prog_get_info_by_fd(struct file *file,
        info.recursion_misses = stats.misses;
 
        info.verified_insns = prog->aux->verified_insns;
+       if (prog->aux->btf)
+               info.btf_id = btf_obj_id(prog->aux->btf);
 
        if (!bpf_capable()) {
                info.jited_prog_len = 0;
@@ -4879,8 +4881,6 @@ static int bpf_prog_get_info_by_fd(struct file *file,
                }
        }
 
-       if (prog->aux->btf)
-               info.btf_id = btf_obj_id(prog->aux->btf);
        info.attach_btf_id = prog->aux->attach_btf_id;
        if (attach_btf)
                info.attach_btf_obj_id = btf_obj_id(attach_btf);