Repository navigation
PR #44653: Validate buffer slices during deserialization - #123627
Merged
Merged
Conversation
copybara-service
Bot
force-pushed
the
exported_pr_950753890
branch
3 times, most recently
from
July 20, 2026 14:19
e538847 to
835745a
Compare
3 tasks
copybara-service
Bot
force-pushed
the
exported_pr_950753890
branch
2 times, most recently
from
July 22, 2026 10:23
5cbd045 to
0647439
Compare
Imported from GitHub PR openxla/xla#44653 ## Summary - validate `BufferAllocation::Slice::FromProto` rejects negative offsets and sizes - reject serialized slices whose `[offset, offset + size)` range exceeds the referenced allocation - add regression coverage for malformed `BufferAllocationSliceProto` values ## Why `BufferAllocation::Slice::FromProto` reconstructs runtime buffer slices from serialized executable data. It previously validated only `buffer_allocation_index`, while the compile-time assignment path guarantees that `offset >= 0`, `size >= 0`, and `offset + size <= allocation.size()`. This change enforces that same invariant before constructing the slice. ## Testing - `git diff --check` - `clang++ -std=c++17 -fsanitize=address -g -DNDEBUG -DAPPLY_FIX poc_primitive_asan.cc -o /tmp/openxla_poc_fixed && /tmp/openxla_poc_fixed` from the local reproduction bundle; the fixed logic rejects the malformed slice - attempted `bazel test //xla/service:buffer_assignment_test`; local sparse-checkout setup initially missed top-level `third_party` and `tools`, and after adding them the invocation stayed in Bazel repository mapping until interrupted. Retrying with `--noexperimental_repo_remote_exec` fails during repository initialization because `rules_ml_toolchain` requires that experimental flag. Copybara import of the project: -- 67c6ebdc5932ccdf4fb97c98a6e21b6656f0c08a by M0nd0R <[email protected]>: Validate buffer slices during deserialization -- 5ce256b2ca289ca3bb01e537025a90aea4f9361c by mundur <[email protected]>: Fix deserialization tests for slice bounds checks Grouped-matmul fixtures used a B allocation sized for the non-grouped shape, and DynamicSliceThunk round-trips hard-coded 1KiB allocations that cannot hold the 1MiB workspace slices once FromProto validates ranges. Merging this change closes #44653 PiperOrigin-RevId: 952025970
copybara-service
Bot
force-pushed
the
exported_pr_950753890
branch
from
July 22, 2026 11:27
0647439 to
f0ef7a1
Compare
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.
PR #44653: Validate buffer slices during deserialization
Imported from GitHub PR openxla/xla#44653
Summary
BufferAllocation::Slice::FromProtorejects negative offsets and sizes[offset, offset + size)range exceeds the referenced allocationBufferAllocationSliceProtovaluesWhy
BufferAllocation::Slice::FromProtoreconstructs runtime buffer slices from serialized executable data. It previously validated onlybuffer_allocation_index, while the compile-time assignment path guarantees thatoffset >= 0,size >= 0, andoffset + size <= allocation.size(). This change enforces that same invariant before constructing the slice.Testing
git diff --checkclang++ -std=c++17 -fsanitize=address -g -DNDEBUG -DAPPLY_FIX poc_primitive_asan.cc -o /tmp/openxla_poc_fixed && /tmp/openxla_poc_fixedfrom the local reproduction bundle; the fixed logic rejects the malformed slicebazel test //xla/service:buffer_assignment_test; local sparse-checkout setup initially missed top-levelthird_partyandtools, and after adding them the invocation stayed in Bazel repository mapping until interrupted. Retrying with--noexperimental_repo_remote_execfails during repository initialization becauserules_ml_toolchainrequires that experimental flag.Copybara import of the project:
--
67c6ebdc5932ccdf4fb97c98a6e21b6656f0c08a by M0nd0R [email protected]:
Validate buffer slices during deserialization
--
5ce256b2ca289ca3bb01e537025a90aea4f9361c by mundur [email protected]:
Fix deserialization tests for slice bounds checks
Grouped-matmul fixtures used a B allocation sized for the non-grouped
shape, and DynamicSliceThunk round-trips hard-coded 1KiB allocations that
cannot hold the 1MiB workspace slices once FromProto validates ranges.
Merging this change closes #44653
FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#44653 from M0nd0R:codex/validate-buffer-slice-from-proto 5ce256b2ca289ca3bb01e537025a90aea4f9361c