Lines Matching refs:prog
1642 static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog) in find_prog_type() argument
1653 if (!bpf_prog_is_dev_bound(prog->aux)) in find_prog_type()
1654 prog->aux->ops = ops; in find_prog_type()
1656 prog->aux->ops = &bpf_offload_prog_ops; in find_prog_type()
1657 prog->type = type; in find_prog_type()
1672 static void bpf_audit_prog(const struct bpf_prog *prog, unsigned int op) in bpf_audit_prog() argument
1687 prog->aux->id, bpf_audit_str[op]); in bpf_audit_prog()
1691 static int bpf_prog_alloc_id(struct bpf_prog *prog) in bpf_prog_alloc_id() argument
1697 id = idr_alloc_cyclic(&prog_idr, prog, 1, INT_MAX, GFP_ATOMIC); in bpf_prog_alloc_id()
1699 prog->aux->id = id; in bpf_prog_alloc_id()
1710 void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock) in bpf_prog_free_id() argument
1719 if (!prog->aux->id) in bpf_prog_free_id()
1727 idr_remove(&prog_idr, prog->aux->id); in bpf_prog_free_id()
1728 prog->aux->id = 0; in bpf_prog_free_id()
1744 bpf_prog_free(aux->prog); in __bpf_prog_put_rcu()
1747 static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred) in __bpf_prog_put_noref() argument
1749 bpf_prog_kallsyms_del_all(prog); in __bpf_prog_put_noref()
1750 btf_put(prog->aux->btf); in __bpf_prog_put_noref()
1751 kvfree(prog->aux->jited_linfo); in __bpf_prog_put_noref()
1752 kvfree(prog->aux->linfo); in __bpf_prog_put_noref()
1753 kfree(prog->aux->kfunc_tab); in __bpf_prog_put_noref()
1754 if (prog->aux->attach_btf) in __bpf_prog_put_noref()
1755 btf_put(prog->aux->attach_btf); in __bpf_prog_put_noref()
1758 if (prog->aux->sleepable) in __bpf_prog_put_noref()
1759 call_rcu_tasks_trace(&prog->aux->rcu, __bpf_prog_put_rcu); in __bpf_prog_put_noref()
1761 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); in __bpf_prog_put_noref()
1763 __bpf_prog_put_rcu(&prog->aux->rcu); in __bpf_prog_put_noref()
1770 struct bpf_prog *prog; in bpf_prog_put_deferred() local
1773 prog = aux->prog; in bpf_prog_put_deferred()
1774 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0); in bpf_prog_put_deferred()
1775 bpf_audit_prog(prog, BPF_AUDIT_UNLOAD); in bpf_prog_put_deferred()
1776 __bpf_prog_put_noref(prog, true); in bpf_prog_put_deferred()
1779 static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock) in __bpf_prog_put() argument
1781 struct bpf_prog_aux *aux = prog->aux; in __bpf_prog_put()
1785 bpf_prog_free_id(prog, do_idr_lock); in __bpf_prog_put()
1796 void bpf_prog_put(struct bpf_prog *prog) in bpf_prog_put() argument
1798 __bpf_prog_put(prog, true); in bpf_prog_put()
1804 struct bpf_prog *prog = filp->private_data; in bpf_prog_release() local
1806 bpf_prog_put(prog); in bpf_prog_release()
1810 static void bpf_prog_get_stats(const struct bpf_prog *prog, in bpf_prog_get_stats() argument
1821 st = per_cpu_ptr(prog->stats, cpu); in bpf_prog_get_stats()
1840 const struct bpf_prog *prog = filp->private_data; in bpf_prog_show_fdinfo() local
1841 char prog_tag[sizeof(prog->tag) * 2 + 1] = { }; in bpf_prog_show_fdinfo()
1844 bpf_prog_get_stats(prog, &stats); in bpf_prog_show_fdinfo()
1845 bin2hex(prog_tag, prog->tag, sizeof(prog->tag)); in bpf_prog_show_fdinfo()
1855 prog->type, in bpf_prog_show_fdinfo()
1856 prog->jited, in bpf_prog_show_fdinfo()
1858 prog->pages * 1ULL << PAGE_SHIFT, in bpf_prog_show_fdinfo()
1859 prog->aux->id, in bpf_prog_show_fdinfo()
1875 int bpf_prog_new_fd(struct bpf_prog *prog) in bpf_prog_new_fd() argument
1879 ret = security_bpf_prog(prog); in bpf_prog_new_fd()
1883 return anon_inode_getfd("bpf-prog", &bpf_prog_fops, prog, in bpf_prog_new_fd()
1899 void bpf_prog_add(struct bpf_prog *prog, int i) in bpf_prog_add() argument
1901 atomic64_add(i, &prog->aux->refcnt); in bpf_prog_add()
1905 void bpf_prog_sub(struct bpf_prog *prog, int i) in bpf_prog_sub() argument
1912 WARN_ON(atomic64_sub_return(i, &prog->aux->refcnt) == 0); in bpf_prog_sub()
1916 void bpf_prog_inc(struct bpf_prog *prog) in bpf_prog_inc() argument
1918 atomic64_inc(&prog->aux->refcnt); in bpf_prog_inc()
1923 struct bpf_prog *bpf_prog_inc_not_zero(struct bpf_prog *prog) in bpf_prog_inc_not_zero() argument
1927 refold = atomic64_fetch_add_unless(&prog->aux->refcnt, 1, 0); in bpf_prog_inc_not_zero()
1932 return prog; in bpf_prog_inc_not_zero()
1936 bool bpf_prog_get_ok(struct bpf_prog *prog, in bpf_prog_get_ok() argument
1943 if (prog->type != *attach_type) in bpf_prog_get_ok()
1945 if (bpf_prog_is_dev_bound(prog->aux) && !attach_drv) in bpf_prog_get_ok()
1955 struct bpf_prog *prog; in __bpf_prog_get() local
1957 prog = ____bpf_prog_get(f); in __bpf_prog_get()
1958 if (IS_ERR(prog)) in __bpf_prog_get()
1959 return prog; in __bpf_prog_get()
1960 if (!bpf_prog_get_ok(prog, attach_type, attach_drv)) { in __bpf_prog_get()
1961 prog = ERR_PTR(-EINVAL); in __bpf_prog_get()
1965 bpf_prog_inc(prog); in __bpf_prog_get()
1968 return prog; in __bpf_prog_get()
2167 struct bpf_prog *prog, *dst_prog = NULL; in bpf_prog_load() local
2251 prog = bpf_prog_alloc(bpf_prog_size(attr->insn_cnt), GFP_USER); in bpf_prog_load()
2252 if (!prog) { in bpf_prog_load()
2260 prog->expected_attach_type = attr->expected_attach_type; in bpf_prog_load()
2261 prog->aux->attach_btf = attach_btf; in bpf_prog_load()
2262 prog->aux->attach_btf_id = attr->attach_btf_id; in bpf_prog_load()
2263 prog->aux->dst_prog = dst_prog; in bpf_prog_load()
2264 prog->aux->offload_requested = !!attr->prog_ifindex; in bpf_prog_load()
2265 prog->aux->sleepable = attr->prog_flags & BPF_F_SLEEPABLE; in bpf_prog_load()
2267 err = security_bpf_prog_alloc(prog->aux); in bpf_prog_load()
2271 prog->aux->user = get_current_user(); in bpf_prog_load()
2272 prog->len = attr->insn_cnt; in bpf_prog_load()
2275 if (copy_from_bpfptr(prog->insns, in bpf_prog_load()
2277 bpf_prog_insn_size(prog)) != 0) in bpf_prog_load()
2280 prog->orig_prog = NULL; in bpf_prog_load()
2281 prog->jited = 0; in bpf_prog_load()
2283 atomic64_set(&prog->aux->refcnt, 1); in bpf_prog_load()
2284 prog->gpl_compatible = is_gpl ? 1 : 0; in bpf_prog_load()
2286 if (bpf_prog_is_dev_bound(prog->aux)) { in bpf_prog_load()
2287 err = bpf_prog_offload_init(prog, attr); in bpf_prog_load()
2293 err = find_prog_type(type, prog); in bpf_prog_load()
2297 prog->aux->load_time = ktime_get_boottime_ns(); in bpf_prog_load()
2298 err = bpf_obj_name_cpy(prog->aux->name, attr->prog_name, in bpf_prog_load()
2304 err = bpf_check(&prog, attr, uattr); in bpf_prog_load()
2308 prog = bpf_prog_select_runtime(prog, &err); in bpf_prog_load()
2312 err = bpf_prog_alloc_id(prog); in bpf_prog_load()
2330 bpf_prog_kallsyms_add(prog); in bpf_prog_load()
2331 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0); in bpf_prog_load()
2332 bpf_audit_prog(prog, BPF_AUDIT_LOAD); in bpf_prog_load()
2334 err = bpf_prog_new_fd(prog); in bpf_prog_load()
2336 bpf_prog_put(prog); in bpf_prog_load()
2344 __bpf_prog_put_noref(prog, prog->aux->func_cnt); in bpf_prog_load()
2347 free_uid(prog->aux->user); in bpf_prog_load()
2348 security_bpf_prog_free(prog->aux); in bpf_prog_load()
2350 if (prog->aux->attach_btf) in bpf_prog_load()
2351 btf_put(prog->aux->attach_btf); in bpf_prog_load()
2352 bpf_prog_free(prog); in bpf_prog_load()
2377 const struct bpf_link_ops *ops, struct bpf_prog *prog) in bpf_link_init() argument
2383 link->prog = prog; in bpf_link_init()
2405 primer->link->prog = NULL; in bpf_link_cleanup()
2420 if (link->prog) { in bpf_link_free()
2423 bpf_prog_put(link->prog); in bpf_link_free()
2475 const struct bpf_prog *prog = link->prog; in bpf_link_show_fdinfo() local
2476 char prog_tag[sizeof(prog->tag) * 2 + 1] = { }; in bpf_link_show_fdinfo()
2478 bin2hex(prog_tag, prog->tag, sizeof(prog->tag)); in bpf_link_show_fdinfo()
2487 prog->aux->id); in bpf_link_show_fdinfo()
2606 WARN_ON_ONCE(bpf_trampoline_unlink_prog(link->prog, in bpf_tracing_link_release()
2656 static int bpf_tracing_prog_attach(struct bpf_prog *prog, in bpf_tracing_prog_attach() argument
2667 switch (prog->type) { in bpf_tracing_prog_attach()
2669 if (prog->expected_attach_type != BPF_TRACE_FENTRY && in bpf_tracing_prog_attach()
2670 prog->expected_attach_type != BPF_TRACE_FEXIT && in bpf_tracing_prog_attach()
2671 prog->expected_attach_type != BPF_MODIFY_RETURN) { in bpf_tracing_prog_attach()
2677 if (prog->expected_attach_type != 0) { in bpf_tracing_prog_attach()
2683 if (prog->expected_attach_type != BPF_LSM_MAC) { in bpf_tracing_prog_attach()
2700 if (prog->type != BPF_PROG_TYPE_EXT) { in bpf_tracing_prog_attach()
2721 &bpf_tracing_link_lops, prog); in bpf_tracing_prog_attach()
2722 link->attach_type = prog->expected_attach_type; in bpf_tracing_prog_attach()
2724 mutex_lock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2744 if (!prog->aux->dst_trampoline && !tgt_prog) { in bpf_tracing_prog_attach()
2751 if (prog->type != BPF_PROG_TYPE_TRACING && in bpf_tracing_prog_attach()
2752 prog->type != BPF_PROG_TYPE_LSM) { in bpf_tracing_prog_attach()
2756 btf_id = prog->aux->attach_btf_id; in bpf_tracing_prog_attach()
2757 key = bpf_trampoline_compute_key(NULL, prog->aux->attach_btf, btf_id); in bpf_tracing_prog_attach()
2760 if (!prog->aux->dst_trampoline || in bpf_tracing_prog_attach()
2761 (key && key != prog->aux->dst_trampoline->key)) { in bpf_tracing_prog_attach()
2768 err = bpf_check_attach_target(NULL, prog, tgt_prog, btf_id, in bpf_tracing_prog_attach()
2786 tr = prog->aux->dst_trampoline; in bpf_tracing_prog_attach()
2787 tgt_prog = prog->aux->dst_prog; in bpf_tracing_prog_attach()
2794 err = bpf_trampoline_link_prog(prog, tr); in bpf_tracing_prog_attach()
2808 if (prog->aux->dst_prog && in bpf_tracing_prog_attach()
2809 (tgt_prog_fd || tr != prog->aux->dst_trampoline)) in bpf_tracing_prog_attach()
2811 bpf_prog_put(prog->aux->dst_prog); in bpf_tracing_prog_attach()
2812 if (prog->aux->dst_trampoline && tr != prog->aux->dst_trampoline) in bpf_tracing_prog_attach()
2814 bpf_trampoline_put(prog->aux->dst_trampoline); in bpf_tracing_prog_attach()
2816 prog->aux->dst_prog = NULL; in bpf_tracing_prog_attach()
2817 prog->aux->dst_trampoline = NULL; in bpf_tracing_prog_attach()
2818 mutex_unlock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2822 if (tr && tr != prog->aux->dst_trampoline) in bpf_tracing_prog_attach()
2824 mutex_unlock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2842 bpf_probe_unregister(raw_tp->btp, raw_tp->link.prog); in bpf_raw_tp_link_release()
2933 static int bpf_perf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog) in bpf_perf_link_attach() argument
2953 bpf_link_init(&link->link, BPF_LINK_TYPE_PERF_EVENT, &bpf_perf_link_lops, prog); in bpf_perf_link_attach()
2963 err = perf_event_set_bpf_prog(event, prog, attr->link_create.perf_event.bpf_cookie); in bpf_perf_link_attach()
2969 bpf_prog_inc(prog); in bpf_perf_link_attach()
2986 struct bpf_prog *prog; in bpf_raw_tracepoint_open() local
2994 prog = bpf_prog_get(attr->raw_tracepoint.prog_fd); in bpf_raw_tracepoint_open()
2995 if (IS_ERR(prog)) in bpf_raw_tracepoint_open()
2996 return PTR_ERR(prog); in bpf_raw_tracepoint_open()
2998 switch (prog->type) { in bpf_raw_tracepoint_open()
3009 if (prog->type == BPF_PROG_TYPE_TRACING && in bpf_raw_tracepoint_open()
3010 prog->expected_attach_type == BPF_TRACE_RAW_TP) { in bpf_raw_tracepoint_open()
3011 tp_name = prog->aux->attach_func_name; in bpf_raw_tracepoint_open()
3014 err = bpf_tracing_prog_attach(prog, 0, 0); in bpf_raw_tracepoint_open()
3046 &bpf_raw_tp_link_lops, prog); in bpf_raw_tracepoint_open()
3055 err = bpf_probe_register(link->btp, prog); in bpf_raw_tracepoint_open()
3066 bpf_prog_put(prog); in bpf_raw_tracepoint_open()
3070 static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, in bpf_prog_attach_check_attach_type() argument
3073 switch (prog->type) { in bpf_prog_attach_check_attach_type()
3078 return attach_type == prog->expected_attach_type ? 0 : -EINVAL; in bpf_prog_attach_check_attach_type()
3085 return prog->enforce_expected_attach_type && in bpf_prog_attach_check_attach_type()
3086 prog->expected_attach_type != attach_type ? in bpf_prog_attach_check_attach_type()
3156 struct bpf_prog *prog; in bpf_prog_attach() local
3169 prog = bpf_prog_get_type(attr->attach_bpf_fd, ptype); in bpf_prog_attach()
3170 if (IS_ERR(prog)) in bpf_prog_attach()
3171 return PTR_ERR(prog); in bpf_prog_attach()
3173 if (bpf_prog_attach_check_attach_type(prog, attr->attach_type)) { in bpf_prog_attach()
3174 bpf_prog_put(prog); in bpf_prog_attach()
3181 ret = sock_map_get_from_fd(attr, prog); in bpf_prog_attach()
3184 ret = lirc_prog_attach(attr, prog); in bpf_prog_attach()
3187 ret = netns_bpf_prog_attach(attr, prog); in bpf_prog_attach()
3196 ret = cgroup_bpf_prog_attach(attr, ptype, prog); in bpf_prog_attach()
3203 bpf_prog_put(prog); in bpf_prog_attach()
3291 struct bpf_prog *prog; in bpf_prog_test_run() local
3305 prog = bpf_prog_get(attr->test.prog_fd); in bpf_prog_test_run()
3306 if (IS_ERR(prog)) in bpf_prog_test_run()
3307 return PTR_ERR(prog); in bpf_prog_test_run()
3309 if (prog->aux->ops->test_run) in bpf_prog_test_run()
3310 ret = prog->aux->ops->test_run(prog, attr, uattr); in bpf_prog_test_run()
3312 bpf_prog_put(prog); in bpf_prog_test_run()
3365 struct bpf_prog *prog; in bpf_prog_get_curr_or_next() local
3369 prog = idr_get_next(&prog_idr, id); in bpf_prog_get_curr_or_next()
3370 if (prog) { in bpf_prog_get_curr_or_next()
3371 prog = bpf_prog_inc_not_zero(prog); in bpf_prog_get_curr_or_next()
3372 if (IS_ERR(prog)) { in bpf_prog_get_curr_or_next()
3379 return prog; in bpf_prog_get_curr_or_next()
3386 struct bpf_prog *prog; in bpf_prog_by_id() local
3392 prog = idr_find(&prog_idr, id); in bpf_prog_by_id()
3393 if (prog) in bpf_prog_by_id()
3394 prog = bpf_prog_inc_not_zero(prog); in bpf_prog_by_id()
3396 prog = ERR_PTR(-ENOENT); in bpf_prog_by_id()
3398 return prog; in bpf_prog_by_id()
3403 struct bpf_prog *prog; in bpf_prog_get_fd_by_id() local
3413 prog = bpf_prog_by_id(id); in bpf_prog_get_fd_by_id()
3414 if (IS_ERR(prog)) in bpf_prog_get_fd_by_id()
3415 return PTR_ERR(prog); in bpf_prog_get_fd_by_id()
3417 fd = bpf_prog_new_fd(prog); in bpf_prog_get_fd_by_id()
3419 bpf_prog_put(prog); in bpf_prog_get_fd_by_id()
3462 static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog, in bpf_map_from_imm() argument
3469 mutex_lock(&prog->aux->used_maps_mutex); in bpf_map_from_imm()
3470 for (i = 0, *off = 0; i < prog->aux->used_map_cnt; i++) { in bpf_map_from_imm()
3471 map = prog->aux->used_maps[i]; in bpf_map_from_imm()
3486 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_map_from_imm()
3490 static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog, in bpf_insn_prepare_dump() argument
3500 insns = kmemdup(prog->insnsi, bpf_prog_insn_size(prog), in bpf_insn_prepare_dump()
3505 for (i = 0; i < prog->len; i++) { in bpf_insn_prepare_dump()
3530 map = bpf_map_from_imm(prog, imm, &off, &type); in bpf_insn_prepare_dump()
3574 struct bpf_prog *prog, in bpf_prog_get_info_by_fd() argument
3595 info.type = prog->type; in bpf_prog_get_info_by_fd()
3596 info.id = prog->aux->id; in bpf_prog_get_info_by_fd()
3597 info.load_time = prog->aux->load_time; in bpf_prog_get_info_by_fd()
3599 prog->aux->user->uid); in bpf_prog_get_info_by_fd()
3600 info.gpl_compatible = prog->gpl_compatible; in bpf_prog_get_info_by_fd()
3602 memcpy(info.tag, prog->tag, sizeof(prog->tag)); in bpf_prog_get_info_by_fd()
3603 memcpy(info.name, prog->aux->name, sizeof(prog->aux->name)); in bpf_prog_get_info_by_fd()
3605 mutex_lock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3607 info.nr_map_ids = prog->aux->used_map_cnt; in bpf_prog_get_info_by_fd()
3614 if (put_user(prog->aux->used_maps[i]->id, in bpf_prog_get_info_by_fd()
3616 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3620 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3626 bpf_prog_get_stats(prog, &stats); in bpf_prog_get_info_by_fd()
3643 info.xlated_prog_len = bpf_prog_insn_size(prog); in bpf_prog_get_info_by_fd()
3648 if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) { in bpf_prog_get_info_by_fd()
3652 insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred); in bpf_prog_get_info_by_fd()
3663 if (bpf_prog_is_dev_bound(prog->aux)) { in bpf_prog_get_info_by_fd()
3664 err = bpf_prog_offload_info_fill(&info, prog); in bpf_prog_get_info_by_fd()
3675 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3679 for (i = 0; i < prog->aux->func_cnt; i++) in bpf_prog_get_info_by_fd()
3680 info.jited_prog_len += prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3682 info.jited_prog_len = prog->jited_len; in bpf_prog_get_info_by_fd()
3693 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3698 for (i = 0; i < prog->aux->func_cnt; i++) { in bpf_prog_get_info_by_fd()
3699 len = prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3701 img = (u8 *) prog->aux->func[i]->bpf_func; in bpf_prog_get_info_by_fd()
3710 if (copy_to_user(uinsns, prog->bpf_func, ulen)) in bpf_prog_get_info_by_fd()
3719 info.nr_jited_ksyms = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3731 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3734 prog->aux->func[i]->bpf_func; in bpf_prog_get_info_by_fd()
3740 ksym_addr = (unsigned long) prog->bpf_func; in bpf_prog_get_info_by_fd()
3750 info.nr_jited_func_lens = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3759 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3762 prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3767 func_len = prog->jited_len; in bpf_prog_get_info_by_fd()
3776 if (prog->aux->btf) in bpf_prog_get_info_by_fd()
3777 info.btf_id = btf_obj_id(prog->aux->btf); in bpf_prog_get_info_by_fd()
3780 info.nr_func_info = prog->aux->func_info_cnt; in bpf_prog_get_info_by_fd()
3786 if (copy_to_user(user_finfo, prog->aux->func_info, in bpf_prog_get_info_by_fd()
3792 info.nr_line_info = prog->aux->nr_linfo; in bpf_prog_get_info_by_fd()
3798 if (copy_to_user(user_linfo, prog->aux->linfo, in bpf_prog_get_info_by_fd()
3804 if (prog->aux->jited_linfo) in bpf_prog_get_info_by_fd()
3805 info.nr_jited_line_info = prog->aux->nr_linfo; in bpf_prog_get_info_by_fd()
3816 if (put_user((__u64)(long)prog->aux->jited_linfo[i], in bpf_prog_get_info_by_fd()
3826 info.nr_prog_tags = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3833 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3836 prog->aux->func[i]->tag, in bpf_prog_get_info_by_fd()
3842 prog->tag, BPF_TAG_SIZE)) in bpf_prog_get_info_by_fd()
3936 info.prog_id = link->prog->aux->id; in bpf_link_get_info_by_fd()
4099 raw_tp->link.prog->aux->id, in bpf_task_fd_query()
4187 struct bpf_prog *prog) in tracing_bpf_link_attach() argument
4189 if (attr->link_create.attach_type != prog->expected_attach_type) in tracing_bpf_link_attach()
4192 if (prog->expected_attach_type == BPF_TRACE_ITER) in tracing_bpf_link_attach()
4193 return bpf_iter_link_attach(attr, uattr, prog); in tracing_bpf_link_attach()
4194 else if (prog->type == BPF_PROG_TYPE_EXT) in tracing_bpf_link_attach()
4195 return bpf_tracing_prog_attach(prog, in tracing_bpf_link_attach()
4205 struct bpf_prog *prog; in link_create() local
4211 prog = bpf_prog_get(attr->link_create.prog_fd); in link_create()
4212 if (IS_ERR(prog)) in link_create()
4213 return PTR_ERR(prog); in link_create()
4215 ret = bpf_prog_attach_check_attach_type(prog, in link_create()
4220 switch (prog->type) { in link_create()
4222 ret = tracing_bpf_link_attach(attr, uattr, prog); in link_create()
4231 ptype = prog->type; in link_create()
4235 if (ptype == BPF_PROG_TYPE_UNSPEC || ptype != prog->type) { in link_create()
4250 ret = cgroup_bpf_link_attach(attr, prog); in link_create()
4253 ret = tracing_bpf_link_attach(attr, uattr, prog); in link_create()
4257 ret = netns_bpf_link_create(attr, prog); in link_create()
4261 ret = bpf_xdp_link_attach(attr, prog); in link_create()
4268 ret = bpf_perf_link_attach(attr, prog); in link_create()
4277 bpf_prog_put(prog); in link_create()
4490 struct bpf_prog *prog; in bpf_prog_bind_map() local
4501 prog = bpf_prog_get(attr->prog_bind_map.prog_fd); in bpf_prog_bind_map()
4502 if (IS_ERR(prog)) in bpf_prog_bind_map()
4503 return PTR_ERR(prog); in bpf_prog_bind_map()
4511 mutex_lock(&prog->aux->used_maps_mutex); in bpf_prog_bind_map()
4513 used_maps_old = prog->aux->used_maps; in bpf_prog_bind_map()
4515 for (i = 0; i < prog->aux->used_map_cnt; i++) in bpf_prog_bind_map()
4521 used_maps_new = kmalloc_array(prog->aux->used_map_cnt + 1, in bpf_prog_bind_map()
4530 sizeof(used_maps_old[0]) * prog->aux->used_map_cnt); in bpf_prog_bind_map()
4531 used_maps_new[prog->aux->used_map_cnt] = map; in bpf_prog_bind_map()
4533 prog->aux->used_map_cnt++; in bpf_prog_bind_map()
4534 prog->aux->used_maps = used_maps_new; in bpf_prog_bind_map()
4539 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_bind_map()
4544 bpf_prog_put(prog); in bpf_prog_bind_map()
4699 const struct bpf_prog *prog, in syscall_prog_is_valid_access() argument
4737 tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) in tracing_prog_func_proto() argument
4760 syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) in syscall_prog_func_proto() argument
4770 return tracing_prog_func_proto(func_id, prog); in syscall_prog_func_proto()