about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm_util.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-08-26 16:34:17 +0200
committerGitHub <noreply@github.com>2025-08-26 16:34:17 +0200
commit6047243330acb6126ba3875abb09285a2f7a0356 (patch)
tree74936f90406f91745724609ed21995424f41a0b2 /compiler/rustc_codegen_llvm/src/llvm_util.rs
parent5d95ec05f63209fbb41080425079fba3e20399dc (diff)
parentfcff8f7f5a0d4add3c05f57de1b34291746c3c08 (diff)
downloadrust-6047243330acb6126ba3875abb09285a2f7a0356.tar.gz
rust-6047243330acb6126ba3875abb09285a2f7a0356.zip
Rollup merge of #145867 - Zalathar:range-attr, r=nikic
cg_llvm: Assert that LLVM range-attribute values don't exceed 128 bits

The underlying implementation of `LLVMCreateConstantRangeAttribute` assumes that each of `LowerWords` and `UpperWords` points to enough u64 values to define an integer of the specified bit-length, and will encounter UB if that is not the case.

Our safe wrapper function always passes pointers to `[u64; 2]` arrays, regardless of the bit-length specified. That's fine in practice, because scalar primitives never exceed 128 bits, but it is technically a soundness hole in a safe function.

We can close the soundness hole by explicitly asserting `size_bits <= 128`. This is effectively just a stricter version of the existing check that the value must be small enough to fit in `c_uint`.

---

This is a narrower version of the fix in rust-lang/rust#145846.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
0 files changed, 0 insertions, 0 deletions