Incorrect bounds checking for LLVM array functions #1932
Labels
easy
Issues that are expected to be easy to resolve and might therefore be good for new contributors
subsystem: crucible-llvm
Issues related to LLVM bitcode verification with crucible-llvm
type: bug
Issues reporting bugs or unexpected/unwanted behavior
While browsing the code in the SAW LLVM backend recently, I noticed a couple of array bounds checks that look suspicious:
saw-script/src/SAWScript/Crucible/LLVM/ResolveSetupValue.hs
Lines 500 to 506 in 4c0985c
saw-script/src/SAWScript/Crucible/LLVM/ResolveSetupValue.hs
Lines 572 to 573 in 4c0985c
Since
i
is zero-indexed, I believe these should befromIntegral i < n
, notfromIntegral i <= n
.I don't believe this is a source of unsoundness, since I think the worst that can happen from this code is that you might try to write to an uninitialized part of Crucible memory, which will cause Crucible to throw an error message. That being said, the error message you'd get in this situation would be suboptimal. When you run SAW on the this program, which writes to an array index equal to the length of the array:
Then SAW will produce this error:
If you made one minor change to this program, however:
Then the error message becomes much more understandable:
I believe that if we fixed the bounds checks above to be
fromIntegral i < n
, then we would get the more understandable error message in both cases. This issue tracks implementing this idea.The text was updated successfully, but these errors were encountered: