Lines Matching refs:cgrp

25 void cgroup_bpf_offline(struct cgroup *cgrp)  in cgroup_bpf_offline()  argument
27 cgroup_get(cgrp); in cgroup_bpf_offline()
28 percpu_ref_kill(&cgrp->bpf.refcnt); in cgroup_bpf_offline()
43 struct cgroup *cgrp) in bpf_cgroup_storages_alloc() argument
49 key.cgroup_inode_id = cgroup_id(cgrp); in bpf_cgroup_storages_alloc()
83 struct cgroup *cgrp, in bpf_cgroup_storages_link() argument
89 bpf_cgroup_storage_link(storages[stype], cgrp, attach_type); in bpf_cgroup_storages_link()
110 struct cgroup *p, *cgrp = container_of(work, struct cgroup, in cgroup_bpf_release() local
113 struct list_head *storages = &cgrp->bpf.storages; in cgroup_bpf_release()
120 for (atype = 0; atype < ARRAY_SIZE(cgrp->bpf.progs); atype++) { in cgroup_bpf_release()
121 struct list_head *progs = &cgrp->bpf.progs[atype]; in cgroup_bpf_release()
134 cgrp->bpf.effective[atype], in cgroup_bpf_release()
146 for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p)) in cgroup_bpf_release()
149 percpu_ref_exit(&cgrp->bpf.refcnt); in cgroup_bpf_release()
150 cgroup_put(cgrp); in cgroup_bpf_release()
160 struct cgroup *cgrp = container_of(ref, struct cgroup, bpf.refcnt); in cgroup_bpf_release_fn() local
162 INIT_WORK(&cgrp->bpf.release_work, cgroup_bpf_release); in cgroup_bpf_release_fn()
163 queue_work(system_wq, &cgrp->bpf.release_work); in cgroup_bpf_release_fn()
198 static bool hierarchy_allows_attach(struct cgroup *cgrp, in hierarchy_allows_attach() argument
203 p = cgroup_parent(cgrp); in hierarchy_allows_attach()
227 static int compute_effective_progs(struct cgroup *cgrp, in compute_effective_progs() argument
234 struct cgroup *p = cgrp; in compute_effective_progs()
250 p = cgrp; in compute_effective_progs()
271 static void activate_effective_progs(struct cgroup *cgrp, in activate_effective_progs() argument
275 old_array = rcu_replace_pointer(cgrp->bpf.effective[atype], old_array, in activate_effective_progs()
287 int cgroup_bpf_inherit(struct cgroup *cgrp) in cgroup_bpf_inherit() argument
292 #define NR ARRAY_SIZE(cgrp->bpf.effective) in cgroup_bpf_inherit()
297 ret = percpu_ref_init(&cgrp->bpf.refcnt, cgroup_bpf_release_fn, 0, in cgroup_bpf_inherit()
302 for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p)) in cgroup_bpf_inherit()
306 INIT_LIST_HEAD(&cgrp->bpf.progs[i]); in cgroup_bpf_inherit()
308 INIT_LIST_HEAD(&cgrp->bpf.storages); in cgroup_bpf_inherit()
311 if (compute_effective_progs(cgrp, i, &arrays[i])) in cgroup_bpf_inherit()
315 activate_effective_progs(cgrp, i, arrays[i]); in cgroup_bpf_inherit()
322 for (p = cgroup_parent(cgrp); p; p = cgroup_parent(p)) in cgroup_bpf_inherit()
325 percpu_ref_exit(&cgrp->bpf.refcnt); in cgroup_bpf_inherit()
330 static int update_effective_progs(struct cgroup *cgrp, in update_effective_progs() argument
337 css_for_each_descendant_pre(css, &cgrp->self) { in update_effective_progs()
349 css_for_each_descendant_pre(css, &cgrp->self) { in update_effective_progs()
370 css_for_each_descendant_pre(css, &cgrp->self) { in update_effective_progs()
433 static int __cgroup_bpf_attach(struct cgroup *cgrp, in __cgroup_bpf_attach() argument
462 progs = &cgrp->bpf.progs[atype]; in __cgroup_bpf_attach()
464 if (!hierarchy_allows_attach(cgrp, atype)) in __cgroup_bpf_attach()
467 if (!list_empty(progs) && cgrp->bpf.flags[atype] != saved_flags) in __cgroup_bpf_attach()
483 prog ? : link->link.prog, cgrp)) in __cgroup_bpf_attach()
500 cgrp->bpf.flags[atype] = saved_flags; in __cgroup_bpf_attach()
502 err = update_effective_progs(cgrp, atype); in __cgroup_bpf_attach()
510 bpf_cgroup_storages_link(new_storage, cgrp, type); in __cgroup_bpf_attach()
526 static int cgroup_bpf_attach(struct cgroup *cgrp, in cgroup_bpf_attach() argument
535 ret = __cgroup_bpf_attach(cgrp, prog, replace_prog, link, type, flags); in cgroup_bpf_attach()
543 static void replace_effective_prog(struct cgroup *cgrp, in replace_effective_prog() argument
555 css_for_each_descendant_pre(css, &cgrp->self) { in replace_effective_prog()
594 static int __cgroup_bpf_replace(struct cgroup *cgrp, in __cgroup_bpf_replace() argument
608 progs = &cgrp->bpf.progs[atype]; in __cgroup_bpf_replace()
623 replace_effective_prog(cgrp, atype, link); in __cgroup_bpf_replace()
695 static int __cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog, in __cgroup_bpf_detach() argument
709 progs = &cgrp->bpf.progs[atype]; in __cgroup_bpf_detach()
710 flags = cgrp->bpf.flags[atype]; in __cgroup_bpf_detach()
725 err = update_effective_progs(cgrp, atype); in __cgroup_bpf_detach()
734 cgrp->bpf.flags[atype] = 0; in __cgroup_bpf_detach()
747 static int cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog, in cgroup_bpf_detach() argument
753 ret = __cgroup_bpf_detach(cgrp, prog, NULL, type); in cgroup_bpf_detach()
759 static int __cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr, in __cgroup_bpf_query() argument
775 progs = &cgrp->bpf.progs[atype]; in __cgroup_bpf_query()
776 flags = cgrp->bpf.flags[atype]; in __cgroup_bpf_query()
778 effective = rcu_dereference_protected(cgrp->bpf.effective[atype], in __cgroup_bpf_query()
817 static int cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr, in cgroup_bpf_query() argument
823 ret = __cgroup_bpf_query(cgrp, attr, uattr); in cgroup_bpf_query()
832 struct cgroup *cgrp; in cgroup_bpf_prog_attach() local
835 cgrp = cgroup_get_from_fd(attr->target_fd); in cgroup_bpf_prog_attach()
836 if (IS_ERR(cgrp)) in cgroup_bpf_prog_attach()
837 return PTR_ERR(cgrp); in cgroup_bpf_prog_attach()
843 cgroup_put(cgrp); in cgroup_bpf_prog_attach()
848 ret = cgroup_bpf_attach(cgrp, prog, replace_prog, NULL, in cgroup_bpf_prog_attach()
853 cgroup_put(cgrp); in cgroup_bpf_prog_attach()
860 struct cgroup *cgrp; in cgroup_bpf_prog_detach() local
863 cgrp = cgroup_get_from_fd(attr->target_fd); in cgroup_bpf_prog_detach()
864 if (IS_ERR(cgrp)) in cgroup_bpf_prog_detach()
865 return PTR_ERR(cgrp); in cgroup_bpf_prog_detach()
871 ret = cgroup_bpf_detach(cgrp, prog, attr->attach_type); in cgroup_bpf_prog_detach()
875 cgroup_put(cgrp); in cgroup_bpf_prog_detach()
974 struct cgroup *cgrp; in cgroup_bpf_link_attach() local
980 cgrp = cgroup_get_from_fd(attr->link_create.target_fd); in cgroup_bpf_link_attach()
981 if (IS_ERR(cgrp)) in cgroup_bpf_link_attach()
982 return PTR_ERR(cgrp); in cgroup_bpf_link_attach()
991 link->cgroup = cgrp; in cgroup_bpf_link_attach()
1000 err = cgroup_bpf_attach(cgrp, NULL, NULL, link, in cgroup_bpf_link_attach()
1010 cgroup_put(cgrp); in cgroup_bpf_link_attach()
1017 struct cgroup *cgrp; in cgroup_bpf_prog_query() local
1020 cgrp = cgroup_get_from_fd(attr->query.target_fd); in cgroup_bpf_prog_query()
1021 if (IS_ERR(cgrp)) in cgroup_bpf_prog_query()
1022 return PTR_ERR(cgrp); in cgroup_bpf_prog_query()
1024 ret = cgroup_bpf_query(cgrp, attr, uattr); in cgroup_bpf_prog_query()
1026 cgroup_put(cgrp); in cgroup_bpf_prog_query()
1060 struct cgroup *cgrp; in __cgroup_bpf_run_filter_skb() local
1069 cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); in __cgroup_bpf_run_filter_skb()
1079 cgrp->bpf.effective[atype], skb, __bpf_prog_run_save_cb); in __cgroup_bpf_run_filter_skb()
1081 ret = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[atype], skb, in __cgroup_bpf_run_filter_skb()
1109 struct cgroup *cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); in __cgroup_bpf_run_filter_sk() local
1112 ret = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[atype], sk, bpf_prog_run); in __cgroup_bpf_run_filter_sk()
1144 struct cgroup *cgrp; in __cgroup_bpf_run_filter_sock_addr() local
1158 cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); in __cgroup_bpf_run_filter_sock_addr()
1159 ret = BPF_PROG_RUN_ARRAY_CG_FLAGS(cgrp->bpf.effective[atype], &ctx, in __cgroup_bpf_run_filter_sock_addr()
1186 struct cgroup *cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); in __cgroup_bpf_run_filter_sock_ops() local
1189 ret = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[atype], sock_ops, in __cgroup_bpf_run_filter_sock_ops()
1198 struct cgroup *cgrp; in __cgroup_bpf_check_dev_permission() local
1207 cgrp = task_dfl_cgroup(current); in __cgroup_bpf_check_dev_permission()
1208 allow = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[atype], &ctx, in __cgroup_bpf_check_dev_permission()
1313 struct cgroup *cgrp; in __cgroup_bpf_run_filter_sysctl() local
1339 cgrp = task_dfl_cgroup(current); in __cgroup_bpf_run_filter_sysctl()
1340 ret = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[atype], &ctx, bpf_prog_run); in __cgroup_bpf_run_filter_sysctl()
1357 static bool __cgroup_bpf_prog_array_is_empty(struct cgroup *cgrp, in __cgroup_bpf_prog_array_is_empty() argument
1364 prog_array = rcu_dereference(cgrp->bpf.effective[attach_type]); in __cgroup_bpf_prog_array_is_empty()
1420 struct cgroup *cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); in __cgroup_bpf_run_filter_setsockopt() local
1433 if (__cgroup_bpf_prog_array_is_empty(cgrp, CGROUP_SETSOCKOPT)) in __cgroup_bpf_run_filter_setsockopt()
1454 ret = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[CGROUP_SETSOCKOPT], in __cgroup_bpf_run_filter_setsockopt()
1515 struct cgroup *cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); in __cgroup_bpf_run_filter_getsockopt() local
1529 if (__cgroup_bpf_prog_array_is_empty(cgrp, CGROUP_GETSOCKOPT)) in __cgroup_bpf_run_filter_getsockopt()
1564 ret = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[CGROUP_GETSOCKOPT], in __cgroup_bpf_run_filter_getsockopt()
1605 struct cgroup *cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); in __cgroup_bpf_run_filter_getsockopt_kern() local
1625 ret = BPF_PROG_RUN_ARRAY_CG(cgrp->bpf.effective[CGROUP_GETSOCKOPT], in __cgroup_bpf_run_filter_getsockopt_kern()