From: sashiko-bot@kernel.org
To: "Gyeyoung Baek" <gye976@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v2 4/6] drm/imagination: Add VM_BIND ioctl
Date: Sun, 08 Nov 2026 05:43:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-203590@kernel.org> (raw)
In-Reply-To: <20261108-pvr-vm-bind-v2-4-730103d2cc9a@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Critical] drm/imagination: UAF on page tables in pvr_vm_bind() after
unlock
--
commit d5bbe10d571fc12d872392309205546a1d09b850
Author: Gyeyoung Baek <gye976@gmail.com>
drm/imagination: Add VM_BIND ioctl
This commit adds the DRM_IOCTL_PVR_VM_BIND ioctl to apply a batch of map and
unmap operations to a VM context, and bumps the driver minor version to 2.
> diff --git a/drivers/gpu/drm/imagination/pvr_drv.c b/drivers/gpu/drm/imagination/pvr_drv.c
> index 2d522a8e46ad6..8203d5f081d5d 100644
> --- a/drivers/gpu/drm/imagination/pvr_drv.c
> +++ b/drivers/gpu/drm/imagination/pvr_drv.c
> @@ -1135,6 +1135,168 @@ pvr_ioctl_vm_unmap(struct drm_device *drm_dev, void *raw_args,
[ ... ]
> +static int
> +pvr_ioctl_vm_bind(struct drm_device *drm_dev, void *raw_args,
> + struct drm_file *file)
> +{
[ ... ]
> + descs = pvr_vm_bind_descs_from_uapi(pvr_file, uapi_ops, args->ops.count);
> + kvfree(uapi_ops);
> + if (IS_ERR(descs)) {
> + err = PTR_ERR(descs);
> + goto err_put_vm_context;
> + }
> +
> + err = pvr_vm_bind(vm_ctx, descs, args->ops.count);
[Severity: Critical]
Can concurrent VM operations on the same vm_ctx cause a use-after-free on
op_ctx->curr_page.l0_table and l1_table in pvr_vm_bind()?
drivers/gpu/drm/imagination/pvr_vm.c:pvr_vm_bind() {
...
mutex_lock(&vm_ctx->lock);
for (u32 i = 0; !err && i < desc_count; i++)
err = pvr_vm_bind_op_exec(&bind_ops[i]);
mutex_unlock(&vm_ctx->lock);
pvr_vm_bind_ops_free(bind_ops, desc_count);
...
}
pvr_vm_bind_op_exec() caches raw pointers to L0 and L1 page tables in
op_ctx->curr_page.l0_table and l1_table and defers the final DMA sync until
pvr_vm_bind_ops_free() -> pvr_vm_bind_op_fini() ->
pvr_mmu_op_context_destroy() -> pvr_mmu_op_context_sync(), which runs after
vm_ctx->lock has been dropped:
CPU0 CPU1
pvr_ioctl_vm_bind()
pvr_vm_bind()
mutex_lock(&vm_ctx->lock)
pvr_vm_bind_op_exec()
...
op_ctx->curr_page.l0_table = ...
mutex_unlock(&vm_ctx->lock)
pvr_ioctl_vm_bind() / pvr_ioctl_vm_unmap()
pvr_vm_bind()
mutex_lock(&vm_ctx->lock)
pvr_vm_bind_op_exec()
...
pvr_page_table_l1_remove()
mutex_unlock(&vm_ctx->lock)
pvr_vm_bind_ops_free()
...
pvr_page_table_l0_free()
pvr_vm_bind_ops_free()
...
pvr_mmu_op_context_sync_manual()
pvr_page_table_l0_sync(op_ctx->curr_page.l0_table)
<-- use-after-free
Once CPU0 drops vm_ctx->lock, CPU1 can unmap the remaining entries in those
page tables and free them before CPU0 runs pvr_mmu_op_context_sync_manual(),
causing CPU0 to dereference freed page table structs and sync unmapped backing
pages.
A later patch in this series, commit "drm/imagination: Add asynchronous
VM_BIND", calls pvr_mmu_op_context_sync() and pvr_mmu_flush_exec() under
vm_ctx->lock in pvr_vm_bind_run_job(), but synchronous pvr_vm_bind() still
leaves them outside the lock.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108-pvr-vm-bind-v2-0-730103d2cc9a@gmail.com?part=4
next prev parent reply other threads:[~2026-11-08 5:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 5:16 [PATCH v2 0/6] drm/imagination: Add async VM_BIND with sparse mappings Gyeyoung Baek
2026-11-08 5:16 ` [PATCH v2 1/6] drm/imagination: Switch the GPUVM to immediate mode Gyeyoung Baek
2026-11-08 5:16 ` [PATCH v2 2/6] drm/imagination: Stop locking reservations around map and unmap Gyeyoung Baek
2026-11-08 5:16 ` [PATCH v2 3/6] drm/imagination: Route map and unmap through pvr_vm_bind() Gyeyoung Baek
2026-11-08 5:38 ` sashiko-bot
2026-11-08 5:16 ` [PATCH v2 4/6] drm/imagination: Add VM_BIND ioctl Gyeyoung Baek
2026-11-08 5:43 ` sashiko-bot [this message]
2026-11-08 5:16 ` [PATCH v2 5/6] drm/imagination: Add asynchronous VM_BIND Gyeyoung Baek
2026-11-08 5:47 ` sashiko-bot
2026-11-08 5:16 ` [PATCH v2 6/6] drm/imagination: Add MAP_SPARSE to VM_BIND Gyeyoung Baek
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-203590@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gye976@gmail.com \
--cc=media-ci@linuxtv.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.