Skip to content
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

Fix unsoundness in our representation of the MADT #223

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IsaacWoods
Copy link
Member

As reported in #218, we had a glaring soundness hole in the way we represented the MADT, which allowed an Madt to be moved away from its following entries. When Madt::entries was called, this would lead to arbitrary memory being read from after wherever the Madt ended up.

Moving the structures representing the tables is unlikely if the library is used as intended (and structures were Copy only because this was required by repr(packed), but this is not actually required in the case of Madt), but this should obviously still be closed.

We make this sound by making Madt: !Unpin, which prevents the structure from being moved if in a Pin. To minimise difficulty using PhysicalMapping, we continue to allow mappings to deref to normal references if the underlying T: Unpin, but only allow access through Pin<&T> if T: !Unpin (ideally we'd just produce a Pin through deref but I don't think is possible?).

This feels like it should address the soundness issue from my end, but my knowledge surrounding Pin is 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

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant