Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v4 1/3] accel/rocket: Validate BO handle counts on job submission
       [not found] <20260828061916.20405-1-Naixumogu@whut.edu.cn>
@ 2026-08-28  6:19 ` MoGGuU
  2026-08-28  6:33   ` Greg KH
  2026-08-28  6:19 ` [PATCH v4 2/3] accel/rocket: Collect job dependencies before arming MoGGuU
  1 sibling, 1 reply; 4+ messages in thread
From: MoGGuU @ 2026-08-28  6:19 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 cannot be
represented safely by the GEM lookup helper.

Reject each count above INT_MAX before looking up the BOs.

rocket_job_push() already uses check_add_overflow() for the combined count,
but stores the result in u32, so it only detects unsigned wraparound. Store
the result in int so sums above INT_MAX are rejected before the count is
passed to the reservation helpers.

Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
Cc: stable@vger.kernel.org
Tested-by: Sidong Yang <sidong.yang@furiosa.ai>
Reviewed-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, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
index bb77b6bf0f231..e6052d1973afa 100644
--- a/drivers/accel/rocket/rocket_job.c
+++ b/drivers/accel/rocket/rocket_job.c
@@ -190,7 +190,7 @@ static int rocket_job_push(struct rocket_job *job)
 	struct rocket_device *rdev = job->rdev;
 	struct drm_gem_object **bos;
 	struct ww_acquire_ctx acquire_ctx;
-	u32 bo_count;
+	int bo_count;
 	int ret = 0;
 
 	if (check_add_overflow(job->in_bo_count, job->out_bo_count, &bo_count))
@@ -556,6 +556,11 @@ static int rocket_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
 	if (job->task_count == 0)
 		return -EINVAL;
 
+	/* GEM lookup takes a signed object count. */
+	if (job->in_bo_handle_count > INT_MAX ||
+	    job->out_bo_handle_count > INT_MAX)
+		return -EINVAL;
+
 	rjob = kzalloc_obj(*rjob);
 	if (!rjob)
 		return -ENOMEM;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 2/3] accel/rocket: Collect job dependencies before arming
       [not found] <20260828061916.20405-1-Naixumogu@whut.edu.cn>
  2026-08-28  6:19 ` [PATCH v4 1/3] accel/rocket: Validate BO handle counts on job submission MoGGuU
@ 2026-08-28  6:19 ` MoGGuU
  1 sibling, 0 replies; 4+ messages in thread
From: MoGGuU @ 2026-08-28  6:19 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>
Reviewed-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 e6052d1973afa..b55e12aecfe64 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 related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 1/3] accel/rocket: Validate BO handle counts on job submission
  2026-08-28  6:19 ` [PATCH v4 1/3] accel/rocket: Validate BO handle counts on job submission MoGGuU
@ 2026-08-28  6:33   ` Greg KH
  2026-08-28  6:41     ` Haoming Gao
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2026-08-28  6:33 UTC (permalink / raw)
  To: MoGGuU
  Cc: Tomeu Vizoso, Oded Gabbay, Jeff Hugo, Sidong Yang, dri-devel,
	linux-kernel, stable

On Fri, Aug 28, 2026 at 02:19:14PM +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 cannot be
> represented safely by the GEM lookup helper.
> 
> Reject each count above INT_MAX before looking up the BOs.
> 
> rocket_job_push() already uses check_add_overflow() for the combined count,
> but stores the result in u32, so it only detects unsigned wraparound. Store
> the result in int so sums above INT_MAX are rejected before the count is
> passed to the reservation helpers.
> 
> Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
> Cc: stable@vger.kernel.org
> Tested-by: Sidong Yang <sidong.yang@furiosa.ai>
> Reviewed-by: Sidong Yang <sidong.yang@furiosa.ai>
> Signed-off-by: MoGGuU <Naixumogu@whut.edu.cn>

Real name please.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 1/3] accel/rocket: Validate BO handle counts on job submission
  2026-08-28  6:33   ` Greg KH
@ 2026-08-28  6:41     ` Haoming Gao
  0 siblings, 0 replies; 4+ messages in thread
From: Haoming Gao @ 2026-08-28  6:41 UTC (permalink / raw)
  To: Greg KH
  Cc: Tomeu Vizoso, Oded Gabbay, Jeff Hugo, Sidong Yang, dri-devel,
	linux-kernel, stable

Thanks for pointing this out.

My real name is Haoming Gao. I have corrected the author identity and
Signed-off-by tags and will resend the series as v5.

Regards,
Haoming Gao

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-28  6:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260828061916.20405-1-Naixumogu@whut.edu.cn>
2026-08-28  6:19 ` [PATCH v4 1/3] accel/rocket: Validate BO handle counts on job submission MoGGuU
2026-08-28  6:33   ` Greg KH
2026-08-28  6:41     ` Haoming Gao
2026-08-28  6:19 ` [PATCH v4 2/3] accel/rocket: Collect job dependencies before arming MoGGuU

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox