Skip to content

Commit 07651cc

Browse files
mykyta5anakryiko
authored andcommitted
bpf: Return prog btf_id without capable check
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
1 parent 0de445d commit 07651cc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/syscall.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4732,6 +4732,8 @@ static int bpf_prog_get_info_by_fd(struct file *file,
47324732
info.recursion_misses = stats.misses;
47334733

47344734
info.verified_insns = prog->aux->verified_insns;
4735+
if (prog->aux->btf)
4736+
info.btf_id = btf_obj_id(prog->aux->btf);
47354737

47364738
if (!bpf_capable()) {
47374739
info.jited_prog_len = 0;
@@ -4878,8 +4880,6 @@ static int bpf_prog_get_info_by_fd(struct file *file,
48784880
}
48794881
}
48804882

4881-
if (prog->aux->btf)
4882-
info.btf_id = btf_obj_id(prog->aux->btf);
48834883
info.attach_btf_id = prog->aux->attach_btf_id;
48844884
if (attach_btf)
48854885
info.attach_btf_obj_id = btf_obj_id(attach_btf);

0 commit comments

Comments
 (0)