From: lyude@redhat.com
To: Francesco Magazzu <postadelmaga@gmail.com>,
Danilo Krummrich <dakr@kernel.org>
Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org,
Dan Carpenter <dan.carpenter@linaro.org>,
Karol Herbst <kherbst@redhat.com>
Subject: Re: [PATCH v2 1/4] drm/nouveau/clk: fix list cursor use after loop in nvkm_clk_ustate_update
Date: Thu, 17 Sep 2026 16:56:44 -0400 [thread overview]
Message-ID: <ad023b5df1495ced25aa681d10f57628df41ac13.camel@redhat.com> (raw)
In-Reply-To: <20260712123616.1180830-2-postadelmaga@gmail.com>
This patch looks fine to me, but but if this was posted by Dan
Carpenter originally would you mind switching the authorship over to
their name?
On Sun, 2026-07-12 at 14:36 +0200, Francesco Magazzu wrote:
> If the requested pstate id is not present in the state list (or the
> list is empty, e.g. broken/missing perf tables), the
> list_for_each_entry
> cursor runs off the end of the list and the subsequent
> pstate->pstate != req check dereferences the list head cast to a
> struct nvkm_pstate, which is an out-of-bounds read.
>
> Track whether the entry was actually found instead of inspecting the
> cursor after the loop.
>
> Fixes: 7c8565220697 ("drm/nouveau/clk: implement power state and
> engine clock control in core")
> Signed-off-by: Francesco Magazzu <postadelmaga@gmail.com>
> ---
> Note: essentially the same fix was posted by Dan Carpenter in 2022
> and
> never picked up; the bug is still present in drm-misc-next. Credit
> for
> spotting it goes to him.
> Link: https://lore.kernel.org/dri-devel/YvSkKAdk8Pe0g2K9@kili/
>
> drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> index 572e63846..42f3709e0 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
> @@ -479,13 +479,17 @@ nvkm_clk_ustate_update(struct nvkm_clk *clk,
> int req)
> return -ENOSYS;
>
> if (req != -1 && req != -2) {
> + bool found = false;
> +
> list_for_each_entry(pstate, &clk->states, head) {
> - if (pstate->pstate == req)
> + if (pstate->pstate == req) {
> + found = true;
> break;
> + }
> i++;
> }
>
> - if (pstate->pstate != req)
> + if (!found)
> return -EINVAL;
> req = i;
> }
next prev parent reply other threads:[~2026-09-17 20:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 12:36 [PATCH v2 0/4] drm/nouveau: fix list cursor use after loop in the clk pstate paths Francesco Magazzu
2026-07-12 12:36 ` [PATCH v2 1/4] drm/nouveau/clk: fix list cursor use after loop in nvkm_clk_ustate_update Francesco Magazzu
2026-09-17 20:56 ` lyude [this message]
2026-07-12 12:36 ` [PATCH v2 2/4] drm/nouveau/clk: don't use the pstate cursor after the loop Francesco Magazzu
2026-09-17 21:15 ` lyude
2026-07-12 12:36 ` [PATCH v2 3/4] drm/nouveau/device: " Francesco Magazzu
2026-09-17 21:13 ` lyude
2026-07-12 12:36 ` [PATCH v2 4/4] drm/nouveau/clk: don't clobber reclock status when restoring volt/fan Francesco Magazzu
2026-09-17 21:15 ` lyude
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad023b5df1495ced25aa681d10f57628df41ac13.camel@redhat.com \
--to=lyude@redhat.com \
--cc=dakr@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kherbst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=postadelmaga@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®