[WebGPU] Reject foreign GPU handles in the built-in data transfer - #32317
Merged
Sushanth Rajasankar (sushraja-msft) merged 1 commit intoAug 31, 2026
Conversation
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.
Contributor
There was a problem hiding this comment.
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.
Sushanth Rajasankar (sushraja-msft)
approved these changes
Aug 31, 2026
Sushanth Rajasankar (sushraja-msft)
merged commit Aug 31, 2026
c1f8233
into
microsoft:main
90 checks passed
This was referenced Sep 10, 2026
Open
This was referenced Sep 14, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
WebGpuDataTransferImpl::CanCopyImpl, the plugin EP path, rejects GPU devices whose vendor idis not
VendorIds::NONE, on the grounds that they belong to another EP. The built-inDataTransfer::CanCopyhas no such check and returns true for any GPU device, so in a buildwith 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.