mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 04:04:06 +00:00
cgroup: cgroup_get_from_id() must check the looked-up kn is a directory
[ Upstream commitdf02452f3d
] cgroup has to be one kernfs dir, otherwise kernel panic is caused, especially cgroup id is provide from userspace. Reported-by: Marco Patalano <mpatalan@redhat.com> Fixes:6b658c4863
("scsi: cgroup: Add cgroup_get_from_id()") Cc: Muneendra <muneendra.kumar@broadcom.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Acked-by: Mukesh Ojha <quic_mojha@quicinc.com> Cc: stable@vger.kernel.org # v5.14+ Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
26a7d45a6a
commit
19480e9ef2
1 changed files with 4 additions and 1 deletions
|
@ -6025,6 +6025,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);
|
||||
|
@ -6032,7 +6035,7 @@ struct cgroup *cgroup_get_from_id(u64 id)
|
|||
cgrp = NULL;
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
put:
|
||||
kernfs_put(kn);
|
||||
out:
|
||||
return cgrp;
|
||||
|
|
Loading…
Add table
Reference in a new issue