From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 01/10] drm/msm: Fix barriers accessing ctx vm
Date: Thu, 16 Jul 2026 20:31:10 +0000 [thread overview]
Message-ID: <20260716203110.E559D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716201538.365824-2-robin.clark@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] MSM VM Lazy Initialization Violation / NULL Pointer Dereference in `msm_ioctl_gem_submit` and `msm_gem_new_handle`
- [High] Incomplete barrier fix: `msm_gem_close()` performs a lockless plain read of `ctx->vm` leading to a data race
--
--- Patch [1]: [PATCH v5 01/10] drm/msm: Fix barriers accessing ctx vm ---
commit fdc4f5db0f02ec8c94395cb949b516d777a3923b
Author: Rob Clark <robin.clark@oss.qualcomm.com>
drm/msm: Fix barriers accessing ctx vm
This patch fixes a race condition by using smp_load_acquire and
smp_store_release when accessing ctx->vm. This prevents callers from
seeing a partially initialized vm.
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 79f78e7e16e9d..3c8b5083a1fbe 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -225,18 +225,19 @@ struct drm_gpuvm *msm_context_vm(struct drm_device *dev, struct msm_context *ctx
> {
> static DEFINE_MUTEX(init_lock);
> struct msm_drm_private *priv = dev->dev_private;
> + struct drm_gpuvm *vm = smp_load_acquire(&ctx->vm);
[Severity: High]
This isn't a bug introduced by this patch, but since we are fixing the
barriers for ctx->vm here, do we also need to update msm_gem_close()?
It appears to perform a lockless plain read of ctx->vm:
drivers/gpu/drm/msm/msm_gem.c:msm_gem_close() {
...
if (!ctx->vm)
return;
/* ... */
msm_gem_lock_vm_and_obj(&exec, obj, ctx->vm);
...
}
Could this race with the smp_store_release() during VM creation and
observe a partially initialized VM object?
[Severity: High]
This is a pre-existing issue, but I noticed there are still direct accesses
to ctx->vm instead of using msm_context_vm() for lazy initialization.
For example, in msm_ioctl_gem_submit():
drivers/gpu/drm/msm/msm_gem_submit.c:msm_ioctl_gem_submit() {
...
if (to_msm_vm(ctx->vm)->unusable)
...
}
And also in msm_gem_new_handle():
drivers/gpu/drm/msm/msm_gem.c:msm_gem_new_handle() {
...
struct drm_gem_object *r_obj = drm_gpuvm_resv_obj(ctx->vm);
...
}
If ctx->vm is NULL before initialization, could these direct accesses
result in a NULL pointer dereference?
>
> /* Once ctx->vm is created it is valid for the lifetime of the context: */
> - if (ctx->vm)
> - return ctx->vm;
> + if (vm)
> + return vm;
> +
> + guard(mutex)(&init_lock);
>
> - mutex_lock(&init_lock);
> if (!ctx->vm) {
> - ctx->vm = msm_gpu_create_private_vm(
> + vm = msm_gpu_create_private_vm(
> priv->gpu, current, !ctx->userspace_managed_vm);
> -
> + smp_store_release(&ctx->vm, vm);
> }
> - mutex_unlock(&init_lock);
>
> return ctx->vm;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716201538.365824-1-robin.clark@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-07-16 20:31 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 20:15 [PATCH v5 00/10] drm/msm: A couple lazy-vm fixes Rob Clark
2026-07-16 20:15 ` [PATCH v5 01/10] drm/msm: Fix barriers accessing ctx vm Rob Clark
2026-07-16 20:31 ` sashiko-bot [this message]
2026-07-16 20:15 ` [PATCH v5 02/10] drm/msm: Rework queuelock Rob Clark
2026-07-16 20:39 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 03/10] drm/msm: Synchronize VM creation on ctxlock Rob Clark
2026-07-16 20:33 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 04/10] drm/msm/a6xx: Access VM directly in submit path Rob Clark
2026-07-16 20:43 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 05/10] drm/msm: Add helper to check for per-process pgtables VM Rob Clark
2026-07-16 20:15 ` [PATCH v5 06/10] drm/msm: Allow lazy VM creation to fail Rob Clark
2026-07-16 20:33 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 07/10] drm/msm: Don't fallback to shared VM for VM_BIND Rob Clark
2026-07-16 20:28 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 08/10] drm/msm: Validate lazy VM in GEM_NEW Rob Clark
2026-07-16 20:29 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 09/10] drm/msm: Fix per-process-pgtables check Rob Clark
2026-07-16 20:48 ` sashiko-bot
2026-07-16 20:15 ` [PATCH v5 10/10] drm/msm: Remove invalid overflow check Rob Clark
2026-07-16 20:34 ` sashiko-bot
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=20260716203110.E559D1F000E9@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 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.