Skip to content

using extern "x86-interrupt" + #[naked] + kernel address sanitizer crashes compiler #129224

Closed
@Freax13

Description

@Freax13

I tried this code:

#![no_std]
#![feature(abi_x86_interrupt)]
#![feature(naked_functions)]

#[naked]
pub extern "x86-interrupt" fn page_fault_handler(_: u64, _: u64) {
    unsafe {
        core::arch::asm!("ud2", options(noreturn));
    }
}

And compiled it with --target x86_64-unknown-none -Zsanitizer=kernel-address.

I expected to see this happen: The compiler should generate a function page_fault_handler which only contains the ud2 instruction.

Instead, this happened: The compiler crashes with SIGILL.

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (506052d49 2024-08-16)
binary: rustc
commit-hash: 506052d49d3903ea554e4ce760cc53610cff4ef5
commit-date: 2024-08-16
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

As requested in #127853 (comment).

Metadata

Metadata

Assignees

Labels

A-ABIArea: Concerning the application binary interface (ABI)A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-nakedArea: `#[naked]`, prologue and epilogue-free, functions, https://git.io/vAzzSA-sanitizersArea: Sanitizers for correctness and code qualityC-bugCategory: This is a bug.F-naked_functions`#![feature(naked_functions)]`I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.O-bare-metalTarget: Rust without an operating systemO-x86_64Target: x86-64 processors (like x86_64-*) (also known as amd64 and x64)PG-exploit-mitigationsProject group: Exploit mitigationsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions