Skip to content

Commit 14b20b7

Browse files
zhuyifei1999borkmann
authored andcommitted
bpf: Restrict bpf_sys_bpf to CAP_PERFMON
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]
1 parent 3024d95 commit 14b20b7

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
@@ -5197,7 +5197,7 @@ syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
51975197
{
51985198
switch (func_id) {
51995199
case BPF_FUNC_sys_bpf:
5200-
return &bpf_sys_bpf_proto;
5200+
return !perfmon_capable() ? NULL : &bpf_sys_bpf_proto;
52015201
case BPF_FUNC_btf_find_by_name_kind:
52025202
return &bpf_btf_find_by_name_kind_proto;
52035203
case BPF_FUNC_sys_close:

0 commit comments

Comments
 (0)