diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index 128028efda64..5a47740c317b 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -226,7 +226,8 @@ static bool hierarchy_allows_attach(struct cgroup *cgrp, */ static int compute_effective_progs(struct cgroup *cgrp, enum cgroup_bpf_attach_type atype, - struct bpf_prog_array **array) + struct bpf_prog_array **array, + gfp_t flags) { struct bpf_prog_array_item *item; struct bpf_prog_array *progs; @@ -241,7 +242,7 @@ static int compute_effective_progs(struct cgroup *cgrp, p = cgroup_parent(p); } while (p); - progs = bpf_prog_array_alloc(cnt, GFP_KERNEL); + progs = bpf_prog_array_alloc(cnt, flags); if (!progs) return -ENOMEM; @@ -308,7 +309,7 @@ int cgroup_bpf_inherit(struct cgroup *cgrp) INIT_LIST_HEAD(&cgrp->bpf.storages); for (i = 0; i < NR; i++) - if (compute_effective_progs(cgrp, i, &arrays[i])) + if (compute_effective_progs(cgrp, i, &arrays[i], GFP_KERNEL)) goto cleanup; for (i = 0; i < NR; i++) @@ -328,7 +329,8 @@ int cgroup_bpf_inherit(struct cgroup *cgrp) } static int update_effective_progs(struct cgroup *cgrp, - enum cgroup_bpf_attach_type atype) + enum cgroup_bpf_attach_type atype, + gfp_t flags) { struct cgroup_subsys_state *css; int err; @@ -340,7 +342,8 @@ static int update_effective_progs(struct cgroup *cgrp, if (percpu_ref_is_zero(&desc->bpf.refcnt)) continue; - err = compute_effective_progs(desc, atype, &desc->bpf.inactive); + err = compute_effective_progs(desc, atype, &desc->bpf.inactive, + flags); if (err) goto cleanup; } @@ -499,7 +502,7 @@ static int __cgroup_bpf_attach(struct cgroup *cgrp, bpf_cgroup_storages_assign(pl->storage, storage); cgrp->bpf.flags[atype] = saved_flags; - err = update_effective_progs(cgrp, atype); + err = update_effective_progs(cgrp, atype, GFP_KERNEL); if (err) goto cleanup; @@ -722,7 +725,7 @@ static int __cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog, pl->prog = NULL; pl->link = NULL; - err = update_effective_progs(cgrp, atype); + err = update_effective_progs(cgrp, atype, GFP_NOIO | __GFP_NOFAIL); if (err) goto cleanup;