public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] Fix dma_resv_wait_timeout() return handling in rocket/panfrost ioctls
@ 2026-04-19  7:17 Gyeyoung Baek
  2026-04-19  7:17 ` [PATCH v1 1/2] accel/rocket: Fix prep_bo ioctl leaking positive return from dma_resv_wait_timeout() Gyeyoung Baek
  2026-04-19  7:17 ` [PATCH v1 2/2] drm/panfrost: Fix wait_bo " Gyeyoung Baek
  0 siblings, 2 replies; 6+ messages in thread
From: Gyeyoung Baek @ 2026-04-19  7:17 UTC (permalink / raw)
  To: Tomeu Vizoso, Boris Brezillon, Rob Herring, Steven Price,
	Adrián Larumbe
  Cc: Oded Gabbay, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel,
	Gyeyoung Baek

dma_resv_wait_timeout() returns a positive 'long' (remaining jiffies)
on success, which is truncated to 'int`.
So userspace interpret that as an error.

Each patch explicitly sets `ret` to 0 on the
success path.

Gyeyoung Baek (2):
  accel/rocket: Fix prep_bo ioctl leaking positive return from
    dma_resv_wait_timeout()
  drm/panfrost: Fix wait_bo ioctl leaking positive return from
    dma_resv_wait_timeout()

 drivers/accel/rocket/rocket_gem.c       | 2 ++
 drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++
 2 files changed, 4 insertions(+)

-- 
2.43.0


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

* [PATCH v1 1/2] accel/rocket: Fix prep_bo ioctl leaking positive return from dma_resv_wait_timeout()
  2026-04-19  7:17 [PATCH v1 0/2] Fix dma_resv_wait_timeout() return handling in rocket/panfrost ioctls Gyeyoung Baek
@ 2026-04-19  7:17 ` Gyeyoung Baek
  2026-04-20 14:12   ` Tomeu Vizoso
  2026-04-19  7:17 ` [PATCH v1 2/2] drm/panfrost: Fix wait_bo " Gyeyoung Baek
  1 sibling, 1 reply; 6+ messages in thread
From: Gyeyoung Baek @ 2026-04-19  7:17 UTC (permalink / raw)
  To: Tomeu Vizoso, Boris Brezillon, Rob Herring, Steven Price,
	Adrián Larumbe
  Cc: Oded Gabbay, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel,
	Gyeyoung Baek, stable

dma_resv_wait_timeout() returns a positive 'remaining jiffies' value
on success, 0 on timeout, and -errno on failure.

rocket_ioctl_prep_bo() returns this 'long' result from an int-typed
ioctl handler, so positive values reach userspace as bogus errors.
Explicitly set ret to 0 on the success path.

Fixes: 525ad89dd904 ("accel/rocket: Add IOCTLs for synchronizing memory accesses")
Cc: stable@vger.kernel.org
Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
---
 drivers/accel/rocket/rocket_gem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
index b6a385d2e..c80847192 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -145,6 +145,8 @@ int rocket_ioctl_prep_bo(struct drm_device *dev, void *data, struct drm_file *fi
 	ret = dma_resv_wait_timeout(gem_obj->resv, DMA_RESV_USAGE_WRITE, true, timeout);
 	if (!ret)
 		ret = timeout ? -ETIMEDOUT : -EBUSY;
+	else if (ret > 0)
+		ret = 0;
 
 	shmem_obj = &to_rocket_bo(gem_obj)->base;
 
-- 
2.43.0


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

* [PATCH v1 2/2] drm/panfrost: Fix wait_bo ioctl leaking positive return from dma_resv_wait_timeout()
  2026-04-19  7:17 [PATCH v1 0/2] Fix dma_resv_wait_timeout() return handling in rocket/panfrost ioctls Gyeyoung Baek
  2026-04-19  7:17 ` [PATCH v1 1/2] accel/rocket: Fix prep_bo ioctl leaking positive return from dma_resv_wait_timeout() Gyeyoung Baek
