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

Unsoundness in #30

Open
lwz23 opened this issue Mar 3, 2025 · 0 comments
Open

Unsoundness in #30

lwz23 opened this issue Mar 3, 2025 · 0 comments

Comments

@lwz23
Copy link

lwz23 commented Mar 3, 2025

Hello, thank you for your contribution in this project, I an testing our static analysis tool in github's Rust project and I notice the following code:

fn jmp64(entry_addr: u64) -> ! {
    unsafe {
        llvm_asm!(
            "pushl $$0x10
              pushl %eax
              movl  %ebx, %eax
              movl  %eax, %cr0
              lret"
            : : "{eax}"(entry_addr), "{ebx}"((1 << 31) | (1 << 0)) "{esi}"(0x7C00) :
        );
        unreachable_unchecked();
    }
}

I think there is a unsound problem because this function doesn't varify the entry_addr is valid and pass it to asm. It will trigger UB. Although it is a private function, I notice a possible way to call this function from a pub function start_kernel.

// 函数: start_kernel
pub fn start_kernel(entry_addr: u64) -> ! {
    setup_gdt();
    enable_pae();
    setup_page_tables();
    enable_paging();
    jmp64(entry_addr);
}

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

No branches or pull requests

1 participant