Lines Matching refs:prog
1673 static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog) in find_prog_type() argument
1684 if (!bpf_prog_is_dev_bound(prog->aux)) in find_prog_type()
1685 prog->aux->ops = ops; in find_prog_type()
1687 prog->aux->ops = &bpf_offload_prog_ops; in find_prog_type()
1688 prog->type = type; in find_prog_type()
1703 static void bpf_audit_prog(const struct bpf_prog *prog, unsigned int op) in bpf_audit_prog() argument
1718 prog->aux->id, bpf_audit_str[op]); in bpf_audit_prog()
1722 static int bpf_prog_alloc_id(struct bpf_prog *prog) in bpf_prog_alloc_id() argument
1728 id = idr_alloc_cyclic(&prog_idr, prog, 1, INT_MAX, GFP_ATOMIC); in bpf_prog_alloc_id()
1730 prog->aux->id = id; in bpf_prog_alloc_id()
1741 void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock) in bpf_prog_free_id() argument
1750 if (!prog->aux->id) in bpf_prog_free_id()
1758 idr_remove(&prog_idr, prog->aux->id); in bpf_prog_free_id()
1759 prog->aux->id = 0; in bpf_prog_free_id()
1775 bpf_prog_free(aux->prog); in __bpf_prog_put_rcu()
1778 static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred) in __bpf_prog_put_noref() argument
1780 bpf_prog_kallsyms_del_all(prog); in __bpf_prog_put_noref()
1781 btf_put(prog->aux->btf); in __bpf_prog_put_noref()
1782 kvfree(prog->aux->jited_linfo); in __bpf_prog_put_noref()
1783 kvfree(prog->aux->linfo); in __bpf_prog_put_noref()
1784 kfree(prog->aux->kfunc_tab); in __bpf_prog_put_noref()
1785 if (prog->aux->attach_btf) in __bpf_prog_put_noref()
1786 btf_put(prog->aux->attach_btf); in __bpf_prog_put_noref()
1789 if (prog->aux->sleepable) in __bpf_prog_put_noref()
1790 call_rcu_tasks_trace(&prog->aux->rcu, __bpf_prog_put_rcu); in __bpf_prog_put_noref()
1792 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); in __bpf_prog_put_noref()
1794 __bpf_prog_put_rcu(&prog->aux->rcu); in __bpf_prog_put_noref()
1801 struct bpf_prog *prog; in bpf_prog_put_deferred() local
1804 prog = aux->prog; in bpf_prog_put_deferred()
1805 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0); in bpf_prog_put_deferred()
1806 bpf_audit_prog(prog, BPF_AUDIT_UNLOAD); in bpf_prog_put_deferred()
1807 __bpf_prog_put_noref(prog, true); in bpf_prog_put_deferred()
1810 static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock) in __bpf_prog_put() argument
1812 struct bpf_prog_aux *aux = prog->aux; in __bpf_prog_put()
1816 bpf_prog_free_id(prog, do_idr_lock); in __bpf_prog_put()
1827 void bpf_prog_put(struct bpf_prog *prog) in bpf_prog_put() argument
1829 __bpf_prog_put(prog, true); in bpf_prog_put()
1835 struct bpf_prog *prog = filp->private_data; in bpf_prog_release() local
1837 bpf_prog_put(prog); in bpf_prog_release()
1847 static void bpf_prog_get_stats(const struct bpf_prog *prog, in bpf_prog_get_stats() argument
1858 st = per_cpu_ptr(prog->stats, cpu); in bpf_prog_get_stats()
1877 const struct bpf_prog *prog = filp->private_data; in bpf_prog_show_fdinfo() local
1878 char prog_tag[sizeof(prog->tag) * 2 + 1] = { }; in bpf_prog_show_fdinfo()
1881 bpf_prog_get_stats(prog, &stats); in bpf_prog_show_fdinfo()
1882 bin2hex(prog_tag, prog->tag, sizeof(prog->tag)); in bpf_prog_show_fdinfo()
1893 prog->type, in bpf_prog_show_fdinfo()
1894 prog->jited, in bpf_prog_show_fdinfo()
1896 prog->pages * 1ULL << PAGE_SHIFT, in bpf_prog_show_fdinfo()
1897 prog->aux->id, in bpf_prog_show_fdinfo()
1901 prog->aux->verified_insns); in bpf_prog_show_fdinfo()
1914 int bpf_prog_new_fd(struct bpf_prog *prog) in bpf_prog_new_fd() argument
1918 ret = security_bpf_prog(prog); in bpf_prog_new_fd()
1922 return anon_inode_getfd("bpf-prog", &bpf_prog_fops, prog, in bpf_prog_new_fd()
1938 void bpf_prog_add(struct bpf_prog *prog, int i) in bpf_prog_add() argument
1940 atomic64_add(i, &prog->aux->refcnt); in bpf_prog_add()
1944 void bpf_prog_sub(struct bpf_prog *prog, int i) in bpf_prog_sub() argument
1951 WARN_ON(atomic64_sub_return(i, &prog->aux->refcnt) == 0); in bpf_prog_sub()
1955 void bpf_prog_inc(struct bpf_prog *prog) in bpf_prog_inc() argument
1957 atomic64_inc(&prog->aux->refcnt); in bpf_prog_inc()
1962 struct bpf_prog *bpf_prog_inc_not_zero(struct bpf_prog *prog) in bpf_prog_inc_not_zero() argument
1966 refold = atomic64_fetch_add_unless(&prog->aux->refcnt, 1, 0); in bpf_prog_inc_not_zero()
1971 return prog; in bpf_prog_inc_not_zero()
1975 bool bpf_prog_get_ok(struct bpf_prog *prog, in bpf_prog_get_ok() argument
1982 if (prog->type != *attach_type) in bpf_prog_get_ok()
1984 if (bpf_prog_is_dev_bound(prog->aux) && !attach_drv) in bpf_prog_get_ok()
1994 struct bpf_prog *prog; in __bpf_prog_get() local
1996 prog = ____bpf_prog_get(f); in __bpf_prog_get()
1997 if (IS_ERR(prog)) in __bpf_prog_get()
1998 return prog; in __bpf_prog_get()
1999 if (!bpf_prog_get_ok(prog, attach_type, attach_drv)) { in __bpf_prog_get()
2000 prog = ERR_PTR(-EINVAL); in __bpf_prog_get()
2004 bpf_prog_inc(prog); in __bpf_prog_get()
2007 return prog; in __bpf_prog_get()
2206 struct bpf_prog *prog, *dst_prog = NULL; in bpf_prog_load() local
2290 prog = bpf_prog_alloc(bpf_prog_size(attr->insn_cnt), GFP_USER); in bpf_prog_load()
2291 if (!prog) { in bpf_prog_load()
2299 prog->expected_attach_type = attr->expected_attach_type; in bpf_prog_load()
2300 prog->aux->attach_btf = attach_btf; in bpf_prog_load()
2301 prog->aux->attach_btf_id = attr->attach_btf_id; in bpf_prog_load()
2302 prog->aux->dst_prog = dst_prog; in bpf_prog_load()
2303 prog->aux->offload_requested = !!attr->prog_ifindex; in bpf_prog_load()
2304 prog->aux->sleepable = attr->prog_flags & BPF_F_SLEEPABLE; in bpf_prog_load()
2306 err = security_bpf_prog_alloc(prog->aux); in bpf_prog_load()
2310 prog->aux->user = get_current_user(); in bpf_prog_load()
2311 prog->len = attr->insn_cnt; in bpf_prog_load()
2314 if (copy_from_bpfptr(prog->insns, in bpf_prog_load()
2316 bpf_prog_insn_size(prog)) != 0) in bpf_prog_load()
2319 prog->orig_prog = NULL; in bpf_prog_load()
2320 prog->jited = 0; in bpf_prog_load()
2322 atomic64_set(&prog->aux->refcnt, 1); in bpf_prog_load()
2323 prog->gpl_compatible = is_gpl ? 1 : 0; in bpf_prog_load()
2325 if (bpf_prog_is_dev_bound(prog->aux)) { in bpf_prog_load()
2326 err = bpf_prog_offload_init(prog, attr); in bpf_prog_load()
2332 err = find_prog_type(type, prog); in bpf_prog_load()
2336 prog->aux->load_time = ktime_get_boottime_ns(); in bpf_prog_load()
2337 err = bpf_obj_name_cpy(prog->aux->name, attr->prog_name, in bpf_prog_load()
2343 err = bpf_check(&prog, attr, uattr); in bpf_prog_load()
2347 prog = bpf_prog_select_runtime(prog, &err); in bpf_prog_load()
2351 err = bpf_prog_alloc_id(prog); in bpf_prog_load()
2369 bpf_prog_kallsyms_add(prog); in bpf_prog_load()
2370 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0); in bpf_prog_load()
2371 bpf_audit_prog(prog, BPF_AUDIT_LOAD); in bpf_prog_load()
2373 err = bpf_prog_new_fd(prog); in bpf_prog_load()
2375 bpf_prog_put(prog); in bpf_prog_load()
2383 __bpf_prog_put_noref(prog, prog->aux->func_cnt); in bpf_prog_load()
2386 free_uid(prog->aux->user); in bpf_prog_load()
2387 security_bpf_prog_free(prog->aux); in bpf_prog_load()
2389 if (prog->aux->attach_btf) in bpf_prog_load()
2390 btf_put(prog->aux->attach_btf); in bpf_prog_load()
2391 bpf_prog_free(prog); in bpf_prog_load()
2416 const struct bpf_link_ops *ops, struct bpf_prog *prog) in bpf_link_init() argument
2422 link->prog = prog; in bpf_link_init()
2444 primer->link->prog = NULL; in bpf_link_cleanup()
2459 if (link->prog) { in bpf_link_free()
2462 bpf_prog_put(link->prog); in bpf_link_free()
2514 const struct bpf_prog *prog = link->prog; in bpf_link_show_fdinfo() local
2515 char prog_tag[sizeof(prog->tag) * 2 + 1] = { }; in bpf_link_show_fdinfo()
2517 bin2hex(prog_tag, prog->tag, sizeof(prog->tag)); in bpf_link_show_fdinfo()
2526 prog->aux->id); in bpf_link_show_fdinfo()
2645 WARN_ON_ONCE(bpf_trampoline_unlink_prog(link->prog, in bpf_tracing_link_release()
2695 static int bpf_tracing_prog_attach(struct bpf_prog *prog, in bpf_tracing_prog_attach() argument
2706 switch (prog->type) { in bpf_tracing_prog_attach()
2708 if (prog->expected_attach_type != BPF_TRACE_FENTRY && in bpf_tracing_prog_attach()
2709 prog->expected_attach_type != BPF_TRACE_FEXIT && in bpf_tracing_prog_attach()
2710 prog->expected_attach_type != BPF_MODIFY_RETURN) { in bpf_tracing_prog_attach()
2716 if (prog->expected_attach_type != 0) { in bpf_tracing_prog_attach()
2722 if (prog->expected_attach_type != BPF_LSM_MAC) { in bpf_tracing_prog_attach()
2739 if (prog->type != BPF_PROG_TYPE_EXT) { in bpf_tracing_prog_attach()
2760 &bpf_tracing_link_lops, prog); in bpf_tracing_prog_attach()
2761 link->attach_type = prog->expected_attach_type; in bpf_tracing_prog_attach()
2763 mutex_lock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2783 if (!prog->aux->dst_trampoline && !tgt_prog) { in bpf_tracing_prog_attach()
2790 if (prog->type != BPF_PROG_TYPE_TRACING && in bpf_tracing_prog_attach()
2791 prog->type != BPF_PROG_TYPE_LSM) { in bpf_tracing_prog_attach()
2795 btf_id = prog->aux->attach_btf_id; in bpf_tracing_prog_attach()
2796 key = bpf_trampoline_compute_key(NULL, prog->aux->attach_btf, btf_id); in bpf_tracing_prog_attach()
2799 if (!prog->aux->dst_trampoline || in bpf_tracing_prog_attach()
2800 (key && key != prog->aux->dst_trampoline->key)) { in bpf_tracing_prog_attach()
2807 err = bpf_check_attach_target(NULL, prog, tgt_prog, btf_id, in bpf_tracing_prog_attach()
2825 tr = prog->aux->dst_trampoline; in bpf_tracing_prog_attach()
2826 tgt_prog = prog->aux->dst_prog; in bpf_tracing_prog_attach()
2833 err = bpf_trampoline_link_prog(prog, tr); in bpf_tracing_prog_attach()
2847 if (prog->aux->dst_prog && in bpf_tracing_prog_attach()
2848 (tgt_prog_fd || tr != prog->aux->dst_trampoline)) in bpf_tracing_prog_attach()
2850 bpf_prog_put(prog->aux->dst_prog); in bpf_tracing_prog_attach()
2851 if (prog->aux->dst_trampoline && tr != prog->aux->dst_trampoline) in bpf_tracing_prog_attach()
2853 bpf_trampoline_put(prog->aux->dst_trampoline); in bpf_tracing_prog_attach()
2855 prog->aux->dst_prog = NULL; in bpf_tracing_prog_attach()
2856 prog->aux->dst_trampoline = NULL; in bpf_tracing_prog_attach()
2857 mutex_unlock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2861 if (tr && tr != prog->aux->dst_trampoline) in bpf_tracing_prog_attach()
2863 mutex_unlock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2881 bpf_probe_unregister(raw_tp->btp, raw_tp->link.prog); in bpf_raw_tp_link_release()
2972 static int bpf_perf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog) in bpf_perf_link_attach() argument
2992 bpf_link_init(&link->link, BPF_LINK_TYPE_PERF_EVENT, &bpf_perf_link_lops, prog); in bpf_perf_link_attach()
3002 err = perf_event_set_bpf_prog(event, prog, attr->link_create.perf_event.bpf_cookie); in bpf_perf_link_attach()
3008 bpf_prog_inc(prog); in bpf_perf_link_attach()
3025 struct bpf_prog *prog; in bpf_raw_tracepoint_open() local
3033 prog = bpf_prog_get(attr->raw_tracepoint.prog_fd); in bpf_raw_tracepoint_open()
3034 if (IS_ERR(prog)) in bpf_raw_tracepoint_open()
3035 return PTR_ERR(prog); in bpf_raw_tracepoint_open()
3037 switch (prog->type) { in bpf_raw_tracepoint_open()
3048 if (prog->type == BPF_PROG_TYPE_TRACING && in bpf_raw_tracepoint_open()
3049 prog->expected_attach_type == BPF_TRACE_RAW_TP) { in bpf_raw_tracepoint_open()
3050 tp_name = prog->aux->attach_func_name; in bpf_raw_tracepoint_open()
3053 err = bpf_tracing_prog_attach(prog, 0, 0); in bpf_raw_tracepoint_open()
3085 &bpf_raw_tp_link_lops, prog); in bpf_raw_tracepoint_open()
3094 err = bpf_probe_register(link->btp, prog); in bpf_raw_tracepoint_open()
3105 bpf_prog_put(prog); in bpf_raw_tracepoint_open()
3109 static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, in bpf_prog_attach_check_attach_type() argument
3112 switch (prog->type) { in bpf_prog_attach_check_attach_type()
3117 return attach_type == prog->expected_attach_type ? 0 : -EINVAL; in bpf_prog_attach_check_attach_type()
3124 return prog->enforce_expected_attach_type && in bpf_prog_attach_check_attach_type()
3125 prog->expected_attach_type != attach_type ? in bpf_prog_attach_check_attach_type()
3195 struct bpf_prog *prog; in bpf_prog_attach() local
3208 prog = bpf_prog_get_type(attr->attach_bpf_fd, ptype); in bpf_prog_attach()
3209 if (IS_ERR(prog)) in bpf_prog_attach()
3210 return PTR_ERR(prog); in bpf_prog_attach()
3212 if (bpf_prog_attach_check_attach_type(prog, attr->attach_type)) { in bpf_prog_attach()
3213 bpf_prog_put(prog); in bpf_prog_attach()
3220 ret = sock_map_get_from_fd(attr, prog); in bpf_prog_attach()
3223 ret = lirc_prog_attach(attr, prog); in bpf_prog_attach()
3226 ret = netns_bpf_prog_attach(attr, prog); in bpf_prog_attach()
3235 ret = cgroup_bpf_prog_attach(attr, ptype, prog); in bpf_prog_attach()
3242 bpf_prog_put(prog); in bpf_prog_attach()
3330 struct bpf_prog *prog; in bpf_prog_test_run() local
3344 prog = bpf_prog_get(attr->test.prog_fd); in bpf_prog_test_run()
3345 if (IS_ERR(prog)) in bpf_prog_test_run()
3346 return PTR_ERR(prog); in bpf_prog_test_run()
3348 if (prog->aux->ops->test_run) in bpf_prog_test_run()
3349 ret = prog->aux->ops->test_run(prog, attr, uattr); in bpf_prog_test_run()
3351 bpf_prog_put(prog); in bpf_prog_test_run()
3404 struct bpf_prog *prog; in bpf_prog_get_curr_or_next() local
3408 prog = idr_get_next(&prog_idr, id); in bpf_prog_get_curr_or_next()
3409 if (prog) { in bpf_prog_get_curr_or_next()
3410 prog = bpf_prog_inc_not_zero(prog); in bpf_prog_get_curr_or_next()
3411 if (IS_ERR(prog)) { in bpf_prog_get_curr_or_next()
3418 return prog; in bpf_prog_get_curr_or_next()
3425 struct bpf_prog *prog; in bpf_prog_by_id() local
3431 prog = idr_find(&prog_idr, id); in bpf_prog_by_id()
3432 if (prog) in bpf_prog_by_id()
3433 prog = bpf_prog_inc_not_zero(prog); in bpf_prog_by_id()
3435 prog = ERR_PTR(-ENOENT); in bpf_prog_by_id()
3437 return prog; in bpf_prog_by_id()
3442 struct bpf_prog *prog; in bpf_prog_get_fd_by_id() local
3452 prog = bpf_prog_by_id(id); in bpf_prog_get_fd_by_id()
3453 if (IS_ERR(prog)) in bpf_prog_get_fd_by_id()
3454 return PTR_ERR(prog); in bpf_prog_get_fd_by_id()
3456 fd = bpf_prog_new_fd(prog); in bpf_prog_get_fd_by_id()
3458 bpf_prog_put(prog); in bpf_prog_get_fd_by_id()
3501 static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog, in bpf_map_from_imm() argument
3508 mutex_lock(&prog->aux->used_maps_mutex); in bpf_map_from_imm()
3509 for (i = 0, *off = 0; i < prog->aux->used_map_cnt; i++) { in bpf_map_from_imm()
3510 map = prog->aux->used_maps[i]; in bpf_map_from_imm()
3525 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_map_from_imm()
3529 static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog, in bpf_insn_prepare_dump() argument
3539 insns = kmemdup(prog->insnsi, bpf_prog_insn_size(prog), in bpf_insn_prepare_dump()
3544 for (i = 0; i < prog->len; i++) { in bpf_insn_prepare_dump()
3569 map = bpf_map_from_imm(prog, imm, &off, &type); in bpf_insn_prepare_dump()
3613 struct bpf_prog *prog, in bpf_prog_get_info_by_fd() argument
3634 info.type = prog->type; in bpf_prog_get_info_by_fd()
3635 info.id = prog->aux->id; in bpf_prog_get_info_by_fd()
3636 info.load_time = prog->aux->load_time; in bpf_prog_get_info_by_fd()
3638 prog->aux->user->uid); in bpf_prog_get_info_by_fd()
3639 info.gpl_compatible = prog->gpl_compatible; in bpf_prog_get_info_by_fd()
3641 memcpy(info.tag, prog->tag, sizeof(prog->tag)); in bpf_prog_get_info_by_fd()
3642 memcpy(info.name, prog->aux->name, sizeof(prog->aux->name)); in bpf_prog_get_info_by_fd()
3644 mutex_lock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3646 info.nr_map_ids = prog->aux->used_map_cnt; in bpf_prog_get_info_by_fd()
3653 if (put_user(prog->aux->used_maps[i]->id, in bpf_prog_get_info_by_fd()
3655 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3659 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3665 bpf_prog_get_stats(prog, &stats); in bpf_prog_get_info_by_fd()
3670 info.verified_insns = prog->aux->verified_insns; in bpf_prog_get_info_by_fd()
3684 info.xlated_prog_len = bpf_prog_insn_size(prog); in bpf_prog_get_info_by_fd()
3689 if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) { in bpf_prog_get_info_by_fd()
3693 insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred); in bpf_prog_get_info_by_fd()
3704 if (bpf_prog_is_dev_bound(prog->aux)) { in bpf_prog_get_info_by_fd()
3705 err = bpf_prog_offload_info_fill(&info, prog); in bpf_prog_get_info_by_fd()
3716 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3720 for (i = 0; i < prog->aux->func_cnt; i++) in bpf_prog_get_info_by_fd()
3721 info.jited_prog_len += prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3723 info.jited_prog_len = prog->jited_len; in bpf_prog_get_info_by_fd()
3734 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3739 for (i = 0; i < prog->aux->func_cnt; i++) { in bpf_prog_get_info_by_fd()
3740 len = prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3742 img = (u8 *) prog->aux->func[i]->bpf_func; in bpf_prog_get_info_by_fd()
3751 if (copy_to_user(uinsns, prog->bpf_func, ulen)) in bpf_prog_get_info_by_fd()
3760 info.nr_jited_ksyms = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3772 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3775 prog->aux->func[i]->bpf_func; in bpf_prog_get_info_by_fd()
3781 ksym_addr = (unsigned long) prog->bpf_func; in bpf_prog_get_info_by_fd()
3791 info.nr_jited_func_lens = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3800 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3803 prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3808 func_len = prog->jited_len; in bpf_prog_get_info_by_fd()
3817 if (prog->aux->btf) in bpf_prog_get_info_by_fd()
3818 info.btf_id = btf_obj_id(prog->aux->btf); in bpf_prog_get_info_by_fd()
3821 info.nr_func_info = prog->aux->func_info_cnt; in bpf_prog_get_info_by_fd()
3827 if (copy_to_user(user_finfo, prog->aux->func_info, in bpf_prog_get_info_by_fd()
3833 info.nr_line_info = prog->aux->nr_linfo; in bpf_prog_get_info_by_fd()
3839 if (copy_to_user(user_linfo, prog->aux->linfo, in bpf_prog_get_info_by_fd()
3845 if (prog->aux->jited_linfo) in bpf_prog_get_info_by_fd()
3846 info.nr_jited_line_info = prog->aux->nr_linfo; in bpf_prog_get_info_by_fd()
3857 if (put_user((__u64)(long)prog->aux->jited_linfo[i], in bpf_prog_get_info_by_fd()
3867 info.nr_prog_tags = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3874 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3877 prog->aux->func[i]->tag, in bpf_prog_get_info_by_fd()
3883 prog->tag, BPF_TAG_SIZE)) in bpf_prog_get_info_by_fd()
3978 info.prog_id = link->prog->aux->id; in bpf_link_get_info_by_fd()
4141 raw_tp->link.prog->aux->id, in bpf_task_fd_query()
4230 struct bpf_prog *prog) in tracing_bpf_link_attach() argument
4232 if (attr->link_create.attach_type != prog->expected_attach_type) in tracing_bpf_link_attach()
4235 if (prog->expected_attach_type == BPF_TRACE_ITER) in tracing_bpf_link_attach()
4236 return bpf_iter_link_attach(attr, uattr, prog); in tracing_bpf_link_attach()
4237 else if (prog->type == BPF_PROG_TYPE_EXT) in tracing_bpf_link_attach()
4238 return bpf_tracing_prog_attach(prog, in tracing_bpf_link_attach()
4248 struct bpf_prog *prog; in link_create() local
4254 prog = bpf_prog_get(attr->link_create.prog_fd); in link_create()
4255 if (IS_ERR(prog)) in link_create()
4256 return PTR_ERR(prog); in link_create()
4258 ret = bpf_prog_attach_check_attach_type(prog, in link_create()
4263 switch (prog->type) { in link_create()
4265 ret = tracing_bpf_link_attach(attr, uattr, prog); in link_create()
4274 ptype = prog->type; in link_create()
4278 if (ptype == BPF_PROG_TYPE_UNSPEC || ptype != prog->type) { in link_create()
4293 ret = cgroup_bpf_link_attach(attr, prog); in link_create()
4296 ret = tracing_bpf_link_attach(attr, uattr, prog); in link_create()
4300 ret = netns_bpf_link_create(attr, prog); in link_create()
4304 ret = bpf_xdp_link_attach(attr, prog); in link_create()
4311 ret = bpf_perf_link_attach(attr, prog); in link_create()
4320 bpf_prog_put(prog); in link_create()
4533 struct bpf_prog *prog; in bpf_prog_bind_map() local
4544 prog = bpf_prog_get(attr->prog_bind_map.prog_fd); in bpf_prog_bind_map()
4545 if (IS_ERR(prog)) in bpf_prog_bind_map()
4546 return PTR_ERR(prog); in bpf_prog_bind_map()
4554 mutex_lock(&prog->aux->used_maps_mutex); in bpf_prog_bind_map()
4556 used_maps_old = prog->aux->used_maps; in bpf_prog_bind_map()
4558 for (i = 0; i < prog->aux->used_map_cnt; i++) in bpf_prog_bind_map()
4564 used_maps_new = kmalloc_array(prog->aux->used_map_cnt + 1, in bpf_prog_bind_map()
4573 sizeof(used_maps_old[0]) * prog->aux->used_map_cnt); in bpf_prog_bind_map()
4574 used_maps_new[prog->aux->used_map_cnt] = map; in bpf_prog_bind_map()
4576 prog->aux->used_map_cnt++; in bpf_prog_bind_map()
4577 prog->aux->used_maps = used_maps_new; in bpf_prog_bind_map()
4582 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_bind_map()
4587 bpf_prog_put(prog); in bpf_prog_bind_map()
4742 const struct bpf_prog *prog, in syscall_prog_is_valid_access() argument
4780 tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) in tracing_prog_func_proto() argument
4828 syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) in syscall_prog_func_proto() argument
4840 return tracing_prog_func_proto(func_id, prog); in syscall_prog_func_proto()