Re:Wgpu-0.10 released: WebGPU implementation now in pure Rust
by devwastaken on Wednesday August 18, 2021 @06:30PM
(#28227967)
Does WebGPU protect against DOS via shaders, crashes, etc? Games like VRChat, where a user can just make shaders in Unity and have them ran on everyone elses computer - could really benefit from such a thing. There's an increase in games that are marketed as being able to create your own content that is displayed for other users in a game.
[ Parent
| on HN ]
Re:Wgpu-0.10 released: WebGPU implementation now in pure Rust
by gfxgirl on Thursday August 19, 2021 @03:28AM
(#28231306)
That's arguably not wgpu's responsibility. It's usually the OS's. Windows will reset the GPU if it doesn't return. Chrome tries to catch it before the OS IIRC.
In any case, other than resetting the GPU there is no way to stop DOS via shaders. I can easily write a 3 line shader that has a legit use at 1x1 pixels but will DOS your machine at 2000x2000 pixels. It's basically the halting problem. The only known solutions are (a) reset the GPU or (b) design preemptable GPUs
Re:Wgpu-0.10 released: WebGPU implementation now in pure Rust
by nextaccountic on Thursday August 19, 2021 @04:15AM
(#28231543)
The commenter said about DoS but what about the fact that GPU memory isn't protected? What if two different shaders run at the same time at the gpu - will one be able to read the other's private memory?
There are GPUs that support IOMMU but they cost a fortune. (or is IOMMU a separate feature than just having virtual memory for GPU memory?)
Running user-supplied shaders seems like a security nightmare.
Re:Wgpu-0.10 released: WebGPU implementation now in pure Rust
by garaetjjte on Thursday August 19, 2021 @07:28AM
(#28232548)
All modern GPUs have MMUs that prevent shaders from accessing arbitrary memory. In rare cases where it is absent (like VC4 on Raspberry Pi) driver needs to statically analyze shaders and ensure that all memory accesses are clamped.
Re:Wgpu-0.10 released: WebGPU implementation now in pure Rust
by kvark on Wednesday August 18, 2021 @07:09PM
(#28228314)
If there is too much GPU work thrown at a WebGPU implementation, the best it could do is terminate the logical device on timeout.
Re:Wgpu-0.10 released: WebGPU implementation now in pure Rust
by kangz on Thursday August 19, 2021 @07:46AM
(#28232662)
Other comments explain how that's challenging/impossible in the general case because GPU don't have as good preemption as CPUs and because of the halting problem. However for the VRChat use case you could imagine disallowing unbounded loops so you can estimate the number of instructions and put a reasonable cap on them. This would take care of the DOS and the WebGPU runtime would take care of the rest of the security (OOB, uninitialized data, etc)