Repository navigation
Harden worker/buffer pools, DGC0 scratch dims, and PJRT shape/HBM accounting against overflow and partial-publish leaks - #49
Merged
Conversation
…ounting against overflow and partial-publish leaks
…etpu-runtime-guards
…ce, and wire guard tests into CI
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.
Summary
Fixes 6 integer-overflow, wraparound, HBM-accounting, and partial-publish bugs across
libopenbuenosandllama-cpp-cloudtpuruntime code (merged cleanly withorigin/mainatd36c4d55), plus post-audit repair of all 3 review blockers and hardened FlatBuffer/pool/mock-PJRT invariants:libopenbuenos/src/ob_worker_pool.cpp&ob_internal.h: Replaceduint32_tfetch_addcursor wraparound with saturatingclaim_work_range, eliminated duplicated range clamping, madeWorkerPool::num_threadsatomic across the fast-path read and lazy startup write, and resetjob_gen/task pointers onshutdown()so restarted workers cannot replay stale jobs.libopenbuenos/src/ob_buffer_pool.cpp:ob_buffer_alloc(SIZE_MAX - 100)page-alignment previously wrapped to a0-byte slab and returned success; now returnsOB_ERR_OVERFLOW.libopenbuenos/src/ob_dgc0.cpp&ob_graph.cpp:< UINT32_MAXin bothparse_dgc0_bufferandupload_and_register_graph(plusext_dive_image.size <= UINT32_MAX) so4 GiB({65536, 65536}) never narrows/wraps to0atlitebuf_register_model_params.dive_scratch_size_bytes.FbView::table_field_status/follow_uoffsetto reject self-overlapping uoffsets (rel < 4), odd/out-of-bounds vtables, truncated field extents, and corruptexternal_buffers/scratchpad tensor fields (OB_ERR_BAD_DGC0) instead of silently defaulting to 1 element.llama-cpp-cloudtpu/pjrt_runtime.cpp(shape/byte overflow & mock cleanup):pjrt_dtype_nbytesto check byte-count overflow (q * bits + ceil(r * bits / 8)) instead of intermediate bit-count overflow, preserving valid large counts (2^59F32 ->2^61B,SIZE_MAXS4 ->2^63B) while throwingstd::overflow_errorwhen host bytes exceedSIZE_MAX.shape_num_elementsvalidate negative dims and zero-element short-circuit order-independently (including{INT64_MAX, 3, 0}on 32-bit/64-bit) and tightened RAII ownership inmock_buffer_from_host/mock_client_compile.llama-cpp-cloudtpu/pjrt_runtime.cpp(device-id HBM accounting): Keyed mock executable counters by hardware device ID, rejected out-of-range 64-bitreplica_device_idsbeforeintnarrowing, and errored on unknown assigned device IDs even for zero-input executables.llama-cpp-cloudtpu/pjrt_runtime.cpp(atomicExecuteoutput publication): Staged outputs and completion events with rollback on missing SSA return / allocation failure.openbuenos_pool_guards_testintolibopenbuenos/CMakeLists.txt(ctest) andlibopenbuenos/Makefile(make test), and wiredpjrt_runtime_guards_testintollama-cpp-cloudtpu/CMakeLists.txt(ctest), so.github/workflows/ci.ymlbuilds and runs both guard suites automatically.Proof Block (Offline Host Verification — Head
c15c8805)libopenbuenos):cmake -S libopenbuenos -B build-cmake -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build-cmake && ctest --test-dir build-cmake --output-on-failure --verbose-> 4/4 PASSED (openbuenos_host_test27/27,tpu_soc_probe_mock,ob_quant_unpack_test,openbuenos_pool_guards_test: ok).libopenbuenos):make -C libopenbuenos verify-header-host host test-> PASS (-Wall -Wextra -Wpedantic -Werror -fno-exceptions -fno-rtti, 27/27 +ob_quant_unpack_test+openbuenos_pool_guards_test: ok).llama-cpp-cloudtpu):cmake -S llama-cpp-cloudtpu -B build-cloudtpu -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build-cloudtpu && ctest --test-dir build-cloudtpu --output-on-failure --verbose-> 2/2 PASSED (cloudtpu_host_tests,pjrt_runtime_guards_test: ok).freetile):cmake -S freetile -B build-freetile -G Ninja -DCMAKE_BUILD_TYPE=Release && cmake --build build-freetile && ctest --test-dir build-freetile --output-on-failure-> 4/4 PASSED (freetile_unit_tests,freetile_splines_flash_attn_tests,freetile_buenos_parity_tests,freetile_twin_tests).-Werror): Bothopenbuenos_pool_guards_testandpjrt_runtime_guards_testbuilt with-fsanitize=address,undefined -fno-omit-frame-pointerand PASSED (ok).git diff --check origin/mainclean; clean-room boundary audit clean (zero private paths/codenames/secrets/binaries).