@ 2026-04-19  7:17 ` Gyeyoung Baek
  2026-04-20  8:08   ` Boris Brezillon
  2026-04-20 11:18   ` Steven Price
  1 sibling, 2 replies; 6+ messages in thread
From: Gyeyoung Baek @ 2026-04-19  7:17 UTC (permalink / raw)
  To: Tomeu Vizoso, Boris Brezillon, Rob Herring, Steven Price,
	Adrián Larumbe
  Cc: Oded Gabbay, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel,
	Gyeyoung Baek, stable

dma_resv_wait_timeout() returns a positive 'remaining jiffies' value
on success, 0 on timeout, and -errno on failure.

panfrost_ioctl_wait_bo() returns this 'long' result from an int-typed
ioctl handler, so positive values reach userspace as bogus errors.
Explicitly set ret to 0 on the success path.

Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gyeyoung Baek <gye976@gmail.com>
---
 drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
index 3d0bdba2a..784e36d72 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -390,6 +390,8 @@ panfrost_ioctl_wait_bo(struct drm_device *dev, void *data,
 				    true, timeout);
 	if (!ret)
 		ret = timeout ? -ETIMEDOUT : -EBUSY;
+	else if (ret > 0)
+		ret = 0;
 
 	drm_gem_object_put(gem_obj);
 
-- 
2.43.0


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

* Re: [PATCH v1 2/2] drm/panfrost: Fix wait_bo ioctl leaking positive return from dma_resv_wait_timeout()
  2026-04-19  7:17 ` [PATCH v1 2/2] drm/panfrost: Fix wait_bo " Gyeyoung Baek
@ 2026-04-20  8:08   ` Boris Brezillon
  2026-04-20 11:18   ` Steven Price
  1 sibling, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2026-04-20  8:08 UTC (permalink / raw)
  To: Gyeyoung Baek
  Cc: Tomeu Vizoso, Rob Herring, Steven Price, Adrián Larumbe,
	Oded Gabbay, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel, stable

On Sun, 19 Apr 2026 16:17:16 +0900
Gyeyoung Baek <gye976@gmail.com> wrote:

> dma_resv_wait_timeout() returns a positive 'remaining jiffies' value
> on success, 0 on timeout, and -errno on failure.
> 
> panfrost_ioctl_wait_bo() returns this 'long' result from an int-typed
> ioctl handler, so positive values reach userspace as bogus errors.
> Explicitly set ret to 0 on the success path.
> 
> Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gyeyoung Baek <gye976@gmail.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
> index 3d0bdba2a..784e36d72 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
> @@ -390,6 +390,8 @@ panfrost_ioctl_wait_bo(struct drm_device *dev, void *data,
>  				    true, timeout);
>  	if (!ret)
>  		ret = timeout ? -ETIMEDOUT : -EBUSY;
> +	else if (ret > 0)
> +		ret = 0;
>  
>  	drm_gem_object_put(gem_obj);
>  


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

* Re: [PATCH v1 2/2] drm/panfrost: Fix wait_bo ioctl leaking positive return from dma_resv_wait_timeout()
  2026-04-19  7:17 ` [PATCH v1 2/2] drm/panfrost: Fix wait_bo " Gyeyoung Baek
  2026-04-20  8:08   ` Boris Brezillon
