* [PATCH v2 1/3] accel/rocket: Validate BO handle counts on job submission
2026-08-27 17:06 [PATCH v2 0/3] accel/rocket: Fix job submit error handling MoGGuU
@ 2026-08-27 17:06 ` MoGGuU
2026-08-28 2:03 ` Sidong Yang
2026-08-27 17:06 ` [PATCH v2 2/3] accel/rocket: Collect job dependencies before arming MoGGuU
2026-08-27 17:06 ` [PATCH v2 3/3] accel/rocket: Propagate job submission errors MoGGuU
2 siblings, 1 reply; 6+ messages in thread
From: MoGGuU @ 2026-08-27 17:06 UTC (permalink / raw)
To: Tomeu Vizoso
Cc: Oded Gabbay, Jeff Hugo, Sidong Yang, dri-devel, linux-kernel, stable
The input and output BO handle counts are __u32, while GEM lookup and
reservation helpers take int counts. A count above INT_MAX, or a combined
count above INT_MAX, cannot be represented safely at those call sites.
Reject such counts before looking up the BOs.
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Tested-by: Sidong Yang <sidong.yang@furiosa.ai>
Signed-off-by: MoGGuU <Naixumogu@whut.edu.cn>
---
drivers/accel/rocket/rocket_job.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index bb77b6bf0f231..7e3d123afc5ad 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -556,6 +556,12 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
if (job->task_count == 0)
return -EINVAL;
+ /* GEM lookup and reservation helpers take signed object counts. */
+ if (job->in_bo_handle_count > INT_MAX ||
+ job->out_bo_handle_count > INT_MAX ||
+ job->in_bo_handle_count > INT_MAX - job->out_bo_handle_count)
+ return -EINVAL;
+
rjob = kzalloc_obj(*rjob);
if (!rjob)
return -ENOMEM;
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 1/3] accel/rocket: Validate BO handle counts on job submission
2026-08-27 17:06 ` [PATCH v2 1/3] accel/rocket: Validate BO handle counts on job submission MoGGuU
@ 2026-08-28 2:03 ` Sidong Yang
2026-08-28 5:32 ` MoGGuU
0 siblings, 1 reply; 6+ messages in thread
From: Sidong Yang @ 2026-08-28 2:03 UTC (permalink / raw)
To: MoGGuU
Cc: Tomeu Vizoso, Oded Gabbay, Jeff Hugo, dri-devel, linux-kernel, stable
On Fri, Aug 28, 2026 at 01:06:06AM +0800, MoGGuU wrote:
> The input and output BO handle counts are __u32, while GEM lookup and
> reservation helpers take int counts. A count above INT_MAX, or a combined
> count above INT_MAX, cannot be represented safely at those call sites.
>
> Reject such counts before looking up the BOs.
>
> Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
> Cc: stable@vger.kernel.org
> Tested-by: Sidong Yang <sidong.yang@furiosa.ai>
> Signed-off-by: MoGGuU <Naixumogu@whut.edu.cn>
> ---
> drivers/accel/rocket/rocket_job.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index bb77b6bf0f231..7e3d123afc5ad 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -556,6 +556,12 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
> if (job->task_count == 0)
> return -EINVAL;
>
> + /* GEM lookup and reservation helpers take signed object counts. */
> + if (job->in_bo_handle_count > INT_MAX ||
> + job->out_bo_handle_count > INT_MAX ||
> + job->in_bo_handle_count > INT_MAX - job->out_bo_handle_count)
I think checking in/out is okay but the sum of in/out would be checked with check_add_overflow()
in rocket_job_push(). But it only caches overflow UINT_MAX because bo_count is u32. It seems that it
would be good to change bo_count to int.
ㅏ
> + return -EINVAL;
> +
> rjob = kzalloc_obj(*rjob);
> if (!rjob)
> return -ENOMEM;
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 1/3] accel/rocket: Validate BO handle counts on job submission
2026-08-28 2:03 ` Sidong Yang
@ 2026-08-28 5:32 ` MoGGuU
0 siblings, 0 replies; 6+ messages in thread
From: MoGGuU @ 2026-08-28 5:32 UTC (permalink / raw)
To: Sidong Yang
Cc: Tomeu Vizoso, Oded Gabbay, Jeff Hugo, dri-devel, linux-kernel, stable
Thanks, that makes sense.
The two individual checks still need to happen before
drm_gem_objects_lookup(), because its count argument is int. For the
combined count, changing bo_count in rocket_job_push() from u32 to int
makes check_add_overflow() reject sums above INT_MAX before the count is
passed to the reservation helpers.
I addressed this in v3:
https://lore.kernel.org/r/20260828050805.38548-2-Naixumogu@whut.edu.cn
Regards,
MoGGuU
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 2/3] accel/rocket: Collect job dependencies before arming
2026-08-27 17:06 [PATCH v2 0/3] accel/rocket: Fix job submit error handling MoGGuU
2026-08-27 17:06 ` [PATCH v2 1/3] accel/rocket: Validate BO handle counts on job submission MoGGuU
@ 2026-08-27 17:06 ` MoGGuU
2026-08-27 17:06 ` [PATCH v2 3/3] accel/rocket: Propagate job submission errors MoGGuU
2 siblings, 0 replies; 6+ messages in thread
From: MoGGuU @ 2026-08-27 17:06 UTC (permalink / raw)
To: Tomeu Vizoso
Cc: Oded Gabbay, Jeff Hugo, Sidong Yang, dri-devel, linux-kernel, stable
rocket_job_push() arms the scheduler job before collecting its implicit
dependencies. Dependency collection can fail with -ENOMEM, but an armed
job must be pushed and must not be aborted with drm_sched_job_cleanup().
Collect dependencies before taking the scheduler lock and arming the job.
Only operations that cannot fail remain after drm_sched_job_arm().
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Tested-by: Sidong Yang <sidong.yang@furiosa.ai>
Signed-off-by: MoGGuU <Naixumogu@whut.edu.cn>
---
drivers/accel/rocket/rocket_job.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index 7e3d123afc5ad..51e8b43c05131 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -206,19 +206,21 @@ static int rocket_job_push(struct rocket_job *job)
if (ret)
goto err;
+ ret = rocket_acquire_object_fences(job->in_bos, job->in_bo_count,
+ &job->base, false);
+ if (ret)
+ goto err_unlock;
+
+ ret = rocket_acquire_object_fences(job->out_bos, job->out_bo_count,
+ &job->base, true);
+ if (ret)
+ goto err_unlock;
+
scoped_guard(mutex, &rdev->sched_lock) {
drm_sched_job_arm(&job->base);
job->inference_done_fence = dma_fence_get(&job->base.s_fence->finished);
- ret = rocket_acquire_object_fences(job->in_bos, job->in_bo_count, &job->base, false);
- if (ret)
- goto err_unlock;
-
- ret = rocket_acquire_object_fences(job->out_bos, job->out_bo_count, &job->base, true);
- if (ret)
- goto err_unlock;
-
kref_get(&job->refcount); /* put by scheduler job completion */
drm_sched_entity_push_job(&job->base);
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v2 3/3] accel/rocket: Propagate job submission errors
2026-08-27 17:06 [PATCH v2 0/3] accel/rocket: Fix job submit error handling MoGGuU
2026-08-27 17:06 ` [PATCH v2 1/3] accel/rocket: Validate BO handle counts on job submission MoGGuU
2026-08-27 17:06 ` [PATCH v2 2/3] accel/rocket: Collect job dependencies before arming MoGGuU
@ 2026-08-27 17:06 ` MoGGuU
2 siblings, 0 replies; 6+ messages in thread
From: MoGGuU @ 2026-08-27 17:06 UTC (permalink / raw)
To: Tomeu Vizoso
Cc: Oded Gabbay, Jeff Hugo, Sidong Yang, dri-devel, linux-kernel, stable
rocket_ioctl_submit() discards each job's return value and reports success
even when every job fails.
Return the first error and stop submitting the remaining jobs. Jobs queued
before an error remain queued, giving the ioctl ordered partial-submit
semantics.
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Tested-by: Sidong Yang <sidong.yang@furiosa.ai>
Signed-off-by: MoGGuU <Naixumogu@whut.edu.cn>
---
drivers/accel/rocket/rocket_job.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index 51e8b43c05131..964d12475a0d5 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -647,8 +647,11 @@ int rocket_ioctl_submit(struct drm_device *dev, void *data, struct drm_file *fil
}
- for (i = 0; i < args->job_count; i++)
- rocket_ioctl_submit_job(dev, file, &jobs[i]);
+ for (i = 0; i < args->job_count; i++) {
+ ret = rocket_ioctl_submit_job(dev, file, &jobs[i]);
+ if (ret)
+ goto exit;
+ }
exit:
kvfree(jobs);
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread