-
Notifications
You must be signed in to change notification settings - Fork 116
fix: insert critical overflow checks preventing heap corruption #3077
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…claudio/upgrade-bug
This was referenced Jan 28, 2022
ggreif
reviewed
Jan 28, 2022
ggreif
approved these changes
Jan 28, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine! We can do the shift trick in another PR.
No idea. Not urgent.
…On 1/28/22, Claudio Russo ***@***.***> wrote:
@crusso commented on this pull request.
> get_data_size ^^
+ compile_const_64 0x1_0000_0000L ^^
Sure, I've done that elsewhere, but is it actually cheaper? I still need to
convert the i64 to a i32 for the conditional I think.
--
Reply to this email directly or view it on GitHub:
#3077 (comment)
You are receiving this because your review was requested.
Message ID: ***@***.***>
|
ggreif
approved these changes
Jan 28, 2022
mergify bot
pushed a commit
that referenced
this pull request
Jan 31, 2022
…sts (#3085) #3077 added an expensive, but necessary overflow check to `alloc_words`, to prevent allocating addresses outside the 32-bit heap. * This PR optimizes that check to avoid the conditional test by doing the page diff arithmetic in u64s, relying on `grow_memory` to trap when asked to grow beyond 2^16 pages. * fixes test `run-drun/oom-update` to actually use an update (not query) method as advertised. I wonder why `grow_memory` is marked `inline_never`? Seems like we'd save a function call on each allocation...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes two classes of
u32
-undetected overflow bugs that could corrupt heap, stable variables, or both:alloc_words
wasn't checking validity of addresses, leading to possible (and observed) heap corruption.buffer_size
wasn't checking overflow of 32-bit size pre-computation.The first is fixed using an overflow detecting add function of Rust.
The second is checked by using a local
i64
in each type-directed size function. These functions are MV and return twoi32
s (for the data buffer and (vestigial) reference buffer sizes. I did not modify the functions to return 2i64
s because our MultiValue emulation only supporti32
at the moment.Fixes #3068.