Merge branch 'for-6.0-fixes' into for-6.1
authorTejun Heo <tj@kernel.org>
Fri, 23 Sep 2022 17:19:38 +0000 (07:19 -1000)
committerTejun Heo <tj@kernel.org>
Fri, 23 Sep 2022 17:19:38 +0000 (07:19 -1000)
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>
1  2 
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);