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

add workaround for recursive page tables with recursive index 511 #425

Merged
merged 4 commits into from
Jun 19, 2023

Conversation

Freax13
Copy link
Member

@Freax13 Freax13 commented Jun 14, 2023

This pr adds changes the iterator returned by PageTable::iter{_mut} to a custom iterator that avoids calculating the end pointer of the page table. It also adds a warning against using recursive index 511.

Closes #424

@Freax13 Freax13 requested a review from phil-opp June 14, 2023 19:14
// that address sound, but it avoids some easy to trigger
// miscompilations.
let ptr = self.entries.as_ptr();
(0..512).map(move |i| unsafe { &*ptr.add(i) })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried whether self.entries[i] works? This way we might be able to avoid the unsafe..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should work for iter, but not iter_mut.

src/structures/paging/mapper/recursive_page_table.rs Outdated Show resolved Hide resolved
Copy link
Member

@phil-opp phil-opp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

I proposed a small update to the safety comment, otherwise this looks good to me.

src/structures/paging/mapper/recursive_page_table.rs Outdated Show resolved Hide resolved
@Freax13 Freax13 enabled auto-merge June 19, 2023 05:43
@Freax13 Freax13 merged commit 9e0a8d1 into rust-osdev:master Jun 19, 2023
@Freax13 Freax13 mentioned this pull request Sep 15, 2023
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.

recursive page table with recursive index 511 is unsound
2 participants