summaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-09-24 08:36:10 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2022-09-24 08:36:10 -0700
commit1772094f12a7b180aa9ab849586f891b14d06d1f (patch)
tree588e469443afcf332d0c8a5a0b5372187259dc2a /kernel
parentaae8dda51964ff9d3f1dc96528b853826667efad (diff)
parentdf02452f3df069a59bc9e69c84435bf115cb6e37 (diff)
downloadlinux-stable-1772094f12a7b180aa9ab849586f891b14d06d1f.tar.gz
linux-stable-1772094f12a7b180aa9ab849586f891b14d06d1f.tar.bz2
linux-stable-1772094f12a7b180aa9ab849586f891b14d06d1f.zip
Merge tag 'cgroup-for-6.0-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup fixes from Tejun Heo: - Add Waiman Long as a cpuset maintainer - cgroup_get_from_id() could be fed a kernfs ID which doesn't point to a cgroup directory but a knob file and then crash. Error out if the lookup kernfs_node isn't a directory. * tag 'cgroup-for-6.0-rc6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: cgroup_get_from_id() must check the looked-up kn is a directory cpuset: Add Waiman Long as a cpuset maintainer
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup/cgroup.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index e4bb5d57f4d1..5f2090d051ac 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -6049,6 +6049,9 @@ struct cgroup *cgroup_get_from_id(u64 id)
if (!kn)
goto out;
+ if (kernfs_type(kn) != KERNFS_DIR)
+ goto put;
+
rcu_read_lock();
cgrp = rcu_dereference(*(void __rcu __force **)&kn->priv);
@@ -6056,7 +6059,7 @@ struct cgroup *cgroup_get_from_id(u64 id)
cgrp = NULL;
rcu_read_unlock();
-
+put:
kernfs_put(kn);
out:
return cgrp;