All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] accel/rocket: Reject zero-sized BOs in rocket_ioctl_create_bo()
@ 2026-11-30  2:56 Hu Xinyao
  2026-11-30  3:09 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Hu Xinyao @ 2026-11-30  2:56 UTC (permalink / raw)
  To: Tomeu Vizoso, Oded Gabbay; +Cc: Heiko Stuebner, dri-devel, linux-kernel

rocket_ioctl_create_bo() passes args->size directly to
drm_gem_shmem_create() and drm_gem_shmem_get_pages_sgt(). When
args->size is zero, drm_gem_get_pages() allocates a zero-element page
array (ZERO_SIZE_PTR), and drm_gem_shmem_get_sg_table() calls
sg_alloc_append_table_from_pages() with n_pages == 0, which initializes
chunks = 1 and dereferences pages[0].

Reject zero-sized buffer objects with -EINVAL.

Fixes: 658ebeac3351 ("accel/rocket: Add IOCTL for BO creation")
Cc: stable@vger.kernel.org
Signed-off-by: Hu Xinyao <huxinyao@kylinsec.com.cn>
---
 drivers/accel/rocket/rocket_gem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/accel/rocket/rocket_gem.c b/drivers/accel/rocket/rocket_gem.c
index 8f802df..be9c217 100644
--- a/drivers/accel/rocket/rocket_gem.c
+++ b/drivers/accel/rocket/rocket_gem.c
@@ -68,6 +68,9 @@ int rocket_ioctl_create_bo(struct drm_device *dev, void *data, struct drm_file *
 	struct sg_table *sgt;
 	int ret;
 
+	if (!args->size)
+		return -EINVAL;
+
 	shmem_obj = drm_gem_shmem_create(dev, args->size);
 	if (IS_ERR(shmem_obj))
 		return PTR_ERR(shmem_obj);
-- 
2.43.0


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

* Re: [PATCH] accel/rocket: Reject zero-sized BOs in rocket_ioctl_create_bo()
  2026-11-30  2:56 [PATCH] accel/rocket: Reject zero-sized BOs in rocket_ioctl_create_bo() Hu Xinyao
@ 2026-11-30  3:09 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30  3:09 UTC (permalink / raw)
  To: Hu Xinyao; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] accel/rocket: inaccurate commit message on zero-size BO
  failure path
--

commit 16a770184fb1378b86d900df5443b48c32c09ac4
Author: Hu Xinyao <huxinyao@kylinsec.com.cn>

accel/rocket: Reject zero-sized BOs in rocket_ioctl_create_bo()

This commit rejects zero-sized buffer objects in rocket_ioctl_create_bo()
with -EINVAL before calling drm_gem_shmem_create().

> rocket_ioctl_create_bo() passes args->size directly to
> drm_gem_shmem_create() and drm_gem_shmem_get_pages_sgt(). When
> args->size is zero, drm_gem_get_pages() allocates a zero-element page
> array (ZERO_SIZE_PTR), and drm_gem_shmem_get_sg_table() calls
> sg_alloc_append_table_from_pages() with n_pages == 0, which initializes
> chunks = 1 and dereferences pages[0].

[Severity: Medium]
Is the commit message accurate about how a zero-sized request fails?

When args->size is 0, drm_gem_shmem_create() calls __drm_gem_shmem_init()
-> drm_gem_create_mmap_offset() -> drm_vma_offset_add() ->
drm_mm_insert_node_in_range() with size == 0, which rejects the 0-page
VMA offset allocation and returns -ENOSPC.  rocket_ioctl_create_bo()
returns ERR_PTR(-ENOSPC) from drm_gem_shmem_create() without reaching
drm_gem_shmem_get_pages_sgt().  The patch changes the return value from
-ENOSPC to -EINVAL and avoids allocating and releasing a zero-length
shmem object.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/89ABE9BE453F2F3D+1796007386.199131-1-huxinyao@kylinsec.com.cn?part=1

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

end of thread, other threads:[~2026-11-30  3:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  2:56 [PATCH] accel/rocket: Reject zero-sized BOs in rocket_ioctl_create_bo() Hu Xinyao
2026-11-30  3:09 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.