aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/syscall.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r--kernel/bpf/syscall.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index bbb016adbaeb..f74ca17af64a 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -10,6 +10,7 @@
10 * General Public License for more details. 10 * General Public License for more details.
11 */ 11 */
12#include <linux/bpf.h> 12#include <linux/bpf.h>
13#include <linux/bpf_trace.h>
13#include <linux/syscalls.h> 14#include <linux/syscalls.h>
14#include <linux/slab.h> 15#include <linux/slab.h>
15#include <linux/vmalloc.h> 16#include <linux/vmalloc.h>
@@ -241,6 +242,7 @@ static int map_create(union bpf_attr *attr)
241 /* failed to allocate fd */ 242 /* failed to allocate fd */
242 goto free_map; 243 goto free_map;
243 244
245 trace_bpf_map_create(map, err);
244 return err; 246 return err;
245 247
246free_map: 248free_map:
@@ -365,6 +367,7 @@ static int map_lookup_elem(union bpf_attr *attr)
365 if (copy_to_user(uvalue, value, value_size) != 0) 367 if (copy_to_user(uvalue, value, value_size) != 0)
366 goto free_value; 368 goto free_value;
367 369
370 trace_bpf_map_lookup_elem(map, ufd, key, value);
368 err = 0; 371 err = 0;
369 372
370free_value: 373free_value:
@@ -447,6 +450,8 @@ static int map_update_elem(union bpf_attr *attr)
447 __this_cpu_dec(bpf_prog_active); 450 __this_cpu_dec(bpf_prog_active);
448 preempt_enable(); 451 preempt_enable();
449 452
453 if (!err)
454 trace_bpf_map_update_elem(map, ufd, key, value);
450free_value: 455free_value:
451 kfree(value); 456 kfree(value);
452free_key: 457free_key:
@@ -492,6 +497,8 @@ static int map_delete_elem(union bpf_attr *attr)
492 __this_cpu_dec(bpf_prog_active); 497 __this_cpu_dec(bpf_prog_active);
493 preempt_enable(); 498 preempt_enable();
494 499
500 if (!err)
501 trace_bpf_map_delete_elem(map, ufd, key);
495free_key: 502free_key:
496 kfree(key); 503 kfree(key);
497err_put: 504err_put:
@@ -544,6 +551,7 @@ static int map_get_next_key(union bpf_attr *attr)
544 if (copy_to_user(unext_key, next_key, map->key_size) != 0) 551 if (copy_to_user(unext_key, next_key, map->key_size) != 0)
545 goto free_next_key; 552 goto free_next_key;
546 553
554 trace_bpf_map_next_key(map, ufd, key, next_key);
547 err = 0; 555 err = 0;
548 556
549free_next_key: 557free_next_key:
@@ -697,8 +705,10 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu)
697 705
698void bpf_prog_put(struct bpf_prog *prog) 706void bpf_prog_put(struct bpf_prog *prog)
699{ 707{
700 if (atomic_dec_and_test(&prog->aux->refcnt)) 708 if (atomic_dec_and_test(&prog->aux->refcnt)) {
709 trace_bpf_prog_put_rcu(prog);
701 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); 710 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu);
711 }
702} 712}
703EXPORT_SYMBOL_GPL(bpf_prog_put); 713EXPORT_SYMBOL_GPL(bpf_prog_put);
704 714
@@ -807,7 +817,11 @@ struct bpf_prog *bpf_prog_get(u32 ufd)
807 817
808struct bpf_prog *bpf_prog_get_type(u32 ufd, enum bpf_prog_type type) 818struct bpf_prog *bpf_prog_get_type(u32 ufd, enum bpf_prog_type type)
809{ 819{
810 return __bpf_prog_get(ufd, &type); 820 struct bpf_prog *prog = __bpf_prog_get(ufd, &type);
821
822 if (!IS_ERR(prog))
823 trace_bpf_prog_get_type(prog);
824 return prog;
811} 825}
812EXPORT_SYMBOL_GPL(bpf_prog_get_type); 826EXPORT_SYMBOL_GPL(bpf_prog_get_type);
813 827
@@ -889,6 +903,7 @@ static int bpf_prog_load(union bpf_attr *attr)
889 /* failed to allocate fd */ 903 /* failed to allocate fd */
890 goto free_used_maps; 904 goto free_used_maps;
891 905
906 trace_bpf_prog_load(prog, err);
892 return err; 907 return err;
893 908
894free_used_maps: 909free_used_maps: