[PATCH v4 12/31] accel: ethosu: Validate timeout command offset
From: Rob Herring (Arm)
Date: Thu Oct 29 2026 - 09:41:01 EST
QREAD is supplied by the NPU. Check that its command-stream offset is
word aligned and within the validated command stream before using it to
index the command buffer in the timeout diagnostic.
Fixes: 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Rob Herring (Arm) <robh@xxxxxxxxxx>
---
v4:
- New patch
---
drivers/accel/ethosu/ethosu_job.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/accel/ethosu/ethosu_job.c b/drivers/accel/ethosu/ethosu_job.c
index 3976115902e8..77218bb17006 100644
--- a/drivers/accel/ethosu/ethosu_job.c
+++ b/drivers/accel/ethosu/ethosu_job.c
@@ -345,6 +345,8 @@ static enum drm_gpu_sched_stat ethosu_job_timedout(struct drm_sched_job *bad)
{
struct ethosu_job *job = to_ethosu_job(bad);
struct ethosu_device *dev = job->dev;
+ struct ethosu_validated_cmdstream_info *cmd_info =
+ to_ethosu_bo(job->cmd_bo)->info;
bool running;
int ret;
u32 *bocmds = to_drm_gem_dma_obj(job->cmd_bo)->vaddr;
@@ -367,9 +369,15 @@ static enum drm_gpu_sched_stat ethosu_job_timedout(struct drm_sched_job *bad)
return DRM_GPU_SCHED_STAT_NO_HANG;
}
- dev_err(dev->base.dev, "NPU sched timed out: NPU %s, cmdstream offset 0x%x: 0x%x\n",
- running ? "running" : "stopped",
- cmdaddr, bocmds[cmdaddr / 4]);
+ if (!(cmdaddr & 3) && cmdaddr < cmd_info->cmd_size)
+ dev_err(dev->base.dev,
+ "NPU sched timed out: NPU %s, cmdstream offset 0x%x: 0x%x\n",
+ running ? "running" : "stopped", cmdaddr,
+ bocmds[cmdaddr / 4]);
+ else
+ dev_err(dev->base.dev,
+ "NPU sched timed out: NPU %s, invalid cmdstream offset 0x%x\n",
+ running ? "running" : "stopped", cmdaddr);
drm_sched_stop(&dev->sched, bad);
--
2.53.0