@ 2026-04-20 11:18   ` Steven Price
  1 sibling, 0 replies; 6+ messages in thread
From: Steven Price @ 2026-04-20 11:18 UTC (permalink / raw)
  To: Gyeyoung Baek, Tomeu Vizoso, Boris Brezillon, Rob Herring,
	Adrián Larumbe
  Cc: Oded Gabbay, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel, stable

On 19/04/2026 08:17, Gyeyoung Baek wrote:
> dma_resv_wait_timeout() returns a positive 'remaining jiffies' value
> on success, 0 on timeout, and -errno on failure.
> 
> panfrost_ioctl_wait_bo() returns this 'long' result from an int-typed
> ioctl handler, so positive values reach userspace as bogus errors.
> Explicitly set ret to 0 on the success path.
> 
> Fixes: f3ba91228e8e ("drm/panfrost: Add initial panfrost driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gyeyoung Baek <gye976@gmail.com>

Reviewed-by: Steven Price <steven.price@arm.com>

> ---
>  drivers/gpu/drm/panfrost/panfrost_drv.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
> index 3d0bdba2a..784e36d72 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
> @@ -390,6 +390,8 @@ panfrost_ioctl_wait_bo(struct drm_device *dev, void *data,
>  				    true, timeout);
>  	if (!ret)
>  		ret = timeout ? -ETIMEDOUT : -EBUSY;
> +	else if (ret > 0)
> +		ret = 0;
>  
>  	drm_gem_object_put(gem_obj);
>  


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

* Re: [PATCH v1 1/2] accel/rocket: Fix prep_bo ioctl leaking positive return from dma_resv_wait_timeout()
  2026-04-19  7:17 ` [PATCH v1 1/2] accel/rocket: Fix prep_bo ioctl leaking positive return from dma_resv_wait_timeout() Gyeyoung Baek
@ 2026-04-20 14:12   ` Tomeu Vizoso
  0 siblings, 0 replies; 6+ messages in thread
From: Tomeu Vizoso @ 2026-04-20 14:12 UTC (permalink / raw)
  To: Gyeyoung Baek
  Cc: Boris Brezillon, Rob Herring, Steven Price, Adrián Larumbe,
	Oded Gabbay, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, dri-devel, linux-kernel, stable

On Sun, Apr 19, 2026 at 9:19 AM Gyeyoung Baek <gye976@gmail.com> wrote:
>
> dma_resv_wait_timeout() returns a positive 'remaining jiffies' value
> on success, 0 on timeout, and -errno on failure.
>
> rocket_ioctl_prep_bo() returns this 'long' result from an int-typed
> ioctl handler, so positive values reach userspace as bogus errors.
> Explicitly set ret to 0 on the success path.
>
> Fixes: 525ad89dd904 ("accel/rocket: Add IOCTLs for synchronizing memory accesses")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gyeyoung Baek <gye976@gmail.com>

Reviewed-by: Tomeu Vizoso <tomeu@tomeuvizoso.net>

Thanks!

Tomeu

> ---
>  drivers/accel/rocket/rocket_gem.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
> index b6a385d2e..c80847192 100644
> --- a/drivers/accel/rocket/rocket_gem.c
> +++ b/drivers/accel/rocket/rocket_gem.c
> @@ -145,6 +145,8 @@ int rocket_ioctl_prep_bo(struct drm_device *dev, void *data, struct drm_file *fi
>         ret = dma_resv_wait_timeout(gem_obj->resv, DMA_RESV_USAGE_WRITE, true, timeout);
>         if (!ret)
>                 ret = timeout ? -ETIMEDOUT : -EBUSY;
> +       else if (ret > 0)
> +               ret = 0;
>
>         shmem_obj = &to_rocket_bo(gem_obj)->base;
>
> --
> 2.43.0
>

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

end of thread, other threads:[~2026-04-20 14:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-19  7:17 [PATCH v1 0/2] Fix dma_resv_wait_timeout() return handling in rocket/panfrost ioctls Gyeyoung Baek
2026-04-19  7:17 ` [PATCH v1 1/2] accel/rocket: Fix prep_bo ioctl leaking positive return from dma_resv_wait_timeout() Gyeyoung Baek
2026-04-20 14:12   ` Tomeu Vizoso
2026-04-19  7:17 ` [PATCH v1 2/2] drm/panfrost: Fix wait_bo " Gyeyoung Baek
2026-04-20  8:08   ` Boris Brezillon
2026-04-20 11:18   ` Steven Price

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