about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2025-08-26 12:31:33 +1000
committerZalathar <Zalathar@users.noreply.github.com>2025-08-26 13:07:19 +1000
commitfcff8f7f5a0d4add3c05f57de1b34291746c3c08 (patch)
tree7a88352c86ab0ad81b9dbf7411e83d5a73cf6dff /compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
parentd327d651e2583eb601978179f2ca9808f5e243bb (diff)
downloadrust-fcff8f7f5a0d4add3c05f57de1b34291746c3c08.tar.gz
rust-fcff8f7f5a0d4add3c05f57de1b34291746c3c08.zip
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`.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp')
0 files changed, 0 insertions, 0 deletions