Skip to content

vulkan: Use 64-bit arithmetic for scaled readback buffer sizes#149

Open
utzcoz wants to merge 1 commit into
google:mainfrom
utzcoz:64-bit-arithmetic
Open

vulkan: Use 64-bit arithmetic for scaled readback buffer sizes#149
utzcoz wants to merge 1 commit into
google:mainfrom
utzcoz:64-bit-arithmetic

Conversation

@utzcoz

@utzcoz utzcoz commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

readColorBufferPixelsScaledCpu() and ResizeRGBAImage() computed pixel buffer sizes and indices as 'width * height * bpp' in 32-bit int before widening to the uint64_t/size_t they are stored in. The dimensions here come from the host screenshot path rather than the guest, so this is a robustness fix rather than a guest-reachable overflow, but the mixed arithmetic is inconsistent with the explicit (uint64_t) cast already used a few lines up at the simple-readback size computation.

Perform these multiplications in 64-bit: cast the scaled output size and the resize allocation to 64-bit, and widen ResizeRGBAImage's pixel index helper and index variables to int64_t so the index math cannot overflow independently of the allocation.

Test: bazel build //host/vulkan:gfxstream_vulkan_server

readColorBufferPixelsScaledCpu() and ResizeRGBAImage() computed pixel
buffer sizes and indices as 'width * height * bpp' in 32-bit int before
widening to the uint64_t/size_t they are stored in. The dimensions here
come from the host screenshot path rather than the guest, so this is a
robustness fix rather than a guest-reachable overflow, but the mixed
arithmetic is inconsistent with the explicit (uint64_t) cast already
used a few lines up at the simple-readback size computation.

Perform these multiplications in 64-bit: cast the scaled output size and
the resize allocation to 64-bit, and widen ResizeRGBAImage's pixel index
helper and index variables to int64_t so the index math cannot overflow
independently of the allocation.

Test: bazel build //host/vulkan:gfxstream_vulkan_server

Change-Id: I71c06bf932ad5ee598b907bfb5daf46dde69f9c0
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.

1 participant