mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:10:53 +01:00
[PR #524] DEPTH24-SCRATCH-BOUNDS-OVERFLOW: guard integer overflows in Depth24Converter #571
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#571
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/524
Author: @xroneyaa
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:fix/depth24-scratch-bounds-overflow📝 Commits (1)
0052344depth24: guard integer overflows in Depth24Converter prepare, scratch, and run📊 Changes
3 files changed (+520 additions, -28 deletions)
View changed files
📝
runtime/CMakeLists.txt(+9 -0)📝
runtime/src/vulkan_depth24.h(+62 -28)➕
runtime/test/depth24_bounds_test.cpp(+449 -0)📄 Description
Claimed in the coordination issue as: DEPTH24-SCRATCH-BOUNDS-OVERFLOW
What and why
Depth24Converterinruntime/src/vulkan_depth24.hhad several integer-overflow and pre-validation gaps:prepare():whole.app_offset > whole.app_sizewas not checked beforewhole.app_offset + span_words * 4 > whole.app_size, so an offset nearUINT64_MAXcould wrap past0and pass bounds validation.(s - 1) * whole.app_slice_words + (h - 1) * whole.app_row_words + aw,span_words * 4,sw * h * s * 4, andmax_range_part sizing (* 4 + slack) used unchecked 64-bit arithmetic.make_pipeline()andscratch(...)ran before checkingmax_range_, so an oversized row ormax_range_ <= 256left an unused scratch buffer allocation incurrent_.chunks.whole.scratchdid not validatescratch_offset % 4 == 0or overflow ofwhole.scratch_offset + total_scratch_bytes.scratch():(chunk.used + alignment - 1) / alignment * alignmentwrappeduint64_tnearUINT64_MAX, andstart + bytes <= chunk.sizewrapped whenbyteswas nearUINT64_MAX.make_part():window + rangeandpart.app_offset - window + spanwere unchecked.run():(job.width + 7) / 8and(job.height + 7) / 8wrappeduint32_tnearUINT32_MAX.This adds
checked_add/checked_mulguards and O(1) overflow-free part sizing inprepare(), pre-validates everything before pipeline creation or scratch allocation, uses overflow-free alignment padding inscratch(), guardsmake_part()range checks, promotesjob.width/job.heightinrun(), and adds the CPU-only mock-Vulkan testruntime/test/depth24_bounds_test.cpp(depth24_bounds).Tested
depth24_bounds_testanddepth24_convert_testwith MSVC 19.50 / Ninja (0 warnings under/W4)ctest --test-dir runtime/build --output-on-failure -R "^(depth24_bounds|depth24_convert)$"(VK_LOADER_LAYERS_DISABLE=~implicit~) -> 2/2 Passed (depth24_convert5.00 s on RTX 3060 Ti,depth24_bounds0.01 s CPU-only)python -I scripts/check_no_game_data.py runtime/src/vulkan_depth24.h runtime/test/depth24_bounds_test.cpp runtime/CMakeLists.txt-> exit 0GPUs tested: NVIDIA GeForce RTX 3060 Ti (
depth24_convert1/1 Passed;depth24_boundsCPU-only)AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed (n/a — no translator rule added).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.