//! A misbehaving program: tries to read kernel memory directly. The kernel's //! pages aren't USER_ACCESSIBLE, so the CPU raises a page fault, and the //! kernel kills this process (and carries on). #![no_std] #![no_main] #[macro_use] #[path = "ulib.rs"] mod ulib; fn main() -> i64 { let kernel_code = 0x200_0000_0000 as *const u64; // where the kernel is loaded println!("[evil] pid {}: reading kernel memory at {:p}...", ulib::getpid(), kernel_code); let value = unsafe { core::ptr::read_volatile(kernel_code) }; println!("[evil] got {:#x} -- this must never be printed!", value); 1 }