From: "Rob Herring (Arm)" <robh@kernel.org>
To: Tomeu Vizoso <tomeu@tomeuvizoso.net>, Oded Gabbay <ogabbay@kernel.org>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH] accel: ethosu: Validate SRAM size on submit
Date: Wed, 13 May 2026 13:54:34 -0500 [thread overview]
Message-ID: <20260513185434.1667045-1-robh@kernel.org> (raw)
Regions with a BO are checked against the BO size, but the SRAM
region is not. The SRAM region doesn't have a BO, but the command stream
region size should be checked against the SRAM size. The job's
"sram_size" isn't useful here because an evil userspace could lie about
the size.
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
drivers/accel/ethosu/ethosu_job.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c
index ec85f4156744..e7b07cdbcced 100644
--- a/drivers/accel/ethosu/ethosu_job.c
+++ b/drivers/accel/ethosu/ethosu_job.c
@@ -417,9 +417,21 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
struct drm_gem_object *gem;
/* Can only omit a BO handle if the region is not used or used for SRAM */
- if (!job->region_bo_handles[i] &&
- (!cmd_info->region_size[i] || (i == ETHOSU_SRAM_REGION && job->sram_size)))
- continue;
+ if (!job->region_bo_handles[i]) {
+ if (!cmd_info->region_size[i])
+ continue;
+ if (i == ETHOSU_SRAM_REGION) {
+ if (cmd_info->region_size[i] <= edev->npu_info.sram_size)
+ continue;
+
+ dev_err(dev->dev,
+ "cmd stream region %d size greater than SRAM size (%llu > %u)\n",
+ i, cmd_info->region_size[i],
+ edev->npu_info.sram_size);
+ ret = -EINVAL;
+ goto out_cleanup_job;
+ }
+ }
if (job->region_bo_handles[i] && !cmd_info->region_size[i]) {
dev_err(dev->dev,
--
2.53.0
reply other threads:[~2026-05-13 18:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260513185434.1667045-1-robh@kernel.org \
--to=robh@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=tomeu@tomeuvizoso.net \
/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