Skip to content

fix(cutile-ir): reject invalid constant offsets - #1627

Open
DrunkTrader wants to merge 1 commit into
NVIDIA:mainfrom
DrunkTrader:fix/reject-invalid-constant-offsets
Open

DrunkTrader wants to merge 1 commit into
NVIDIA:mainfrom
DrunkTrader:fix/reject-invalid-constant-offsets

Conversation

@DrunkTrader

Copy link
Copy Markdown

Summary

Validate constant-section offsets before slicing the decoded bytecode payload. This prevents malformed bytecode from causing an out-of-bounds panic and ensures invalid offsets are reported as decoder errors instead.

Changes

  • Convert decoded u64 constant offsets using checked usize conversion.
  • Reject descending constant offsets.
  • Reject offsets beyond the constant-section payload before slicing.
  • Add a regression test covering an out-of-range constant offset.
  • Keep the change scoped to cutile-rs/cutile-ir bytecode decoding.

Testing

  • just -f cuda-oxide/Justfile check passes (local mirror of CI: fmt, clippy, tests, guards, docs).
PATH=/usr/local/cuda-13.4/bin:$PATH \
CUDA_TOOLKIT_PATH=/usr/local/cuda-13.4 \
just -f cuda-oxide/Justfile check

PASS

Focused cutile-ir regression and compatibility tests:

cargo +1.98.0-aarch64-unknown-linux-gnu test -p cutile-ir --lib decoder::tests::reject_constant_offset_out_of_range

cargo +1.98.0-aarch64-unknown-linux-gnu test -p cutile-ir --test bytecode_compat test_malformed_constant_entry -- --ignored

cargo +1.98.0-aarch64-unknown-linux-gnu test -p cutile-ir --test bytecode_compat test_multidim_all_types_combined -- --ignored

cargo +1.98.0-aarch64-unknown-linux-gnu test -p cutile-ir --all-targets

Additional checks passed:

cargo +1.98.0-aarch64-unknown-linux-gnu fmt --check

cargo +1.98.0-aarch64-unknown-linux-gnu clippy -p cutile-ir --all-targets -- -D warnings

bash cuda-oxide/scripts/check-spdx-headers.sh

git diff --check
  • CUDA example/smoke test: Not applicable; this is a decoder fix and no CUDA example was added.
  • New example: Not applicable.

Checklist

  • All commits signed off (git commit -s).
  • SPDX headers on new source files — no new source files were added; the repository SPDX check passes.

@DrunkTrader
DrunkTrader requested a review from elibol as a code owner October 24, 2026 13:20
@copy-pr-bot

copy-pr-bot Bot commented Oct 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Signed-off-by: DrunkTrader <neerajrajputa786@gmail.com>
@DrunkTrader
DrunkTrader force-pushed the fix/reject-invalid-constant-offsets branch from 66954f1 to 77a66f1 Compare October 24, 2026 13:27

This branch has not been deployed

No deployments
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