From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v4 5/6] drm/msm: Fix per-process-pgtables check
Date: Wed, 08 Jul 2026 17:47:13 +0000 [thread overview]
Message-ID: <20260708174713.B716A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708173356.578713-6-robin.clark@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Concurrent ioctl calls to MSM_PARAM_SYSPROF can cause unbalanced pm_runtime and sysprof_active refcounts.
- [Medium] TOCTOU race in MSM_PARAM_EN_VM_BIND handler leading to mismatched VM state.
--
--- Patch [5]: [PATCH v4 5/6] drm/msm: Fix per-process-pgtables check ---
commit 445f3f992eb83cba3cf22345c8afc2a87202a7ce
Author: Rob Clark <robin.clark@oss.qualcomm.com>
Subject: drm/msm: Fix per-process-pgtables check
This patch fixes the per-process-pgtable check in adreno_set_param() by
verifying create_private_vm instead of ctx->vm, as ctx->vm is not yet
initialized at this point.
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index c62c45bb0ddbb..bff2a773c0d4e 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -505,7 +505,7 @@ int adreno_set_param(struct msm_gpu *gpu, struct msm_context *ctx,
> return msm_context_set_sysprof(ctx, gpu, value);
[Severity: High]
This isn't a bug introduced by this patch, but does calling
msm_context_set_sysprof() here without locks allow a race condition?
If two threads concurrently call MSM_PARAM_SYSPROF to transition from 2 to 0,
couldn't they both read ctx->sysprof == 2 in msm_context_set_sysprof() and both
call pm_runtime_put_autosuspend() and refcount_dec()?
This might underflow the pm_runtime refcount, causing premature hardware
suspension.
> case MSM_PARAM_EN_VM_BIND:
> /* We can only support VM_BIND with per-process pgtables: */
> - if (ctx->vm == gpu->vm)
> + if (!gpu->funcs->create_private_vm)
> return UERR(EINVAL, drm, "requires per-process pgtables");
>
> /*
> * We can only swtich to VM_BIND mode if the VM has not yet
> * been created:
> */
> if (ctx->vm)
> return UERR(EBUSY, drm, "VM already created");
>
> ctx->userspace_managed_vm = value;
[Severity: Medium]
This is a pre-existing issue, but since the check if (ctx->vm) and the
assignment ctx->userspace_managed_vm = value are performed locklessly in
adreno_set_param(), is it possible for a concurrent lazy VM creation to race
with this?
If thread A issues MSM_PARAM_EN_VM_BIND, checks if (ctx->vm) and evaluates to
false, thread B could simultaneously issue an ioctl that lazily creates the VM
(e.g., DRM_IOCTL_MSM_GEM_SUBMIT).
Thread B would create the VM and set ctx->vm, and then thread A proceeds to set
ctx->userspace_managed_vm = value. This would leave the context state
desynchronized from the actual VM state.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708173356.578713-1-robin.clark@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-07-08 17:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 17:33 [PATCH v4 0/6] drm/msm: A couple lazy-vm fixes Rob Clark
2026-07-08 17:33 ` [PATCH v4 1/6] drm/msm: Fix barriers accessing ctx vm Rob Clark
2026-07-08 17:52 ` sashiko-bot
2026-07-08 17:33 ` [PATCH v4 2/6] drm/msm: Block VM_BIND for shared VMs Rob Clark
2026-07-08 17:50 ` sashiko-bot
2026-07-08 17:33 ` [PATCH v4 3/6] drm/msm: Validate lazy VM is created in GEM_SUBMIT Rob Clark
2026-07-08 17:53 ` sashiko-bot
2026-07-08 17:33 ` [PATCH v4 4/6] drm/msm: Validate lazy VM in GEM_NEW Rob Clark
2026-07-08 17:33 ` [PATCH v4 5/6] drm/msm: Fix per-process-pgtables check Rob Clark
2026-07-08 17:47 ` sashiko-bot [this message]
2026-07-08 17:33 ` [PATCH v4 6/6] drm/msm: Remove invalid overflow check Rob Clark
2026-07-08 17:40 ` 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=20260708174713.B716A1F000E9@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.