WebGPU IPC bind-group-layout entry serialization (refactor)
Component: WebKit WebGPU IPC | 94fa535
Source/WebKit/Shared/WebGPU/WebGPUBindGroupLayoutDescriptor.cpp
Source/WebKit/Shared/WebGPU/WebGPUBindGroupLayoutEntry.h
Bind group layout descriptor는 shader가 bind할 수 있는 resource를 선언합니다. 대상은 buffer, sampler, texture, storage texture, external texture입니다. 각 entry는 binding index, stage visibility, type parameter를 개별적으로 갖습니다. GPU process 입장에서 보면, decode되는 모든 field는 attacker가 제어하는 값입니다.
이번 commit에서 IPC 쪽 BindGroupLayoutEntry와 다섯 가지 binding-layout 타입은 별도 복사본이 아니라 ::WebGPU value type의 alias로 변경되었습니다. 직렬화는 각 타입의 .serialization.in 파일이 직접 담당합니다. 또한 converter 파일 6개가 삭제되었고, descriptor converter는 entry Vector를 통째로 복사하도록 수정되었습니다.
Significance
Bind group layout의 WebContent→GPU 경로는 이제 생성된 IPC encoder/decoder만으로 정의되며, 중간에 수작업 변환 계층이 존재하지 않습니다. 기존 converter는 값을 그대로 옮기는 pass-through 복사에 불과했습니다. 따라서 validation 동작은 사실상 달라지지 않습니다.
Audit directions
먼저 좁은 범위에서는, 각 .serialization.in의 field 목록이 ::WebGPU struct의 모든 멤버와 일치하는지 확인해야 합니다. field가 누락되거나 순서가 어긋나면, GPU 쪽에서 해당 field가 default-initialized 상태로 남기 때문입니다. 아울러 ::WebGPU struct에 기존 IPC struct와 다른 padding이나 default member initializer가 있는지도 살펴볼 필요가 있습니다.
범위를 넓히면, Metal 쪽 createBindGroupLayout이 entry를 어떻게 검증하는지 추적할 필요가 있습니다. 우선 buffer/sampler/texture/storageTexture/externalTexture 중 여러 개가 동시에 설정되거나 하나도 설정되지 않은 entry를 걸러내는지 확인해야 합니다. binding index 중복 여부, minBindingSize, stage별 limit 검증도 함께 점검 대상입니다. 이번 주 [1]과 9589788의 중복 @binding fix를 고려하면, 이 질문의 중요도는 더 커집니다.
그 밖에 entry 수가 많을 때 convertFromBacking의 Vector 복사가 어떻게 동작하는지도 검토해야 합니다. span으로 borrow한 entry의 lifetime이 caller와 어긋나지 않는지 역시 확인할 필요가 있습니다.