Skip to content

PR #44653: Validate buffer slices during deserialization - #123627

Merged
copybara-service[bot] merged 1 commit into
masterfrom
exported_pr_950753890
Jul 22, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
exported_pr_950753890

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

PR #44653: Validate buffer slices during deserialization

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

FUTURE_COPYBARA_INTEGRATE_REVIEW=openxla/xla#44653 from M0nd0R:codex/validate-buffer-slice-from-proto 5ce256b2ca289ca3bb01e537025a90aea4f9361c

@copybara-service
copybara-service Bot force-pushed the exported_pr_950753890 branch 3 times, most recently from e538847 to 835745a Compare July 20, 2026 14:19
@copybara-service
copybara-service Bot force-pushed the exported_pr_950753890 branch 2 times, most recently from 5cbd045 to 0647439 Compare July 22, 2026 10:23
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
copybara-service Bot force-pushed the exported_pr_950753890 branch from 0647439 to f0ef7a1 Compare July 22, 2026 11:27
@copybara-service
copybara-service Bot merged commit f0ef7a1 into master Jul 22, 2026
@copybara-service
copybara-service Bot deleted the exported_pr_950753890 branch July 22, 2026 11:27
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