aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2017-02-16 16:24:48 -0500
committerDavid S. Miller <davem@davemloft.net>2017-02-17 13:40:04 -0500
commitc78f8bdfa11fcceb9723c61212e4bd8f76c87f9e (patch)
tree456eca6a892aea9e8cd9fec3b9ca6b380112d7b2
parentafcb50ba7f745eea32f91d7f63d6aa88f929f9c4 (diff)
bpf: mark all registered map/prog types as __ro_after_init
All map types and prog types are registered to the BPF core through bpf_register_map_type() and bpf_register_prog_type() during init and remain unchanged thereafter. As by design we don't (and never will) have any pluggable code that can register to that at any later point in time, lets mark all the existing bpf_{map,prog}_type_list objects in the tree as __ro_after_init, so they can be moved to read-only section from then onwards. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--kernel/bpf/arraymap.c10
-rw-r--r--kernel/bpf/hashtab.c8
-rw-r--r--kernel/bpf/lpm_trie.c2
-rw-r--r--kernel/bpf/stackmap.c2
-rw-r--r--kernel/trace/bpf_trace.c6
-rw-r--r--net/core/filter.c18
6 files changed, 23 insertions, 23 deletions
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 3d55d95dcf49..6b6f41f0b211 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -269,7 +269,7 @@ static const struct bpf_map_ops array_ops = {
269 .map_delete_elem = array_map_delete_elem, 269 .map_delete_elem = array_map_delete_elem,
270}; 270};
271 271
272static struct bpf_map_type_list array_type __read_mostly = { 272static struct bpf_map_type_list array_type __ro_after_init = {
273 .ops = &array_ops, 273 .ops = &array_ops,
274 .type = BPF_MAP_TYPE_ARRAY, 274 .type = BPF_MAP_TYPE_ARRAY,
275}; 275};
@@ -283,7 +283,7 @@ static const struct bpf_map_ops percpu_array_ops = {
283 .map_delete_elem = array_map_delete_elem, 283 .map_delete_elem = array_map_delete_elem,
284}; 284};
285 285
286static struct bpf_map_type_list percpu_array_type __read_mostly = { 286static struct bpf_map_type_list percpu_array_type __ro_after_init = {
287 .ops = &percpu_array_ops, 287 .ops = &percpu_array_ops,
288 .type = BPF_MAP_TYPE_PERCPU_ARRAY, 288 .type = BPF_MAP_TYPE_PERCPU_ARRAY,
289}; 289};
@@ -409,7 +409,7 @@ static const struct bpf_map_ops prog_array_ops = {
409 .map_fd_put_ptr = prog_fd_array_put_ptr, 409 .map_fd_put_ptr = prog_fd_array_put_ptr,
410}; 410};
411 411
412static struct bpf_map_type_list prog_array_type __read_mostly = { 412static struct bpf_map_type_list prog_array_type __ro_after_init = {
413 .ops = &prog_array_ops, 413 .ops = &prog_array_ops,
414 .type = BPF_MAP_TYPE_PROG_ARRAY, 414 .type = BPF_MAP_TYPE_PROG_ARRAY,
415}; 415};
@@ -522,7 +522,7 @@ static const struct bpf_map_ops perf_event_array_ops = {
522 .map_release = perf_event_fd_array_release, 522 .map_release = perf_event_fd_array_release,
523}; 523};
524 524
525static struct bpf_map_type_list perf_event_array_type __read_mostly = { 525static struct bpf_map_type_list perf_event_array_type __ro_after_init = {
526 .ops = &perf_event_array_ops, 526 .ops = &perf_event_array_ops,
527 .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, 527 .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
528}; 528};
@@ -564,7 +564,7 @@ static const struct bpf_map_ops cgroup_array_ops = {
564 .map_fd_put_ptr = cgroup_fd_array_put_ptr, 564 .map_fd_put_ptr = cgroup_fd_array_put_ptr,
565}; 565};
566 566
567static struct bpf_map_type_list cgroup_array_type __read_mostly = { 567static struct bpf_map_type_list cgroup_array_type __ro_after_init = {
568 .ops = &cgroup_array_ops, 568 .ops = &cgroup_array_ops,
569 .type = BPF_MAP_TYPE_CGROUP_ARRAY, 569 .type = BPF_MAP_TYPE_CGROUP_ARRAY,
570}; 570};
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index a753bbe7df0a..3ea87fb19a94 100644
--- a/kernel/bpf/hashtab.c
+++ b/kernel/bpf/hashtab.c
@@ -1023,7 +1023,7 @@ static const struct bpf_map_ops htab_ops = {
1023 .map_delete_elem = htab_map_delete_elem, 1023 .map_delete_elem = htab_map_delete_elem,
1024}; 1024};
1025 1025
1026static struct bpf_map_type_list htab_type __read_mostly = { 1026static struct bpf_map_type_list htab_type __ro_after_init = {
1027 .ops = &htab_ops, 1027 .ops = &htab_ops,
1028 .type = BPF_MAP_TYPE_HASH, 1028 .type = BPF_MAP_TYPE_HASH,
1029}; 1029};
@@ -1037,7 +1037,7 @@ static const struct bpf_map_ops htab_lru_ops = {
1037 .map_delete_elem = htab_lru_map_delete_elem, 1037 .map_delete_elem = htab_lru_map_delete_elem,
1038}; 1038};
1039 1039
1040static struct bpf_map_type_list htab_lru_type __read_mostly = { 1040static struct bpf_map_type_list htab_lru_type __ro_after_init = {
1041 .ops = &htab_lru_ops, 1041 .ops = &htab_lru_ops,
1042 .type = BPF_MAP_TYPE_LRU_HASH, 1042 .type = BPF_MAP_TYPE_LRU_HASH,
1043}; 1043};
@@ -1124,7 +1124,7 @@ static const struct bpf_map_ops htab_percpu_ops = {
1124 .map_delete_elem = htab_map_delete_elem, 1124 .map_delete_elem = htab_map_delete_elem,
1125}; 1125};
1126 1126
1127static struct bpf_map_type_list htab_percpu_type __read_mostly = { 1127static struct bpf_map_type_list htab_percpu_type __ro_after_init = {
1128 .ops = &htab_percpu_ops, 1128 .ops = &htab_percpu_ops,
1129 .type = BPF_MAP_TYPE_PERCPU_HASH, 1129 .type = BPF_MAP_TYPE_PERCPU_HASH,
1130}; 1130};
@@ -1138,7 +1138,7 @@ static const struct bpf_map_ops htab_lru_percpu_ops = {
1138 .map_delete_elem = htab_lru_map_delete_elem, 1138 .map_delete_elem = htab_lru_map_delete_elem,
1139}; 1139};
1140 1140
1141static struct bpf_map_type_list htab_lru_percpu_type __read_mostly = { 1141static struct bpf_map_type_list htab_lru_percpu_type __ro_after_init = {
1142 .ops = &htab_lru_percpu_ops, 1142 .ops = &htab_lru_percpu_ops,
1143 .type = BPF_MAP_TYPE_LRU_PERCPU_HASH, 1143 .type = BPF_MAP_TYPE_LRU_PERCPU_HASH,
1144}; 1144};
diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c
index e0f6a0bd279b..8bfe0afaee10 100644
--- a/kernel/bpf/lpm_trie.c
+++ b/kernel/bpf/lpm_trie.c
@@ -508,7 +508,7 @@ static const struct bpf_map_ops trie_ops = {
508 .map_delete_elem = trie_delete_elem, 508 .map_delete_elem = trie_delete_elem,
509}; 509};
510 510
511static struct bpf_map_type_list trie_type __read_mostly = { 511static struct bpf_map_type_list trie_type __ro_after_init = {
512 .ops = &trie_ops, 512 .ops = &trie_ops,
513 .type = BPF_MAP_TYPE_LPM_TRIE, 513 .type = BPF_MAP_TYPE_LPM_TRIE,
514}; 514};
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index be8519148c25..22aa45cd0324 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -273,7 +273,7 @@ static const struct bpf_map_ops stack_map_ops = {
273 .map_delete_elem = stack_map_delete_elem, 273 .map_delete_elem = stack_map_delete_elem,
274}; 274};
275 275
276static struct bpf_map_type_list stack_map_type __read_mostly = { 276static struct bpf_map_type_list stack_map_type __ro_after_init = {
277 .ops = &stack_map_ops, 277 .ops = &stack_map_ops,
278 .type = BPF_MAP_TYPE_STACK_TRACE, 278 .type = BPF_MAP_TYPE_STACK_TRACE,
279}; 279};
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 424daa4586d1..cee9802cf3e0 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -506,7 +506,7 @@ static const struct bpf_verifier_ops kprobe_prog_ops = {
506 .is_valid_access = kprobe_prog_is_valid_access, 506 .is_valid_access = kprobe_prog_is_valid_access,
507}; 507};
508 508
509static struct bpf_prog_type_list kprobe_tl = { 509static struct bpf_prog_type_list kprobe_tl __ro_after_init = {
510 .ops = &kprobe_prog_ops, 510 .ops = &kprobe_prog_ops,
511 .type = BPF_PROG_TYPE_KPROBE, 511 .type = BPF_PROG_TYPE_KPROBE,
512}; 512};
@@ -589,7 +589,7 @@ static const struct bpf_verifier_ops tracepoint_prog_ops = {
589 .is_valid_access = tp_prog_is_valid_access, 589 .is_valid_access = tp_prog_is_valid_access,
590}; 590};
591 591
592static struct bpf_prog_type_list tracepoint_tl = { 592static struct bpf_prog_type_list tracepoint_tl __ro_after_init = {
593 .ops = &tracepoint_prog_ops, 593 .ops = &tracepoint_prog_ops,
594 .type = BPF_PROG_TYPE_TRACEPOINT, 594 .type = BPF_PROG_TYPE_TRACEPOINT,
595}; 595};
@@ -648,7 +648,7 @@ static const struct bpf_verifier_ops perf_event_prog_ops = {
648 .convert_ctx_access = pe_prog_convert_ctx_access, 648 .convert_ctx_access = pe_prog_convert_ctx_access,
649}; 649};
650 650
651static struct bpf_prog_type_list perf_event_tl = { 651static struct bpf_prog_type_list perf_event_tl __ro_after_init = {
652 .ops = &perf_event_prog_ops, 652 .ops = &perf_event_prog_ops,
653 .type = BPF_PROG_TYPE_PERF_EVENT, 653 .type = BPF_PROG_TYPE_PERF_EVENT,
654}; 654};
diff --git a/net/core/filter.c b/net/core/filter.c
index 0b753cbb2536..e466e0040137 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3296,47 +3296,47 @@ static const struct bpf_verifier_ops cg_sock_ops = {
3296 .convert_ctx_access = sock_filter_convert_ctx_access, 3296 .convert_ctx_access = sock_filter_convert_ctx_access,
3297}; 3297};
3298 3298
3299static struct bpf_prog_type_list sk_filter_type __read_mostly = { 3299static struct bpf_prog_type_list sk_filter_type __ro_after_init = {
3300 .ops = &sk_filter_ops, 3300 .ops = &sk_filter_ops,
3301 .type = BPF_PROG_TYPE_SOCKET_FILTER, 3301 .type = BPF_PROG_TYPE_SOCKET_FILTER,
3302}; 3302};
3303 3303
3304static struct bpf_prog_type_list sched_cls_type __read_mostly = { 3304static struct bpf_prog_type_list sched_cls_type __ro_after_init = {
3305 .ops = &tc_cls_act_ops, 3305 .ops = &tc_cls_act_ops,
3306 .type = BPF_PROG_TYPE_SCHED_CLS, 3306 .type = BPF_PROG_TYPE_SCHED_CLS,
3307}; 3307};
3308 3308
3309static struct bpf_prog_type_list sched_act_type __read_mostly = { 3309static struct bpf_prog_type_list sched_act_type __ro_after_init = {
3310 .ops = &tc_cls_act_ops, 3310 .ops = &tc_cls_act_ops,
3311 .type = BPF_PROG_TYPE_SCHED_ACT, 3311 .type = BPF_PROG_TYPE_SCHED_ACT,
3312}; 3312};
3313 3313
3314static struct bpf_prog_type_list xdp_type __read_mostly = { 3314static struct bpf_prog_type_list xdp_type __ro_after_init = {
3315 .ops = &xdp_ops, 3315 .ops = &xdp_ops,
3316 .type = BPF_PROG_TYPE_XDP, 3316 .type = BPF_PROG_TYPE_XDP,
3317}; 3317};
3318 3318
3319static struct bpf_prog_type_list cg_skb_type __read_mostly = { 3319static struct bpf_prog_type_list cg_skb_type __ro_after_init = {
3320 .ops = &cg_skb_ops, 3320 .ops = &cg_skb_ops,
3321 .type = BPF_PROG_TYPE_CGROUP_SKB, 3321 .type = BPF_PROG_TYPE_CGROUP_SKB,
3322}; 3322};
3323 3323
3324static struct bpf_prog_type_list lwt_in_type __read_mostly = { 3324static struct bpf_prog_type_list lwt_in_type __ro_after_init = {
3325 .ops = &lwt_inout_ops, 3325 .ops = &lwt_inout_ops,
3326 .type = BPF_PROG_TYPE_LWT_IN, 3326 .type = BPF_PROG_TYPE_LWT_IN,
3327}; 3327};
3328 3328
3329static struct bpf_prog_type_list lwt_out_type __read_mostly = { 3329static struct bpf_prog_type_list lwt_out_type __ro_after_init = {
3330 .ops = &lwt_inout_ops, 3330 .ops = &lwt_inout_ops,
3331 .type = BPF_PROG_TYPE_LWT_OUT, 3331 .type = BPF_PROG_TYPE_LWT_OUT,
3332}; 3332};
3333 3333
3334static struct bpf_prog_type_list lwt_xmit_type __read_mostly = { 3334static struct bpf_prog_type_list lwt_xmit_type __ro_after_init = {
3335 .ops = &lwt_xmit_ops, 3335 .ops = &lwt_xmit_ops,
3336 .type = BPF_PROG_TYPE_LWT_XMIT, 3336 .type = BPF_PROG_TYPE_LWT_XMIT,
3337}; 3337};
3338 3338
3339static struct bpf_prog_type_list cg_sock_type __read_mostly = { 3339static struct bpf_prog_type_list cg_sock_type __ro_after_init = {
3340 .ops = &cg_sock_ops, 3340 .ops = &cg_sock_ops,
3341 .type = BPF_PROG_TYPE_CGROUP_SOCK 3341 .type = BPF_PROG_TYPE_CGROUP_SOCK
3342}; 3342};