Lines Matching refs:prog
1582 static int find_prog_type(enum bpf_prog_type type, struct bpf_prog *prog) in find_prog_type() argument
1593 if (!bpf_prog_is_dev_bound(prog->aux)) in find_prog_type()
1594 prog->aux->ops = ops; in find_prog_type()
1596 prog->aux->ops = &bpf_offload_prog_ops; in find_prog_type()
1597 prog->type = type; in find_prog_type()
1612 static void bpf_audit_prog(const struct bpf_prog *prog, unsigned int op) in bpf_audit_prog() argument
1627 prog->aux->id, bpf_audit_str[op]); in bpf_audit_prog()
1653 static int bpf_prog_charge_memlock(struct bpf_prog *prog) in bpf_prog_charge_memlock() argument
1658 ret = __bpf_prog_charge(user, prog->pages); in bpf_prog_charge_memlock()
1664 prog->aux->user = user; in bpf_prog_charge_memlock()
1668 static void bpf_prog_uncharge_memlock(struct bpf_prog *prog) in bpf_prog_uncharge_memlock() argument
1670 struct user_struct *user = prog->aux->user; in bpf_prog_uncharge_memlock()
1672 __bpf_prog_uncharge(user, prog->pages); in bpf_prog_uncharge_memlock()
1676 static int bpf_prog_alloc_id(struct bpf_prog *prog) in bpf_prog_alloc_id() argument
1682 id = idr_alloc_cyclic(&prog_idr, prog, 1, INT_MAX, GFP_ATOMIC); in bpf_prog_alloc_id()
1684 prog->aux->id = id; in bpf_prog_alloc_id()
1695 void bpf_prog_free_id(struct bpf_prog *prog, bool do_idr_lock) in bpf_prog_free_id() argument
1702 if (!prog->aux->id) in bpf_prog_free_id()
1710 idr_remove(&prog_idr, prog->aux->id); in bpf_prog_free_id()
1711 prog->aux->id = 0; in bpf_prog_free_id()
1725 bpf_prog_uncharge_memlock(aux->prog); in __bpf_prog_put_rcu()
1727 bpf_prog_free(aux->prog); in __bpf_prog_put_rcu()
1730 static void __bpf_prog_put_noref(struct bpf_prog *prog, bool deferred) in __bpf_prog_put_noref() argument
1732 bpf_prog_kallsyms_del_all(prog); in __bpf_prog_put_noref()
1733 btf_put(prog->aux->btf); in __bpf_prog_put_noref()
1734 bpf_prog_free_linfo(prog); in __bpf_prog_put_noref()
1737 if (prog->aux->sleepable) in __bpf_prog_put_noref()
1738 call_rcu_tasks_trace(&prog->aux->rcu, __bpf_prog_put_rcu); in __bpf_prog_put_noref()
1740 call_rcu(&prog->aux->rcu, __bpf_prog_put_rcu); in __bpf_prog_put_noref()
1742 __bpf_prog_put_rcu(&prog->aux->rcu); in __bpf_prog_put_noref()
1746 static void __bpf_prog_put(struct bpf_prog *prog, bool do_idr_lock) in __bpf_prog_put() argument
1748 if (atomic64_dec_and_test(&prog->aux->refcnt)) { in __bpf_prog_put()
1749 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_UNLOAD, 0); in __bpf_prog_put()
1750 bpf_audit_prog(prog, BPF_AUDIT_UNLOAD); in __bpf_prog_put()
1752 bpf_prog_free_id(prog, do_idr_lock); in __bpf_prog_put()
1753 __bpf_prog_put_noref(prog, true); in __bpf_prog_put()
1757 void bpf_prog_put(struct bpf_prog *prog) in bpf_prog_put() argument
1759 __bpf_prog_put(prog, true); in bpf_prog_put()
1765 struct bpf_prog *prog = filp->private_data; in bpf_prog_release() local
1767 bpf_prog_put(prog); in bpf_prog_release()
1771 static void bpf_prog_get_stats(const struct bpf_prog *prog, in bpf_prog_get_stats() argument
1782 st = per_cpu_ptr(prog->aux->stats, cpu); in bpf_prog_get_stats()
1798 const struct bpf_prog *prog = filp->private_data; in bpf_prog_show_fdinfo() local
1799 char prog_tag[sizeof(prog->tag) * 2 + 1] = { }; in bpf_prog_show_fdinfo()
1802 bpf_prog_get_stats(prog, &stats); in bpf_prog_show_fdinfo()
1803 bin2hex(prog_tag, prog->tag, sizeof(prog->tag)); in bpf_prog_show_fdinfo()
1812 prog->type, in bpf_prog_show_fdinfo()
1813 prog->jited, in bpf_prog_show_fdinfo()
1815 prog->pages * 1ULL << PAGE_SHIFT, in bpf_prog_show_fdinfo()
1816 prog->aux->id, in bpf_prog_show_fdinfo()
1831 int bpf_prog_new_fd(struct bpf_prog *prog) in bpf_prog_new_fd() argument
1835 ret = security_bpf_prog(prog); in bpf_prog_new_fd()
1839 return anon_inode_getfd("bpf-prog", &bpf_prog_fops, prog, in bpf_prog_new_fd()
1855 void bpf_prog_add(struct bpf_prog *prog, int i) in bpf_prog_add() argument
1857 atomic64_add(i, &prog->aux->refcnt); in bpf_prog_add()
1861 void bpf_prog_sub(struct bpf_prog *prog, int i) in bpf_prog_sub() argument
1868 WARN_ON(atomic64_sub_return(i, &prog->aux->refcnt) == 0); in bpf_prog_sub()
1872 void bpf_prog_inc(struct bpf_prog *prog) in bpf_prog_inc() argument
1874 atomic64_inc(&prog->aux->refcnt); in bpf_prog_inc()
1879 struct bpf_prog *bpf_prog_inc_not_zero(struct bpf_prog *prog) in bpf_prog_inc_not_zero() argument
1883 refold = atomic64_fetch_add_unless(&prog->aux->refcnt, 1, 0); in bpf_prog_inc_not_zero()
1888 return prog; in bpf_prog_inc_not_zero()
1892 bool bpf_prog_get_ok(struct bpf_prog *prog, in bpf_prog_get_ok() argument
1899 if (prog->type != *attach_type) in bpf_prog_get_ok()
1901 if (bpf_prog_is_dev_bound(prog->aux) && !attach_drv) in bpf_prog_get_ok()
1911 struct bpf_prog *prog; in __bpf_prog_get() local
1913 prog = ____bpf_prog_get(f); in __bpf_prog_get()
1914 if (IS_ERR(prog)) in __bpf_prog_get()
1915 return prog; in __bpf_prog_get()
1916 if (!bpf_prog_get_ok(prog, attach_type, attach_drv)) { in __bpf_prog_get()
1917 prog = ERR_PTR(-EINVAL); in __bpf_prog_get()
1921 bpf_prog_inc(prog); in __bpf_prog_get()
1924 return prog; in __bpf_prog_get()
2102 struct bpf_prog *prog; in bpf_prog_load() local
2151 prog = bpf_prog_alloc(bpf_prog_size(attr->insn_cnt), GFP_USER); in bpf_prog_load()
2152 if (!prog) in bpf_prog_load()
2155 prog->expected_attach_type = attr->expected_attach_type; in bpf_prog_load()
2156 prog->aux->attach_btf_id = attr->attach_btf_id; in bpf_prog_load()
2165 prog->aux->dst_prog = dst_prog; in bpf_prog_load()
2168 prog->aux->offload_requested = !!attr->prog_ifindex; in bpf_prog_load()
2169 prog->aux->sleepable = attr->prog_flags & BPF_F_SLEEPABLE; in bpf_prog_load()
2171 err = security_bpf_prog_alloc(prog->aux); in bpf_prog_load()
2175 err = bpf_prog_charge_memlock(prog); in bpf_prog_load()
2179 prog->len = attr->insn_cnt; in bpf_prog_load()
2182 if (copy_from_user(prog->insns, u64_to_user_ptr(attr->insns), in bpf_prog_load()
2183 bpf_prog_insn_size(prog)) != 0) in bpf_prog_load()
2186 prog->orig_prog = NULL; in bpf_prog_load()
2187 prog->jited = 0; in bpf_prog_load()
2189 atomic64_set(&prog->aux->refcnt, 1); in bpf_prog_load()
2190 prog->gpl_compatible = is_gpl ? 1 : 0; in bpf_prog_load()
2192 if (bpf_prog_is_dev_bound(prog->aux)) { in bpf_prog_load()
2193 err = bpf_prog_offload_init(prog, attr); in bpf_prog_load()
2199 err = find_prog_type(type, prog); in bpf_prog_load()
2203 prog->aux->load_time = ktime_get_boottime_ns(); in bpf_prog_load()
2204 err = bpf_obj_name_cpy(prog->aux->name, attr->prog_name, in bpf_prog_load()
2210 err = bpf_check(&prog, attr, uattr); in bpf_prog_load()
2214 prog = bpf_prog_select_runtime(prog, &err); in bpf_prog_load()
2218 err = bpf_prog_alloc_id(prog); in bpf_prog_load()
2236 bpf_prog_kallsyms_add(prog); in bpf_prog_load()
2237 perf_event_bpf_event(prog, PERF_BPF_EVENT_PROG_LOAD, 0); in bpf_prog_load()
2238 bpf_audit_prog(prog, BPF_AUDIT_LOAD); in bpf_prog_load()
2240 err = bpf_prog_new_fd(prog); in bpf_prog_load()
2242 bpf_prog_put(prog); in bpf_prog_load()
2250 __bpf_prog_put_noref(prog, prog->aux->func_cnt); in bpf_prog_load()
2253 bpf_prog_uncharge_memlock(prog); in bpf_prog_load()
2255 security_bpf_prog_free(prog->aux); in bpf_prog_load()
2257 bpf_prog_free(prog); in bpf_prog_load()
2282 const struct bpf_link_ops *ops, struct bpf_prog *prog) in bpf_link_init() argument
2288 link->prog = prog; in bpf_link_init()
2310 primer->link->prog = NULL; in bpf_link_cleanup()
2325 if (link->prog) { in bpf_link_free()
2328 bpf_prog_put(link->prog); in bpf_link_free()
2380 const struct bpf_prog *prog = link->prog; in bpf_link_show_fdinfo() local
2381 char prog_tag[sizeof(prog->tag) * 2 + 1] = { }; in bpf_link_show_fdinfo()
2383 bin2hex(prog_tag, prog->tag, sizeof(prog->tag)); in bpf_link_show_fdinfo()
2392 prog->aux->id); in bpf_link_show_fdinfo()
2511 WARN_ON_ONCE(bpf_trampoline_unlink_prog(link->prog, in bpf_tracing_link_release()
2558 static int bpf_tracing_prog_attach(struct bpf_prog *prog, in bpf_tracing_prog_attach() argument
2569 switch (prog->type) { in bpf_tracing_prog_attach()
2571 if (prog->expected_attach_type != BPF_TRACE_FENTRY && in bpf_tracing_prog_attach()
2572 prog->expected_attach_type != BPF_TRACE_FEXIT && in bpf_tracing_prog_attach()
2573 prog->expected_attach_type != BPF_MODIFY_RETURN) { in bpf_tracing_prog_attach()
2579 if (prog->expected_attach_type != 0) { in bpf_tracing_prog_attach()
2585 if (prog->expected_attach_type != BPF_LSM_MAC) { in bpf_tracing_prog_attach()
2602 if (prog->type != BPF_PROG_TYPE_EXT) { in bpf_tracing_prog_attach()
2623 &bpf_tracing_link_lops, prog); in bpf_tracing_prog_attach()
2624 link->attach_type = prog->expected_attach_type; in bpf_tracing_prog_attach()
2626 mutex_lock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2646 if (!prog->aux->dst_trampoline && !tgt_prog) { in bpf_tracing_prog_attach()
2651 if (!prog->aux->dst_trampoline || in bpf_tracing_prog_attach()
2652 (key && key != prog->aux->dst_trampoline->key)) { in bpf_tracing_prog_attach()
2659 err = bpf_check_attach_target(NULL, prog, tgt_prog, btf_id, in bpf_tracing_prog_attach()
2677 tr = prog->aux->dst_trampoline; in bpf_tracing_prog_attach()
2678 tgt_prog = prog->aux->dst_prog; in bpf_tracing_prog_attach()
2685 err = bpf_trampoline_link_prog(prog, tr); in bpf_tracing_prog_attach()
2699 if (prog->aux->dst_prog && in bpf_tracing_prog_attach()
2700 (tgt_prog_fd || tr != prog->aux->dst_trampoline)) in bpf_tracing_prog_attach()
2702 bpf_prog_put(prog->aux->dst_prog); in bpf_tracing_prog_attach()
2703 if (prog->aux->dst_trampoline && tr != prog->aux->dst_trampoline) in bpf_tracing_prog_attach()
2705 bpf_trampoline_put(prog->aux->dst_trampoline); in bpf_tracing_prog_attach()
2707 prog->aux->dst_prog = NULL; in bpf_tracing_prog_attach()
2708 prog->aux->dst_trampoline = NULL; in bpf_tracing_prog_attach()
2709 mutex_unlock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2713 if (tr && tr != prog->aux->dst_trampoline) in bpf_tracing_prog_attach()
2715 mutex_unlock(&prog->aux->dst_mutex); in bpf_tracing_prog_attach()
2720 bpf_prog_put(prog); in bpf_tracing_prog_attach()
2734 bpf_probe_unregister(raw_tp->btp, raw_tp->link.prog); in bpf_raw_tp_link_release()
2805 struct bpf_prog *prog; in bpf_raw_tracepoint_open() local
2813 prog = bpf_prog_get(attr->raw_tracepoint.prog_fd); in bpf_raw_tracepoint_open()
2814 if (IS_ERR(prog)) in bpf_raw_tracepoint_open()
2815 return PTR_ERR(prog); in bpf_raw_tracepoint_open()
2817 switch (prog->type) { in bpf_raw_tracepoint_open()
2828 if (prog->type == BPF_PROG_TYPE_TRACING && in bpf_raw_tracepoint_open()
2829 prog->expected_attach_type == BPF_TRACE_RAW_TP) { in bpf_raw_tracepoint_open()
2830 tp_name = prog->aux->attach_func_name; in bpf_raw_tracepoint_open()
2833 return bpf_tracing_prog_attach(prog, 0, 0); in bpf_raw_tracepoint_open()
2862 &bpf_raw_tp_link_lops, prog); in bpf_raw_tracepoint_open()
2871 err = bpf_probe_register(link->btp, prog); in bpf_raw_tracepoint_open()
2882 bpf_prog_put(prog); in bpf_raw_tracepoint_open()
2886 static int bpf_prog_attach_check_attach_type(const struct bpf_prog *prog, in bpf_prog_attach_check_attach_type() argument
2889 switch (prog->type) { in bpf_prog_attach_check_attach_type()
2894 return attach_type == prog->expected_attach_type ? 0 : -EINVAL; in bpf_prog_attach_check_attach_type()
2901 return prog->enforce_expected_attach_type && in bpf_prog_attach_check_attach_type()
2902 prog->expected_attach_type != attach_type ? in bpf_prog_attach_check_attach_type()
2971 struct bpf_prog *prog; in bpf_prog_attach() local
2984 prog = bpf_prog_get_type(attr->attach_bpf_fd, ptype); in bpf_prog_attach()
2985 if (IS_ERR(prog)) in bpf_prog_attach()
2986 return PTR_ERR(prog); in bpf_prog_attach()
2988 if (bpf_prog_attach_check_attach_type(prog, attr->attach_type)) { in bpf_prog_attach()
2989 bpf_prog_put(prog); in bpf_prog_attach()
2996 ret = sock_map_get_from_fd(attr, prog); in bpf_prog_attach()
2999 ret = lirc_prog_attach(attr, prog); in bpf_prog_attach()
3002 ret = netns_bpf_prog_attach(attr, prog); in bpf_prog_attach()
3011 ret = cgroup_bpf_prog_attach(attr, ptype, prog); in bpf_prog_attach()
3018 bpf_prog_put(prog); in bpf_prog_attach()
3106 struct bpf_prog *prog; in bpf_prog_test_run() local
3120 prog = bpf_prog_get(attr->test.prog_fd); in bpf_prog_test_run()
3121 if (IS_ERR(prog)) in bpf_prog_test_run()
3122 return PTR_ERR(prog); in bpf_prog_test_run()
3124 if (prog->aux->ops->test_run) in bpf_prog_test_run()
3125 ret = prog->aux->ops->test_run(prog, attr, uattr); in bpf_prog_test_run()
3127 bpf_prog_put(prog); in bpf_prog_test_run()
3180 struct bpf_prog *prog; in bpf_prog_get_curr_or_next() local
3184 prog = idr_get_next(&prog_idr, id); in bpf_prog_get_curr_or_next()
3185 if (prog) { in bpf_prog_get_curr_or_next()
3186 prog = bpf_prog_inc_not_zero(prog); in bpf_prog_get_curr_or_next()
3187 if (IS_ERR(prog)) { in bpf_prog_get_curr_or_next()
3194 return prog; in bpf_prog_get_curr_or_next()
3201 struct bpf_prog *prog; in bpf_prog_by_id() local
3207 prog = idr_find(&prog_idr, id); in bpf_prog_by_id()
3208 if (prog) in bpf_prog_by_id()
3209 prog = bpf_prog_inc_not_zero(prog); in bpf_prog_by_id()
3211 prog = ERR_PTR(-ENOENT); in bpf_prog_by_id()
3213 return prog; in bpf_prog_by_id()
3218 struct bpf_prog *prog; in bpf_prog_get_fd_by_id() local
3228 prog = bpf_prog_by_id(id); in bpf_prog_get_fd_by_id()
3229 if (IS_ERR(prog)) in bpf_prog_get_fd_by_id()
3230 return PTR_ERR(prog); in bpf_prog_get_fd_by_id()
3232 fd = bpf_prog_new_fd(prog); in bpf_prog_get_fd_by_id()
3234 bpf_prog_put(prog); in bpf_prog_get_fd_by_id()
3277 static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog, in bpf_map_from_imm() argument
3284 mutex_lock(&prog->aux->used_maps_mutex); in bpf_map_from_imm()
3285 for (i = 0, *off = 0; i < prog->aux->used_map_cnt; i++) { in bpf_map_from_imm()
3286 map = prog->aux->used_maps[i]; in bpf_map_from_imm()
3301 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_map_from_imm()
3305 static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog, in bpf_insn_prepare_dump() argument
3315 insns = kmemdup(prog->insnsi, bpf_prog_insn_size(prog), in bpf_insn_prepare_dump()
3320 for (i = 0; i < prog->len; i++) { in bpf_insn_prepare_dump()
3345 map = bpf_map_from_imm(prog, imm, &off, &type); in bpf_insn_prepare_dump()
3389 struct bpf_prog *prog, in bpf_prog_get_info_by_fd() argument
3410 info.type = prog->type; in bpf_prog_get_info_by_fd()
3411 info.id = prog->aux->id; in bpf_prog_get_info_by_fd()
3412 info.load_time = prog->aux->load_time; in bpf_prog_get_info_by_fd()
3414 prog->aux->user->uid); in bpf_prog_get_info_by_fd()
3415 info.gpl_compatible = prog->gpl_compatible; in bpf_prog_get_info_by_fd()
3417 memcpy(info.tag, prog->tag, sizeof(prog->tag)); in bpf_prog_get_info_by_fd()
3418 memcpy(info.name, prog->aux->name, sizeof(prog->aux->name)); in bpf_prog_get_info_by_fd()
3420 mutex_lock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3422 info.nr_map_ids = prog->aux->used_map_cnt; in bpf_prog_get_info_by_fd()
3429 if (put_user(prog->aux->used_maps[i]->id, in bpf_prog_get_info_by_fd()
3431 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3435 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_get_info_by_fd()
3441 bpf_prog_get_stats(prog, &stats); in bpf_prog_get_info_by_fd()
3457 info.xlated_prog_len = bpf_prog_insn_size(prog); in bpf_prog_get_info_by_fd()
3462 if (prog->blinded && !bpf_dump_raw_ok(file->f_cred)) { in bpf_prog_get_info_by_fd()
3466 insns_sanitized = bpf_insn_prepare_dump(prog, file->f_cred); in bpf_prog_get_info_by_fd()
3477 if (bpf_prog_is_dev_bound(prog->aux)) { in bpf_prog_get_info_by_fd()
3478 err = bpf_prog_offload_info_fill(&info, prog); in bpf_prog_get_info_by_fd()
3489 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3493 for (i = 0; i < prog->aux->func_cnt; i++) in bpf_prog_get_info_by_fd()
3494 info.jited_prog_len += prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3496 info.jited_prog_len = prog->jited_len; in bpf_prog_get_info_by_fd()
3507 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3512 for (i = 0; i < prog->aux->func_cnt; i++) { in bpf_prog_get_info_by_fd()
3513 len = prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3515 img = (u8 *) prog->aux->func[i]->bpf_func; in bpf_prog_get_info_by_fd()
3524 if (copy_to_user(uinsns, prog->bpf_func, ulen)) in bpf_prog_get_info_by_fd()
3533 info.nr_jited_ksyms = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3545 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3548 prog->aux->func[i]->bpf_func; in bpf_prog_get_info_by_fd()
3554 ksym_addr = (unsigned long) prog->bpf_func; in bpf_prog_get_info_by_fd()
3564 info.nr_jited_func_lens = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3573 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3576 prog->aux->func[i]->jited_len; in bpf_prog_get_info_by_fd()
3581 func_len = prog->jited_len; in bpf_prog_get_info_by_fd()
3590 if (prog->aux->btf) in bpf_prog_get_info_by_fd()
3591 info.btf_id = btf_id(prog->aux->btf); in bpf_prog_get_info_by_fd()
3594 info.nr_func_info = prog->aux->func_info_cnt; in bpf_prog_get_info_by_fd()
3600 if (copy_to_user(user_finfo, prog->aux->func_info, in bpf_prog_get_info_by_fd()
3606 info.nr_line_info = prog->aux->nr_linfo; in bpf_prog_get_info_by_fd()
3612 if (copy_to_user(user_linfo, prog->aux->linfo, in bpf_prog_get_info_by_fd()
3618 if (prog->aux->jited_linfo) in bpf_prog_get_info_by_fd()
3619 info.nr_jited_line_info = prog->aux->nr_linfo; in bpf_prog_get_info_by_fd()
3630 if (put_user((__u64)(long)prog->aux->jited_linfo[i], in bpf_prog_get_info_by_fd()
3640 info.nr_prog_tags = prog->aux->func_cnt ? : 1; in bpf_prog_get_info_by_fd()
3647 if (prog->aux->func_cnt) { in bpf_prog_get_info_by_fd()
3650 prog->aux->func[i]->tag, in bpf_prog_get_info_by_fd()
3656 prog->tag, BPF_TAG_SIZE)) in bpf_prog_get_info_by_fd()
3750 info.prog_id = link->prog->aux->id; in bpf_link_get_info_by_fd()
3926 raw_tp->link.prog->aux->id, in bpf_task_fd_query()
4014 static int tracing_bpf_link_attach(const union bpf_attr *attr, struct bpf_prog *prog) in tracing_bpf_link_attach() argument
4016 if (attr->link_create.attach_type != prog->expected_attach_type) in tracing_bpf_link_attach()
4019 if (prog->expected_attach_type == BPF_TRACE_ITER) in tracing_bpf_link_attach()
4020 return bpf_iter_link_attach(attr, prog); in tracing_bpf_link_attach()
4021 else if (prog->type == BPF_PROG_TYPE_EXT) in tracing_bpf_link_attach()
4022 return bpf_tracing_prog_attach(prog, in tracing_bpf_link_attach()
4032 struct bpf_prog *prog; in link_create() local
4038 prog = bpf_prog_get(attr->link_create.prog_fd); in link_create()
4039 if (IS_ERR(prog)) in link_create()
4040 return PTR_ERR(prog); in link_create()
4042 ret = bpf_prog_attach_check_attach_type(prog, in link_create()
4047 if (prog->type == BPF_PROG_TYPE_EXT) { in link_create()
4048 ret = tracing_bpf_link_attach(attr, prog); in link_create()
4053 if (ptype == BPF_PROG_TYPE_UNSPEC || ptype != prog->type) { in link_create()
4066 ret = cgroup_bpf_link_attach(attr, prog); in link_create()
4069 ret = tracing_bpf_link_attach(attr, prog); in link_create()
4073 ret = netns_bpf_link_create(attr, prog); in link_create()
4077 ret = bpf_xdp_link_attach(attr, prog); in link_create()
4086 bpf_prog_put(prog); in link_create()
4299 struct bpf_prog *prog; in bpf_prog_bind_map() local
4310 prog = bpf_prog_get(attr->prog_bind_map.prog_fd); in bpf_prog_bind_map()
4311 if (IS_ERR(prog)) in bpf_prog_bind_map()
4312 return PTR_ERR(prog); in bpf_prog_bind_map()
4320 mutex_lock(&prog->aux->used_maps_mutex); in bpf_prog_bind_map()
4322 used_maps_old = prog->aux->used_maps; in bpf_prog_bind_map()
4324 for (i = 0; i < prog->aux->used_map_cnt; i++) in bpf_prog_bind_map()
4330 used_maps_new = kmalloc_array(prog->aux->used_map_cnt + 1, in bpf_prog_bind_map()
4339 sizeof(used_maps_old[0]) * prog->aux->used_map_cnt); in bpf_prog_bind_map()
4340 used_maps_new[prog->aux->used_map_cnt] = map; in bpf_prog_bind_map()
4342 prog->aux->used_map_cnt++; in bpf_prog_bind_map()
4343 prog->aux->used_maps = used_maps_new; in bpf_prog_bind_map()
4348 mutex_unlock(&prog->aux->used_maps_mutex); in bpf_prog_bind_map()
4353 bpf_prog_put(prog); in bpf_prog_bind_map()