mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] accel/rocket: Fix use-after-free in rocket_ioctl_create_bo()
@ 2026-09-17 18:00 Wentao Liang
  2026-10-02 16:16 ` Jeff Hugo
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 18:00 UTC (permalink / raw)
  To: dri-devel; +Cc: jeff.hugo, linux-kernel, ogabbay, tomeu, Wentao Liang, stable

If drm_gem_handle_create() fails, it takes and then releases its handle
reference internally, leaving the creator's reference as the only one
held.  The drm_gem_object_put() then drops that last reference, freeing
the object via rocket_gem_bo_free(), and the subsequent goto err makes
drm_gem_shmem_object_free() run on the already freed object.

Return directly on the error instead: the put has already released
everything the function acquired at this point, so there is nothing
left to clean up on the err path.

Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/accel/rocket/rocket_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
index 91095d1b3066..521819041475 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -82,7 +82,7 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
 	ret = drm_gem_handle_create(file, gem_obj, &args->handle);
 	drm_gem_object_put(gem_obj);
 	if (ret)
-		goto err;
+		return ret;
 
 	sgt = drm_gem_shmem_get_pages_sgt(shmem_obj);
 	if (IS_ERR(sgt)) {
-- 
2.34.1


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

* Re: [PATCH] accel/rocket: Fix use-after-free in rocket_ioctl_create_bo()
  2026-09-17 18:00 [PATCH] accel/rocket: Fix use-after-free in rocket_ioctl_create_bo() Wentao Liang
@ 2026-10-02 16:16 ` Jeff Hugo
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Hugo @ 2026-10-02 16:16 UTC (permalink / raw)
  To: Wentao Liang, dri-devel; +Cc: linux-kernel, ogabbay, tomeu, stable

On 9/17/2026 12:00 PM, Wentao Liang wrote:
> If drm_gem_handle_create() fails, it takes and then releases its handle
> reference internally, leaving the creator's reference as the only one
> held.  The drm_gem_object_put() then drops that last reference, freeing
> the object via rocket_gem_bo_free(), and the subsequent goto err makes
> drm_gem_shmem_object_free() run on the already freed object.
> 
> Return directly on the error instead: the put has already released
> everything the function acquired at this point, so there is nothing
> left to clean up on the err path.
> 
> Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>   drivers/accel/rocket/rocket_gem.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
> index 91095d1b3066..521819041475 100644
> --- a/drivers/accel/rocket/rocket_gem.c
> +++ b/drivers/accel/rocket/rocket_gem.c
> @@ -82,7 +82,7 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
>   	ret = drm_gem_handle_create(file, gem_obj, &args->handle);
>   	drm_gem_object_put(gem_obj);
>   	if (ret)
> -		goto err;
> +		return ret;
>   
>   	sgt = drm_gem_shmem_get_pages_sgt(shmem_obj);
>   	if (IS_ERR(sgt)) {


Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com>

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

end of thread, other threads:[~2026-10-02 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 18:00 [PATCH] accel/rocket: Fix use-after-free in rocket_ioctl_create_bo() Wentao Liang
2026-10-02 16:16 ` Jeff Hugo

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

all inboxes | Powered by JetHome®