-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
range_to_pow_2_blocks
can underflow length
(size_t
)
#567
Comments
Example values for this are: |
So would ...
auto end = pointer_offset(base, length);
base = pointer_align_up(base, bits::one_at_bit(MIN_BITS));
end = pointer_align_down(end, bits::one_at_bit(MIN_BITS));
length = pointer_diff(base, end);
if (base >= end)
return;
bool first = true;
... Fix the issue? |
A version of that adjusted for the fact that these are |
Does missing the call to |
Should we be asserting that we call this function only with |
It shouldn't mater if we don't call
That sounds like a good assert to add. @pentelbart how did your system end up calling this code with zero? |
It was called from |
From backend_helpers/range_helpers.h
Length can underflow here. As a result, the loop calls
f(base, align, first)
on ever-increasing values forbase
. This leads to runtime length-violations on CHERI RISC-V.I've taken a blunt instrument to this locally in the form of:
This eliminates the crashes I was seeing, but I'm not sure this is the proper solution.
The text was updated successfully, but these errors were encountered: