提交 df02452f 编写于 作者: M Ming Lei 提交者: 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: NMarco Patalano <mpatalan@redhat.com>
Fixes: 6b658c48 ("scsi: cgroup: Add cgroup_get_from_id()")
Cc: Muneendra <muneendra.kumar@broadcom.com>
Signed-off-by: NMing Lei <ming.lei@redhat.com>
Acked-by: NMukesh Ojha <quic_mojha@quicinc.com>
Cc: stable@vger.kernel.org # v5.14+
Signed-off-by: NTejun Heo <tj@kernel.org>
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部