From: Tejun Heo <tj@kernel.org> Date: Fri, 23 Sep 2022 17:19:38 +0000 (-1000) Subject: Merge branch 'for-6.0-fixes' into for-6.1 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=026e14a276c67c8433ecb10e557f0ba23d2b6636;p=linux.git Merge branch 'for-6.0-fixes' into for-6.1 for-6.0 has the following fix for cgroup_get_from_id(). 836ac87d ("cgroup: fix cgroup_get_from_id") which conflicts with the following two commits in for-6.1. 4534dee9 ("cgroup: cgroup: Honor caller's cgroup NS when resolving cgroup id") fa7e439c ("cgroup: Homogenize cgroup_get_from_id() return value") While the resolution is straightforward, the code ends up pretty ugly afterwards. Let's pull for-6.0-fixes into for-6.1 so that the code can be fixed up there. Signed-off-by: Tejun Heo <tj@kernel.org> --- 026e14a276c67c8433ecb10e557f0ba23d2b6636 diff --cc kernel/cgroup/cgroup.c index e24015877d3c5,5f2090d051acb..0d93cd17548c2 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@@ -6079,20 -6059,10 +6082,21 @@@ struct cgroup *cgroup_get_from_id(u64 i cgrp = NULL; rcu_read_unlock(); + put: kernfs_put(kn); + + if (!cgrp) + goto out; + + spin_lock_irq(&css_set_lock); + root_cgrp = current_cgns_cgroup_from_root(&cgrp_dfl_root); + spin_unlock_irq(&css_set_lock); + if (!cgroup_is_descendant(cgrp, root_cgrp)) { + cgroup_put(cgrp); + cgrp = NULL; + } out: - return cgrp; + return cgrp ?: ERR_PTR(-ENOENT); } EXPORT_SYMBOL_GPL(cgroup_get_from_id);