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

Unsound {Fs,Gs}Base::write() #526

Closed
mkroening opened this issue Dec 24, 2024 · 1 comment · Fixed by #528
Closed

Unsound {Fs,Gs}Base::write() #526

mkroening opened this issue Dec 24, 2024 · 1 comment · Fixed by #528

Comments

@mkroening
Copy link
Member

Segment64::write_base() states:

Safety

The caller must ensure that this write operation has no unsafe side effects, as the segment base address might be in use.

On the other hand, FsBase::write() is not even unsafe.

This leads to this kind of code in our OS:

unsafe fn writefs(base: VirtAddr) {
    if CR4.FSGSBASE {
        unsafe {
            FS::write_base(base);
        }
    } else {
        FsBase::write(base);
    }
}

I think we should make FsBase::write() and GsBase::write() unsafe, right?

@Freax13
Copy link
Member

Freax13 commented Dec 24, 2024

I think we should make FsBase::write() and GsBase::write() unsafe, right?

Yes, I agree with your analysis. Feel free to open a PR.

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 a pull request may close this issue.

2 participants