Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Mykyta Yatsenko and committed by
Andrii Nakryiko
07651ccd 0de445d1

+2 -2
+2 -2
kernel/bpf/syscall.c
··· 4732 4732 info.recursion_misses = stats.misses; 4733 4733 4734 4734 info.verified_insns = prog->aux->verified_insns; 4735 + if (prog->aux->btf) 4736 + info.btf_id = btf_obj_id(prog->aux->btf); 4735 4737 4736 4738 if (!bpf_capable()) { 4737 4739 info.jited_prog_len = 0; ··· 4880 4878 } 4881 4879 } 4882 4880 4883 - if (prog->aux->btf) 4884 - info.btf_id = btf_obj_id(prog->aux->btf); 4885 4881 info.attach_btf_id = prog->aux->attach_btf_id; 4886 4882 if (attach_btf) 4887 4883 info.attach_btf_obj_id = btf_obj_id(attach_btf);