Ensure from_box works if boxed.addr() == 1#52
Closed
dilr wants to merge 1 commit into
Closed
Conversation
SmallBox::from_box will reuse the allocation from its argument as ptr in smallbox. However, said allocation might be equal to 1, which is the INLINE_SENTINAL value. This would cause the resulting smallbox to read from its uninitialized inline storage space when dereferenced. Note that this problem likely cannot be triggered on a desktop OS since the first page is typically set up to segfault when read. Thus if the type is not a ZST, then the allocator won't have given out a pointer in the first page, and if the type is a ZST, then reading from the uninitialized storge space is perfectly fine behavior. However, bare metal programs could concivibly run into this problem, so this commit causes from_box to copy from boxed into a newly created smallbox if boxed.addr() == INLINE_SENTINEL.
Owner
|
I rather like to revert #45 considering this case. |
Author
|
That seems reasonable. I'll close this request. |
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
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.
SmallBox::from_box will reuse the allocation from its argument as ptr in smallbox. However, said allocation might have an address of 1, which is the INLINE_SENTINAL value.
This would cause the resulting smallbox to read from its uninitialized inline storage space when de-referenced.
Note that this problem likely cannot be triggered on a desktop OS since the first page is typically set up to segfault when read. Thus if the type is not a ZST, then the allocator won't have given out a pointer in the first page, and if the type is a ZST, then reading from the uninitialized storage space is perfectly fine behavior.
However, bare metal programs could conceivably run into this problem, so this commit causes from_box to copy from boxed into a newly created smallbox if boxed.addr() == INLINE_SENTINEL.