[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b013fa2-4ad7-5995-ae6d-52770106272a@quicinc.com>
Date: Fri, 23 Sep 2022 21:13:15 +0530
From: Mukesh Ojha <quic_mojha@...cinc.com>
To: Ming Lei <ming.lei@...hat.com>, Tejun Heo <tj@...nel.org>,
<linux-kernel@...r.kernel.org>
CC: <cgroups@...r.kernel.org>, Marco Patalano <mpatalan@...hat.com>,
Muneendra <muneendra.kumar@...adcom.com>
Subject: Re: [PATCH] cgroup: fix cgroup_get_from_id
Hi,
On 9/23/2022 5:21 PM, Ming Lei wrote:
> 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>
> ---
> kernel/cgroup/cgroup.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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;
Good catch.
Acked-by: Mukesh Ojha <quic_mojha@...cinc.com>
-Mukesh
Powered by blists - more mailing lists