From: Alessio Belle <Alessio.Belle@imgtec.com>
To: "hppiscas@163.com" <hppiscas@163.com>
Cc: Luigi Santivetti <Luigi.Santivetti@imgtec.com>,
"imagination@lists.freedesktop.org"
<imagination@lists.freedesktop.org>,
"simona@ffwll.ch" <simona@ffwll.ch>,
"matt.coster@imgtec.com" <matt.coster@imgtec.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"donald.robson@imgtec.com" <donald.robson@imgtec.com>,
"airlied@gmail.com" <airlied@gmail.com>,
"tzimmermann@suse.de" <tzimmermann@suse.de>,
Frank Binns <Frank.Binns@imgtec.com>,
"maarten.lankhorst@linux.intel.com"
<maarten.lankhorst@linux.intel.com>,
"sarah.walker@imgtec.com" <sarah.walker@imgtec.com>,
"mripard@kernel.org" <mripard@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"boris.brezillon@collabora.com" <boris.brezillon@collabora.com>
Subject: Re: [PATCH v2] drm/imagination: clamp freelist reconstruction requests
Date: Thu, 24 Sep 2026 08:21:25 +0000 [thread overview]
Message-ID: <a5cabd93fa2950b339433f8a452bd92661396e7d.camel@imgtec.com> (raw)
In-Reply-To: <20260920034329.16614-1-hppiscas@163.com>
On Sun, 2026-09-20 at 11:43 +0800, Pengpeng Hou wrote:
> The firmware reconstruction count controls accesses to the request's
> fixed freelist ID array and the copy into the fixed response array.
> Neither access currently bounds the count to those protocol arrays.
>
> Clamp the count to the request capacity, which is shared by the response
> layout, and use that count consistently for reconstruction and response
> publication. Keep the firmware recovery exchange instead of dropping an
> oversized request without a response, as discussed with the firmware
> maintainer.
>
> The issue was found by our static-analysis tool.
>
> Fixes: 6eedddab733b ("drm/imagination: Implement free list and HWRT create and destroy ioctls")
> Assisted-by: gpt 5
> Signed-off-by: Pengpeng Hou <hppiscas@163.com>
Reviewed-by: Alessio Belle <alessio.belle@imgtec.com>
Thanks,
Alessio
> ---
> Changes since v1:
> https://lore.kernel.org/all/20260813152759.35856-1-pengpeng@iscas.ac.cn/
> Include drm_print.h for drm_warn_once(), brace the multiline warning
> block, and shorten its text as Alessio requested.
>
> drivers/gpu/drm/imagination/pvr_free_list.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/imagination/pvr_free_list.c b/drivers/gpu/drm/imagination/pvr_free_list.c
> index e85cac83834c..faf5e586d8dc 100644
> --- a/drivers/gpu/drm/imagination/pvr_free_list.c
> +++ b/drivers/gpu/drm/imagination/pvr_free_list.c
> @@ -8,6 +8,7 @@
> #include "pvr_vm.h"
>
> #include <drm/drm_gem.h>
> +#include <drm/drm_print.h>
> #include <linux/slab.h>
> #include <linux/xarray.h>
> #include <uapi/drm/pvr_drm.h>
> @@ -612,13 +613,21 @@ pvr_free_list_process_reconstruct_req(struct pvr_device *pvr_dev,
> };
> struct rogue_fwif_freelists_reconstruction_data *resp =
> &resp_cmd.cmd_data.free_lists_reconstruction_data;
> + u32 count = min_t(u32, req->freelist_count,
> + ARRAY_SIZE(req->freelist_ids));
>
> - for (u32 i = 0; i < req->freelist_count; i++)
> + if (count != req->freelist_count) {
> + drm_warn_once(from_pvr_device(pvr_dev),
> + "Requested reconstruction of %u freelists, limiting to %u\n",
> + req->freelist_count, count);
> + }
> +
> + for (u32 i = 0; i < count; i++)
> pvr_free_list_reconstruct(pvr_dev, req->freelist_ids[i]);
>
> - resp->freelist_count = req->freelist_count;
> + resp->freelist_count = count;
> memcpy(resp->freelist_ids, req->freelist_ids,
> - req->freelist_count * sizeof(resp->freelist_ids[0]));
> + count * sizeof(resp->freelist_ids[0]));
>
> WARN_ON(pvr_kccb_send_cmd(pvr_dev, &resp_cmd, NULL));
> }
>
> base-commit: 518e5b794c06c0f0eb40df3e202274a66202c137
next prev parent reply other threads:[~2026-09-24 8:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 3:43 Pengpeng Hou
2026-09-24 8:21 ` Alessio Belle [this message]
2026-09-24 9:39 ` Brajesh Gupta
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=a5cabd93fa2950b339433f8a452bd92661396e7d.camel@imgtec.com \
--to=alessio.belle@imgtec.com \
--cc=Frank.Binns@imgtec.com \
--cc=Luigi.Santivetti@imgtec.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=donald.robson@imgtec.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hppiscas@163.com \
--cc=imagination@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matt.coster@imgtec.com \
--cc=mripard@kernel.org \
--cc=sarah.walker@imgtec.com \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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®