Fix panics caused by misaligned pointer dereferences in "Double Faults" & "Introduction to Paging"#1226
Merged
phil-opp merged 2 commits intophil-opp:mainfrom Jun 2, 2023
SPuntte:fix-post-06-ub-panic
Merged
Fix panics caused by misaligned pointer dereferences in "Double Faults" & "Introduction to Paging"#1226phil-opp merged 2 commits intophil-opp:mainfrom SPuntte:fix-post-06-ub-panic
phil-opp merged 2 commits intophil-opp:mainfrom
SPuntte:fix-post-06-ub-panic
Conversation
abad1dea is 2-byte aligned. |
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.
EDIT 2023-05-31:
I just noticed that post 8 is affected by this as well (as already discussed in #1215) and applied the same fix there.
In the "Double Faults" post, the following code is given as an example:
Dereferencing
0xdeadbeefas any type larger thanu8is undefined behavior, and a recently merged PR for Rust added runtime debug assertions for this.Thus, instead of the desired effects, the above code panics with the message
'misaligned pointer dereference: address must be a multiple of 0x8 but is 0xdeadbeef'.Fortunately, the author chose the value
42such that it fits in anu8, facilitating an easy fix without the need to invent another funny address that would additionally be 8-byte aligned ;)The English blog text does not mention the type of the pointer so I assume that neither do the translations.