Skip to content

[WebGPU] Reject foreign GPU handles in the built-in data transfer - #32317

Merged
Sushanth Rajasankar (sushraja-msft) merged 1 commit into
microsoft:mainfrom
4n4ny4:webgpu-data-transfer-predicate-test
Aug 31, 2026
Merged

Sushanth Rajasankar (sushraja-msft) merged 1 commit into
microsoft:mainfrom
4n4ny4:webgpu-data-transfer-predicate-test

Conversation

@4n4ny4

Copy link
Copy Markdown
Contributor

Description

WebGpuDataTransferImpl::CanCopyImpl, the plugin EP path, rejects GPU devices whose vendor id
is not VendorIds::NONE, on the grounds that they belong to another EP. The built-in
DataTransfer::CanCopy has no such check and returns true for any GPU device, so in a build
with another GPU EP registered it can claim a handle it would then reinterpret as a WGPUBuffer.

This applies the same rule in both places, and splits the device-compatibility half of the
predicate into a static so it can be covered without a live device.

Motivation and Context

Found while testing the WebGPU data transfer directly. The two paths encode the same policy and
had drifted; the plugin one already carries a comment explaining why the vendor check is needed.

The plugin EP transfer (WebGpuDataTransferImpl::CanCopyImpl) rejects GPU devices whose
vendor id is not VendorIds::NONE, since those belong to another EP. The built-in
DataTransfer::CanCopy has no such check and claims any GPU device, so in a multi-EP build
it can accept a handle it would then reinterpret as a WGPUBuffer.

Applies the same rule in both places and splits the device-compatibility half out as a
static so it can be covered without a live device.
Copilot AI balanced review requested due to automatic review settings August 28, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds vendor validation to prevent WebGPU from claiming foreign GPU handles.

Changes:

  • Rejects vendor-tagged GPU devices.
  • Extracts a testable device-pair predicate.
  • Adds host, WebGPU, and foreign-vendor tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
data_transfer.cc Implements vendor validation.
data_transfer.h Exposes the compatibility predicate.
data_transfer_test.cc Tests accepted and rejected device pairs.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sushraja-msft
Sushanth Rajasankar (sushraja-msft) merged commit c1f8233 into microsoft:main Aug 31, 2026
90 checks passed
This was referenced Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants