* [PATCH v2] drm/xe/pt: Reset current_op in xe_pt_update_ops_init()
[not found] <20260713230830.2662760-1-zongyao.bai@intel.com>
@ 2026-07-14 23:24 ` Zongyao Bai
2026-07-15 1:46 ` Matthew Brost
0 siblings, 1 reply; 2+ messages in thread
From: Zongyao Bai @ 2026-07-14 23:24 UTC (permalink / raw)
To: intel-xe; +Cc: matthew.brost, Zongyao Bai, Matthew Auld, stable
xe_pt_update_ops_init() fails to reset current_op to 0. On the
vm_bind path, ops_execute() calls xe_pt_update_ops_prepare() inside
the xe_validation_guard() / drm_exec_until_all_locked() loop. When
that loop retries due to lock contention or OOM eviction
(drm_exec_retry_on_contention() / xe_validation_retry_on_oom()),
xe_pt_update_ops_prepare() runs again on the same vops, and each
call to bind_op_prepare() increments current_op without resetting it.
After N retries current_op exceeds the array size allocated by
xe_vma_ops_alloc(), causing an out-of-bounds write into
SLUB-poisoned memory and a subsequent UAF crash in
xe_migrate_update_pgtables_cpu() when reading the corrupted pt_op->bind.
Also reset needs_svm_lock and needs_invalidation which are derived in
the same prepare pass and would otherwise cause wrong migrate ops
selection and redundant TLB invalidation on retry.
Fix this by resetting current_op, needs_svm_lock and needs_invalidation
in xe_pt_update_ops_init().
v2 (Matt):
- Add details in commit message.
- Add Fixes tag and Cc to stable@vger.kernel.org
Fixes: e8babb280b5e ("drm/xe: Convert multiple bind ops into single job")
Suggested-by: Matthew Auld <matthew.auld@intel.com>
Cc: stable@vger.kernel.org
Assisted-by: GitHub-Copilot:claude-sonnet-4.6
Signed-off-by: Zongyao Bai <zongyao.bai@intel.com>
---
drivers/gpu/drm/xe/xe_pt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
index e466f714bf86..598c6b2571e7 100644
--- a/drivers/gpu/drm/xe/xe_pt.c
+++ b/drivers/gpu/drm/xe/xe_pt.c
@@ -2371,8 +2371,11 @@ static void
xe_pt_update_ops_init(struct xe_vm_pgtable_update_ops *pt_update_ops)
{
init_llist_head(&pt_update_ops->deferred);
+ pt_update_ops->current_op = 0;
pt_update_ops->start = ~0x0ull;
pt_update_ops->last = 0x0ull;
+ pt_update_ops->needs_svm_lock = false;
+ pt_update_ops->needs_invalidation = false;
xe_page_reclaim_list_init(&pt_update_ops->prl);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] drm/xe/pt: Reset current_op in xe_pt_update_ops_init()
2026-07-14 23:24 ` [PATCH v2] drm/xe/pt: Reset current_op in xe_pt_update_ops_init() Zongyao Bai
@ 2026-07-15 1:46 ` Matthew Brost
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Brost @ 2026-07-15 1:46 UTC (permalink / raw)
To: Zongyao Bai; +Cc: intel-xe, Matthew Auld, stable
On Tue, Jul 14, 2026 at 11:24:32PM +0000, Zongyao Bai wrote:
> xe_pt_update_ops_init() fails to reset current_op to 0. On the
> vm_bind path, ops_execute() calls xe_pt_update_ops_prepare() inside
> the xe_validation_guard() / drm_exec_until_all_locked() loop. When
> that loop retries due to lock contention or OOM eviction
> (drm_exec_retry_on_contention() / xe_validation_retry_on_oom()),
> xe_pt_update_ops_prepare() runs again on the same vops, and each
> call to bind_op_prepare() increments current_op without resetting it.
>
> After N retries current_op exceeds the array size allocated by
> xe_vma_ops_alloc(), causing an out-of-bounds write into
> SLUB-poisoned memory and a subsequent UAF crash in
> xe_migrate_update_pgtables_cpu() when reading the corrupted pt_op->bind.
>
> Also reset needs_svm_lock and needs_invalidation which are derived in
> the same prepare pass and would otherwise cause wrong migrate ops
> selection and redundant TLB invalidation on retry.
>
> Fix this by resetting current_op, needs_svm_lock and needs_invalidation
> in xe_pt_update_ops_init().
>
> v2 (Matt):
> - Add details in commit message.
> - Add Fixes tag and Cc to stable@vger.kernel.org
>
> Fixes: e8babb280b5e ("drm/xe: Convert multiple bind ops into single job")
> Suggested-by: Matthew Auld <matthew.auld@intel.com>
> Cc: stable@vger.kernel.org
> Assisted-by: GitHub-Copilot:claude-sonnet-4.6
> Signed-off-by: Zongyao Bai <zongyao.bai@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_pt.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_pt.c b/drivers/gpu/drm/xe/xe_pt.c
> index e466f714bf86..598c6b2571e7 100644
> --- a/drivers/gpu/drm/xe/xe_pt.c
> +++ b/drivers/gpu/drm/xe/xe_pt.c
> @@ -2371,8 +2371,11 @@ static void
> xe_pt_update_ops_init(struct xe_vm_pgtable_update_ops *pt_update_ops)
> {
> init_llist_head(&pt_update_ops->deferred);
> + pt_update_ops->current_op = 0;
> pt_update_ops->start = ~0x0ull;
> pt_update_ops->last = 0x0ull;
> + pt_update_ops->needs_svm_lock = false;
> + pt_update_ops->needs_invalidation = false;
> xe_page_reclaim_list_init(&pt_update_ops->prl);
> }
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-15 1:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260713230830.2662760-1-zongyao.bai@intel.com>
2026-07-14 23:24 ` [PATCH v2] drm/xe/pt: Reset current_op in xe_pt_update_ops_init() Zongyao Bai
2026-07-15 1:46 ` Matthew Brost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox