Fix unsoundness in our representation of the MADT#223
Merged
IsaacWoods merged 2 commits intorust-osdev:mainfrom Jan 30, 2025
Merged
Fix unsoundness in our representation of the MADT#223IsaacWoods merged 2 commits intorust-osdev:mainfrom
IsaacWoods merged 2 commits intorust-osdev:mainfrom
Conversation
d2d8932 to
874f84f
Compare
This prevents an `Madt` being moved away from its following, but not represented, dynamic entries. This would previously have caused unsoundness as arbitrary memory would be read from after wherever the `Madt` had ended up. By prevening the user from getting anything other than a `Pin<&Madt>`, this is prevented.
874f84f to
915e816
Compare
5unsetpowerln
added a commit
to 5unsetpowerln/maizono_os
that referenced
this pull request
Mar 10, 2025
- Adapted to the changes introduced in the acpi crate PR #223, specifically for the MADT structure. - Updated handling of MADT entries to align with the new API. - Used Pin<&Madt> to ensure immovable references when accessing MADT entries, in response to changes in the MADT structure. - Adjusted usage of MADT pointers to accommodate the new access pattern introduced by the acpi crate update. See: rust-osdev/acpi#223
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.
As reported in #218, we had a glaring soundness hole in the way we represented the MADT, which allowed an
Madtto be moved away from its following entries. WhenMadt::entrieswas called, this would lead to arbitrary memory being read from after wherever theMadtended up.Moving the structures representing the tables is unlikely if the library is used as intended (and structures were
Copyonly because this was required byrepr(packed), but this is not actually required in the case ofMadt), but this should obviously still be closed.We make this sound by making
Madt: !Unpin, which prevents the structure from being moved if in aPin. To minimise difficulty usingPhysicalMapping, we continue to allow mappings to deref to normal references if the underlyingT: Unpin, but only allow access throughPin<&T>ifT: !Unpin(ideally we'd just produce aPinthrough deref but I don't think is possible?).This feels like it should address the soundness issue from my end, but my knowledge surrounding
Pinis still dubious at times, so anyone more knowledgeable who feels this is not correct please do let me know.This would unfortunately be a breaking change.
cc @pyelias