All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alvin Sun" <alvin.sun@linux.dev>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org, gary@garyguo.net
Subject: Re: [PATCH v7 10/10] drm/tyr: add BO-related ioctls
Date: Sun, 22 Nov 2026 13:15:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-227954@kernel.org> (raw)
In-Reply-To: <20261122-tyr-ioctls-v7-10-3a2af624b992@linux.dev>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/tyr: slab out-of-bounds access in bo_mmap_offset() on
  PRIME/dumb handles
- [Medium] drm/tyr: DRM_PANTHOR_BO_NO_MMAP objects remain CPU-mappable
  via mmap()
--

commit 7d9cd1ac18a4c56e418f19b4899916694572fe8a
Author: Alvin Sun <alvin.sun@linux.dev>

drm/tyr: add BO-related ioctls

This commit implements the PANTHOR_BO_CREATE and PANTHOR_BO_MMAP_OFFSET
ioctls for the Tyr DRM driver.

> diff --git a/drivers/gpu/drm/tyr/file.rs b/drivers/gpu/drm/tyr/file.rs
> index 8fccb42ab9e56..db57df68449cd 100644
> --- a/drivers/gpu/drm/tyr/file.rs
> +++ b/drivers/gpu/drm/tyr/file.rs
> @@ -242,6 +242,100 @@ pub(crate) fn vm_get_state(
>              Ok(0)
>          })
>      }
> +
> +    pub(crate) fn bo_create(
> +        ddev: &TyrDrmDevice<Registered>,
> +        reg_data: &TyrDrmRegistrationData<'_>,
> +        bocreate: &mut uapi::drm_panthor_bo_create,
> +        file: &TyrDrmFile,
> +    ) -> Result<u32> {

[ ... ]

> +        let bo = crate::gem::lookup_handle(file, bommap.handle).inspect_err(|_| {
> +            dev_dbg!(ddev.as_ref(), "Invalid BO mmap handle: {}\n", bommap.handle);
> +        })?;
> +        if bo.flags() & uapi::drm_panthor_bo_flags_DRM_PANTHOR_BO_NO_MMAP != 0 {

[Severity: High]
Can bo.flags() read past the end of the slab allocation when bommap.handle
comes from DRM_IOCTL_PRIME_FD_TO_HANDLE or DRM_IOCTL_MODE_CREATE_DUMB?

gem::shmem::Object::ALLOC_OPS wires up drm_gem_shmem_prime_import_sg_table
and drm_gem_shmem_dumb_create while leaving gem_create_object as None:

rust/kernel/drm/gem/shmem.rs:<Object<T> as driver::AllocImpl>::ALLOC_OPS {
        gem_create_object: None,
        ...
        gem_prime_import_sg_table: Some(bindings::drm_gem_shmem_prime_import_sg_table),
        dumb_create: Some(bindings::drm_gem_shmem_dumb_create),
}

When gem_create_object is NULL, __drm_gem_shmem_create() allocates only
sizeof(struct drm_gem_shmem_object) rather than gem::shmem::Object<BoData>.
lookup_handle() then casts that bare drm_gem_shmem_object to
&gem::shmem::Object<BoData>, so bo.flags() reads BoData::flags out of
bounds.

> +            dev_dbg!(ddev.as_ref(), "BO mmap offset on NO_MMAP object\n");
> +            return Err(EPERM);
> +        }
> +        bommap.offset = bo.create_mmap_offset().inspect_err(|_| {

[Severity: Medium]
Are DRM_PANTHOR_BO_NO_MMAP buffer objects still CPU-mappable even though
bo_mmap_offset() returns EPERM?

In bo_create(), new_object() calls __drm_gem_shmem_init(), which
unconditionally calls drm_gem_create_mmap_offset(), and bo.create_handle()
calls drm_vma_node_allow() to authorize the file to map that offset.
Because gem::shmem::Object::VTABLE sets mmap to drm_gem_shmem_object_mmap
without checking BoData::flags, userspace can still mmap() a NO_MMAP object
on the DRM fd (or via DRM_IOCTL_PRIME_HANDLE_TO_FD and mmap() on the
dma-buf fd).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122-tyr-ioctls-v7-0-3a2af624b992@linux.dev?part=10

  reply	other threads:[~2026-11-22 13:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 12:50 [PATCH v7 00/10] drm/tyr: add VM and BO ioctl support Alvin Sun
2026-11-22 12:50 ` [PATCH v7 01/10] rust: sizes: add SZ_4G constant Alvin Sun
2026-11-22 12:50 ` [PATCH v7 02/10] rust: task: add task_size() Alvin Sun
2026-11-25 14:45   ` Daniel Almeida
2026-11-22 12:50 ` [PATCH v7 03/10] rust: sync: arc: relax `ForeignOwnable` for `Arc<T>` Alvin Sun
2026-11-22 12:50 ` [PATCH v7 04/10] drm/tyr: add per-file VM pool Alvin Sun
2026-11-24 23:43   ` Deborah Brouwer
2026-11-25 15:14   ` Daniel Almeida
2026-11-22 12:50 ` [PATCH v7 05/10] drm/tyr: add user and MCU VM specifications Alvin Sun
2026-11-25 16:13   ` Daniel Almeida
2026-11-22 12:50 ` [PATCH v7 06/10] drm/tyr: add BO creation and lookup helpers Alvin Sun
2026-11-22 12:50 ` [PATCH v7 07/10] drm/tyr: add VM-related ioctls Alvin Sun
2026-11-22 13:19   ` sashiko-bot
2026-11-24 23:40   ` Deborah Brouwer
2026-11-25 18:49   ` Daniel Almeida
2026-11-22 12:50 ` [PATCH v7 08/10] rust: device: expose the device DMA attribute Alvin Sun
2026-11-25 18:52   ` Daniel Almeida
2026-11-22 12:50 ` [PATCH v7 09/10] drm/tyr: support write-combine BO mappings Alvin Sun
2026-11-22 13:16   ` sashiko-bot
2026-11-30 23:47     ` Daniel Almeida
2026-11-25 19:59   ` Daniel Almeida
2026-11-30 20:09     ` Deborah Brouwer
2026-11-30 23:11       ` Daniel Almeida
2026-11-22 12:50 ` [PATCH v7 10/10] drm/tyr: add BO-related ioctls Alvin Sun
2026-11-22 13:15   ` sashiko-bot [this message]
2026-11-25 21:02   ` Daniel Almeida
2026-11-23 22:25 ` [PATCH v7 00/10] drm/tyr: add VM and BO ioctl support Daniel Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-227954@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alvin.sun@linux.dev \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=ojeda@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.