Skip to content

Commit 8addbfc

Browse files
kkdwivediAlexei Starovoitov
authored andcommitted
bpf: Gate dynptr API behind CAP_BPF
This has been enabled for unprivileged programs for only one kernel release, hence the expected annoyances due to this move are low. Users using ringbuf can stick to non-dynptr APIs. The actual use cases dynptr is meant to serve may not make sense in unprivileged BPF programs. Hence, gate these helpers behind CAP_BPF and limit use to privileged BPF programs. Fixes: 263ae15 ("bpf: Add bpf_dynptr_from_mem for local dynptrs") Fixes: bc34dee ("bpf: Dynptr support for ring buffers") Fixes: 13bbbfb ("bpf: Add bpf_dynptr_read and bpf_dynptr_write") Fixes: 34d4ef5 ("bpf: Add dynptr data slices") Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20220921143550.30247-1-memxor@gmail.com Acked-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent d703256 commit 8addbfc

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

kernel/bpf/helpers.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,26 +1627,12 @@ bpf_base_func_proto(enum bpf_func_id func_id)
16271627
return &bpf_ringbuf_discard_proto;
16281628
case BPF_FUNC_ringbuf_query:
16291629
return &bpf_ringbuf_query_proto;
1630-
case BPF_FUNC_ringbuf_reserve_dynptr:
1631-
return &bpf_ringbuf_reserve_dynptr_proto;
1632-
case BPF_FUNC_ringbuf_submit_dynptr:
1633-
return &bpf_ringbuf_submit_dynptr_proto;
1634-
case BPF_FUNC_ringbuf_discard_dynptr:
1635-
return &bpf_ringbuf_discard_dynptr_proto;
16361630
case BPF_FUNC_for_each_map_elem:
16371631
return &bpf_for_each_map_elem_proto;
16381632
case BPF_FUNC_loop:
16391633
return &bpf_loop_proto;
16401634
case BPF_FUNC_strncmp:
16411635
return &bpf_strncmp_proto;
1642-
case BPF_FUNC_dynptr_from_mem:
1643-
return &bpf_dynptr_from_mem_proto;
1644-
case BPF_FUNC_dynptr_read:
1645-
return &bpf_dynptr_read_proto;
1646-
case BPF_FUNC_dynptr_write:
1647-
return &bpf_dynptr_write_proto;
1648-
case BPF_FUNC_dynptr_data:
1649-
return &bpf_dynptr_data_proto;
16501636
default:
16511637
break;
16521638
}
@@ -1675,6 +1661,20 @@ bpf_base_func_proto(enum bpf_func_id func_id)
16751661
return &bpf_timer_cancel_proto;
16761662
case BPF_FUNC_kptr_xchg:
16771663
return &bpf_kptr_xchg_proto;
1664+
case BPF_FUNC_ringbuf_reserve_dynptr:
1665+
return &bpf_ringbuf_reserve_dynptr_proto;
1666+
case BPF_FUNC_ringbuf_submit_dynptr:
1667+
return &bpf_ringbuf_submit_dynptr_proto;
1668+
case BPF_FUNC_ringbuf_discard_dynptr:
1669+
return &bpf_ringbuf_discard_dynptr_proto;
1670+
case BPF_FUNC_dynptr_from_mem:
1671+
return &bpf_dynptr_from_mem_proto;
1672+
case BPF_FUNC_dynptr_read:
1673+
return &bpf_dynptr_read_proto;
1674+
case BPF_FUNC_dynptr_write:
1675+
return &bpf_dynptr_write_proto;
1676+
case BPF_FUNC_dynptr_data:
1677+
return &bpf_dynptr_data_proto;
16781678
default:
16791679
break;
16801680
}

0 commit comments

Comments
 (0)