summaryrefslogtreecommitdiffstats
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 1d6b29e4e2c3..05ad086ab71d 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/anon_inodes.h> 16#include <linux/anon_inodes.h>
@@ -215,6 +216,7 @@ static int map_create(union bpf_attr *attr)
215 /* failed to allocate fd */ 216 /* failed to allocate fd */
216 goto free_map; 217 goto free_map;
217 218
219 trace_bpf_map_create(map, err);
218 return err; 220 return err;
219 221
220free_map: 222free_map:
@@ -339,6 +341,7 @@ static int map_lookup_elem(union bpf_attr *attr)
339 if (copy_to_user(uvalue, value, value_size) != 0) 341 if (copy_to_user(uvalue, value, value_size) != 0)
340 goto free_value; 342 goto free_value;
341 343
344 trace_bpf_map_lookup_elem(map, ufd, key, value);
342 err = 0; 345 err = 0;
343 346
344free_value: 347free_value:
@@ -421,6 +424,8 @@ static int map_update_elem(union bpf_attr *attr)
421 __this_cpu_dec(bpf_prog_active); 424 __this_cpu_dec(bpf_prog_active);
422 preempt_enable(); 425 preempt_enable();
423 426
427 if (!err)
428 trace_bpf_map_update_elem(map, ufd, key, value);
424free_value: 429free_value:
425 kfree(value); 430 kfree(value);
426free_key: 431free_key:
@@ -466,6 +471,8 @@ static int map_delete_elem(union bpf_attr *attr)
466 __this_cpu_dec(bpf_prog_active); 471 __this_cpu_dec(bpf_prog_active);
467 preempt_enable(); 472 preempt_enable();
468 473
474 if (!err)
475 trace_bpf_map_delete_elem(map, ufd, key);
469free_key: 476free_key:
470 kfree(key); 477 kfree(key);
471err_put: 478err_put:
@@ -518,6 +525,7 @@ static int map_get_next_key(union bpf_attr *attr)
518 if (copy_to_user(unext_key, next_key, map->key_size) != 0) 525 if (copy_to_user(unext_key, next_key, map->key_size) != 0)
519 goto free_next_key; 526 goto free_next_key;
520 527
528 trace_bpf_map_next_key(map, ufd, key, next_key);
521 err = 0; 529 err = 0;
522 530
523free_next_key: 531free_next_key:
@@ -671,8 +679,10 @@ static void __bpf_prog_put_rcu(struct rcu_head *rcu)
671 679
672void bpf_prog_put(struct bpf_prog *prog) 680void bpf_prog_put(struct bpf_prog *prog)
673{ 681{
674 if (atomic_dec_and_test(&prog->aux->refcnt)) 682 if (atomic_dec_and_test(&prog->aux->refcnt)) {
683 trace_bpf_prog_put_rcu(prog);
675 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); 684 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu);
685 }
676} 686}
677EXPORT_SYMBOL_GPL(bpf_prog_put); 687EXPORT_SYMBOL_GPL(bpf_prog_put);
678 688
@@ -781,7 +791,11 @@ struct bpf_prog *bpf_prog_get(u32 ufd)
781 791
782struct bpf_prog *bpf_prog_get_type(u32 ufd, enum bpf_prog_type type) 792struct bpf_prog *bpf_prog_get_type(u32 ufd, enum bpf_prog_type type)
783{ 793{
784 return __bpf_prog_get(ufd, &type); 794 struct bpf_prog *prog = __bpf_prog_get(ufd, &type);
795
796 if (!IS_ERR(prog))
797 trace_bpf_prog_get_type(prog);
798 return prog;
785} 799}
786EXPORT_SYMBOL_GPL(bpf_prog_get_type); 800EXPORT_SYMBOL_GPL(bpf_prog_get_type);
787 801
@@ -863,6 +877,7 @@ static int bpf_prog_load(union bpf_attr *attr)
863 /* failed to allocate fd */ 877 /* failed to allocate fd */
864 goto free_used_maps; 878 goto free_used_maps;
865 879
880 trace_bpf_prog_load(prog, err);
866 return err; 881 return err;
867 882
868free_used_maps: 883free_used_maps: