History

bpf: Enable more helpers for BPF_PROG_TYPE_CGROUP_{DEVICE,SYSCTL,SOCKOPT}

Currently the following prog types don't fall back to bpf_base_func_proto() (instead they have cgroup_base_func_proto which has a limited set of helpers from bpf_base_func_proto): * BPF_PROG_TYPE_CGROUP_DEVICE * BPF_PROG_TYPE_CGROUP_SYSCTL * BPF_PROG_TYPE_CGROUP_SOCKOPT I don't see any specific reason why we shouldn't use bpf_base_func_proto(), every other type of program (except bpf-lirc and, understandably, tracing) use it, so let's fall back to bpf_base_func_proto for those prog types as well. This basically boils down to adding access to the following helpers: * BPF_FUNC_get_prandom_u32 * BPF_FUNC_get_smp_processor_id * BPF_FUNC_get_numa_node_id * BPF_FUNC_tail_call * BPF_FUNC_ktime_get_ns * BPF_FUNC_spin_lock (CAP_SYS_ADMIN) * BPF_FUNC_spin_unlock (CAP_SYS_ADMIN) * BPF_FUNC_jiffies64 (CAP_SYS_ADMIN) I've also added bpf_perf_event_output() because it's really handy for logging and debugging.

Stanislav Fomichev committed 6 years ago

Commit 0456ea11 parent 93e51684 files · +29 −18Browse files

Showing the changes to kernel (1 of 4 files). Show all

Unified · Split

kernel/bpf/cgroup.c+3−17
@@ -1060,30 +1060,16 @@ static const struct bpf_func_proto * · 1059 unmodified lines
10601060 cgroup_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
10611061 {
10621062 switch (func_id) {
1063− case BPF_FUNC_map_lookup_elem:
1064− return &bpf_map_lookup_elem_proto;
1065− case BPF_FUNC_map_update_elem:
1066− return &bpf_map_update_elem_proto;
1067− case BPF_FUNC_map_delete_elem:
1068− return &bpf_map_delete_elem_proto;
1069− case BPF_FUNC_map_push_elem:
1070− return &bpf_map_push_elem_proto;
1071− case BPF_FUNC_map_pop_elem:
1072− return &bpf_map_pop_elem_proto;
1073− case BPF_FUNC_map_peek_elem:
1074− return &bpf_map_peek_elem_proto;
10751063 case BPF_FUNC_get_current_uid_gid:
10761064 return &bpf_get_current_uid_gid_proto;
10771065 case BPF_FUNC_get_local_storage:
10781066 return &bpf_get_local_storage_proto;
10791067 case BPF_FUNC_get_current_cgroup_id:
10801068 return &bpf_get_current_cgroup_id_proto;
1081− case BPF_FUNC_trace_printk:
1082− if (capable(CAP_SYS_ADMIN))
1083− return bpf_get_trace_printk_proto();
1084− /* fall through */
1069+ case BPF_FUNC_perf_event_output:
1070+ return &bpf_event_output_data_proto;
10851071 default:
1086− return NULL;
1072+ return bpf_base_func_proto(func_id);
10871073 }
10881074 }
10891075

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t