[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220926100814.011227446@linuxfoundation.org>
Date: Mon, 26 Sep 2022 12:12:33 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Marco Patalano <mpatalan@...hat.com>,
Muneendra <muneendra.kumar@...adcom.com>,
Ming Lei <ming.lei@...hat.com>,
Mukesh Ojha <quic_mojha@...cinc.com>, Tejun Heo <tj@...nel.org>
Subject: [PATCH 5.19 164/207] cgroup: cgroup_get_from_id() must check the looked-up kn is a directory
From: Ming Lei <ming.lei@...hat.com>
commit df02452f3df069a59bc9e69c84435bf115cb6e37 upstream.
cgroup has to be one kernfs dir, otherwise kernel panic is caused,
especially cgroup id is provide from userspace.
Reported-by: Marco Patalano <mpatalan@...hat.com>
Fixes: 6b658c4863c1 ("scsi: cgroup: Add cgroup_get_from_id()")
Cc: Muneendra <muneendra.kumar@...adcom.com>
Signed-off-by: Ming Lei <ming.lei@...hat.com>
Acked-by: Mukesh Ojha <quic_mojha@...cinc.com>
Cc: stable@...r.kernel.org # v5.14+
Signed-off-by: Tejun Heo <tj@...nel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
kernel/cgroup/cgroup.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -6026,6 +6026,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);
@@ -6033,7 +6036,7 @@ struct cgroup *cgroup_get_from_id(u64 id
cgrp = NULL;
rcu_read_unlock();
-
+put:
kernfs_put(kn);
out:
return cgrp;
Powered by blists - more mailing lists