dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v6 12/16] drm/msm/gem: Validate lazy VM in GEM_NEW
Date: Fri, 17 Jul 2026 21:05:54 +0000	[thread overview]
Message-ID: <20260717210554.E09EB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260717204841.26120-13-robin.clark@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] The check `!vm` fails to detect shared VMs, breaking the `MSM_BO_NO_SHARE` contract.

Pre-existing issues:
- [Critical] NULL Pointer Dereference when accessing uninitialized `ctx->vm` in `msm_ioctl_gem_submit`.
--

--- Patch [12]: [PATCH v6 12/16] drm/msm/gem: Validate lazy VM in GEM_NEW ---
commit 2c5a1210206f5856b0becc6857b23e80e4e3fe79
Author: Rob Clark <robin.clark@oss.qualcomm.com>

drm/msm/gem: Validate lazy VM in GEM_NEW

This commit adds a check in msm_gem_new_handle() to ensure the VM is
available before creating a BO with MSM_BO_NO_SHARE. It prevents a NULL
pointer dereference that could occur if a BO is created before any BOs have
been mapped.

> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> index 12d9b8a9c360a..b9da5b7ce8a31 100644
> --- a/drivers/gpu/drm/msm/msm_gem.c
> +++ b/drivers/gpu/drm/msm/msm_gem.c
> @@ -1139,9 +1139,13 @@ int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
>  	int ret;
>  
>  	if (flags & MSM_BO_NO_SHARE) {
> +		struct msm_drm_private *priv = dev->dev_private;
>  		struct msm_context *ctx = file->driver_priv;
>  		struct drm_gpuvm *vm = msm_context_vm(dev, ctx);
>  
> +		if (!priv->gpu || !vm)
> +			return UERR(EINVAL, dev, "not supported with shared VM");
> +

[Severity: Medium]
Does the check for !vm correctly detect if a shared VM is in use?

If a platform does not support private VMs and falls back to the global
VM, msm_context_vm() will return the shared gpu->vm. In this case, !vm
will evaluate to false, allowing the allocation to proceed.

Could this allow the MSM_BO_NO_SHARE flag to succeed while silently sharing
the global reservation object, defeating the purpose of the flag and
creating hidden lock contention?

Would it be better to check if vm == priv->gpu->vm to ensure a private
VM is actually in use?

>  		r_obj = drm_gpuvm_resv_obj(vm);
>  	}
>  

[Severity: Critical]
This is a pre-existing issue, but does msm_ioctl_gem_submit() have a
similar problem with lazy VM initialization?

Looking at msm_ioctl_gem_submit() in drivers/gpu/drm/msm/msm_gem_submit.c:

	if (!gpu)
		return -ENXIO;

	if (args->pad)
		return -EINVAL;

	if (to_msm_vm(ctx->vm)->unusable)
		return UERR(EPIPE, dev, "context is unusable");

If a userspace process calls the DRM_IOCTL_MSM_GEM_SUBMIT ioctl immediately
after opening the DRM device, ctx->vm will be NULL because no previous
operation has initialized it.

Since this code accesses ctx->vm directly instead of using msm_context_vm(),
will this cause a NULL pointer dereference when to_msm_vm() evaluates to NULL
and ->unusable is accessed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260717204841.26120-1-robin.clark@oss.qualcomm.com?part=12

  reply	other threads:[~2026-07-17 21:06 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 20:48 [PATCH v6 00/16] drm/msm: A couple lazy-vm fixes Rob Clark
2026-07-17 20:48 ` [PATCH v6 01/16] drm/msm: Fix barriers accessing ctx vm Rob Clark
2026-07-17 21:07   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 02/16] drm/msm: Rework queuelock Rob Clark
2026-07-17 21:00   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 03/16] drm/msm: Synchronize VM creation on ctxlock Rob Clark
2026-07-17 21:05   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 04/16] drm/msm: Synchronize set_sysprof " Rob Clark
2026-07-17 20:48 ` [PATCH v6 05/16] drm/msm: Move nr_cmds initialization Rob Clark
2026-07-17 21:06   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 06/16] drm/msm: Remove redundant SIZE_MAX check Rob Clark
2026-07-17 20:58   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 07/16] drm/msm/a6xx: Access VM directly in submit path Rob Clark
2026-07-17 21:03   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 08/16] drm/msm: Add helper to check for per-process pgtables VM Rob Clark
2026-07-17 20:48 ` [PATCH v6 09/16] drm/msm/gem: Remove useless locking in GEM import Rob Clark
2026-07-17 21:02   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 10/16] drm/msm/gem: Extract bookkeeping init helper Rob Clark
2026-07-17 21:22   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 11/16] drm/msm/gem: Set resv before exposing obj Rob Clark
2026-07-17 21:06   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 12/16] drm/msm/gem: Validate lazy VM in GEM_NEW Rob Clark
2026-07-17 21:05   ` sashiko-bot [this message]
2026-07-17 20:48 ` [PATCH v6 13/16] drm/msm: Allow lazy VM creation to fail Rob Clark
2026-07-17 20:48 ` [PATCH v6 14/16] drm/msm: Don't fallback to shared VM for VM_BIND Rob Clark
2026-07-17 21:07   ` sashiko-bot
2026-07-17 20:48 ` [PATCH v6 15/16] drm/msm: Fix per-process-pgtables check Rob Clark
2026-07-17 20:48 ` [PATCH v6 16/16] drm/msm: Fixup invalid overflow check Rob Clark

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=20260717210554.E09EB1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robin.clark@oss.qualcomm.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox