Skip to content

Commit 1c51847

Browse files
zhuyifei1999gregkh
authored andcommitted
bpf: Restrict bpf_sys_bpf to CAP_PERFMON
[ Upstream commit 14b20b7 ] The verifier cannot perform sufficient validation of any pointers passed into bpf_attr and treats them as integers rather than pointers. The helper will then read from arbitrary pointers passed into it. Restrict the helper to CAP_PERFMON since the security model in BPF of arbitrary kernel read is CAP_BPF + CAP_PERFMON. Fixes: af2ac3e ("bpf: Prepare bpf syscall to be used from kernel and user space.") Signed-off-by: YiFei Zhu <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent de22cba commit 1c51847

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/syscall.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4785,7 +4785,7 @@ syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
47854785
{
47864786
switch (func_id) {
47874787
case BPF_FUNC_sys_bpf:
4788-
return &bpf_sys_bpf_proto;
4788+
return !perfmon_capable() ? NULL : &bpf_sys_bpf_proto;
47894789
case BPF_FUNC_btf_find_by_name_kind:
47904790
return &bpf_btf_find_by_name_kind_proto;
47914791
case BPF_FUNC_sys_close:

0 commit comments

Comments
 (0)