On Tue, Oct 13, 2026 at 01:54:32PM +0100, Akash Goel wrote:
> The BOs created with DRM_PANTHOR_BO_NO_MMAP flag are not supposed to be
> mmappable by the Userspace. But after the rework to support shrinker,
> it became possible to mmap NO_MMAP BOs. Userspace could second guess
> the file offset range, allocated unconditionally at the BO creation
> time, and create a CPU mapping. There may not be any adverse effect of
> such a CPU mapping though.
> This commit adds a check in the mmap callback of Panthor driver to
> fail the mmap() attempts on BOs created with NO_MMAP flag. The check
> covers private BOs as well as the prime exported BOs that are mmapped
> using prime fd.
> 
> v2:
>  - Fix breakage of mmap() on exported BOs that didn't have
>    BO_MMAP_OFFSET ioctl invoked for them.
> 
> Fixes: 68cbf96b1e9b ("drm/panthor: Part ways with drm_gem_shmem_object")
> Suggested-by: Boris Brezillon <[email protected]>
> Signed-off-by: Akash Goel <[email protected]>

Pushed to drm-misc-next.

Best regards,
Liviu

> ---
>  drivers/gpu/drm/panthor/panthor_gem.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_gem.c 
> b/drivers/gpu/drm/panthor/panthor_gem.c
> index c07a44057e42..22b57ab6f929 100644
> --- a/drivers/gpu/drm/panthor/panthor_gem.c
> +++ b/drivers/gpu/drm/panthor/panthor_gem.c
> @@ -744,6 +744,9 @@ static int panthor_gem_mmap(struct drm_gem_object *obj, 
> struct vm_area_struct *v
>       struct panthor_gem_object *bo = to_panthor_bo(obj);
>       int ret;
>  
> +     if (bo->flags & DRM_PANTHOR_BO_NO_MMAP)
> +             return -EINVAL;
> +
>       if (drm_gem_is_imported(obj)) {
>               /* Reset both vm_ops and vm_private_data, so we don't end up 
> with
>                * vm_ops pointing to our implementation if the dma-buf backend
> -- 
> 2.25.1
> 

-- 
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯

Reply via email to