Commit df02452f authored by Ming Lei's avatar Ming Lei Committed by Tejun Heo

cgroup: cgroup_get_from_id() must check the looked-up kn is a directory

cgroup has to be one kernfs dir, otherwise kernel panic is caused,
especially cgroup id is provide from userspace.
Reported-by: default avatarMarco Patalano <mpatalan@redhat.com>
Fixes: 6b658c48 ("scsi: cgroup: Add cgroup_get_from_id()")
Cc: Muneendra <muneendra.kumar@broadcom.com>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Acked-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
Cc: stable@vger.kernel.org # v5.14+
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent a81e18e9
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment