diff --git a/crates/kernel/src/fork_dispatch.rs b/crates/kernel/src/fork_dispatch.rs index 45746482..cb8a2a75 100644 --- a/crates/kernel/src/fork_dispatch.rs +++ b/crates/kernel/src/fork_dispatch.rs @@ -21,10 +21,11 @@ //! immediately. Writes the exit code (shifted left 8) to the user `*wstatus` //! pointer if non-null. //! -//! * `sys_execve` — path-validated in-kernel exec. Only `"/bin/sh"` is -//! recognized. A new [`UserAddressSpace`] is allocated, the embedded shell -//! ELF is loaded into it, the calling thread's previous address space is -//! released, and the SYSCALL epilogue is redirected to the new entry point. +//! * `sys_execve` — path-validated in-kernel exec. VFS is consulted first, +//! with an embedded compatibility fallback only when the path is absent. A +//! new [`UserAddressSpace`] is allocated, the ELF is loaded, the previous +//! address space is released, and the SYSCALL epilogue is redirected to the +//! new entry point. //! argv/envp are read from user space and laid out on the System V AMD64 //! initial stack at user VA 0x5FF000. //! @@ -45,10 +46,12 @@ use oncrix_hal::arch::uart::{COM1, Uart16550}; use oncrix_hal::serial::SerialPort; +use oncrix_lib::Error; use oncrix_process::pid::{Pid, alloc_pid}; use oncrix_process::process::Process; use oncrix_process::signal::Signal; use oncrix_process::table::{ExitStatus, ProcessEntry, ProcessTable}; +use oncrix_vfs::cred_check::VfsCred; use crate::arch::clone::ForkSnapshot; use crate::arch::sched_glue::read_cr3; @@ -596,6 +599,8 @@ const MAX_ARGV: usize = 64; /// Maximum bytes copied per argv/envp string. const MAX_ARG_STR: usize = 256; +const BIN_PREFIX_LEN: usize = 5; + /// Kernel handler for `SYS_EXECVE`. /// /// POSIX.1-2024 `execve(3p)` semantics: @@ -604,13 +609,14 @@ const MAX_ARG_STR: usize = 256; /// overwriting the saved user RIP / RSP / RFLAGS atomics. /// - On failure: returns a negative errno; the caller continues normally. /// -/// # Phase 13 implementation +/// # Phase 24 implementation /// -/// Only `"/bin/sh"` is recognized. A fresh [`UserAddressSpace`] is -/// allocated via [`crate::frame_alloc`], the embedded `/bin/sh` ELF is -/// loaded into it, the calling thread's previous address space is -/// `release`d (so its frames return to the global pool), and the new -/// UAS is installed both on the thread and at `PD_0_1G[2]`. argv and +/// The executable image is read from VFS first, with an embedded compatibility +/// fallback only when the path is absent. A fresh [`UserAddressSpace`] is +/// allocated via [`crate::frame_alloc`], the ELF is loaded into it, and the +/// calling thread's previous address space is `release`d so its frames return +/// to the global pool. The new UAS is installed both on the thread and at +/// `PD_0_1G[2]`. argv and /// envp are read from user space and written to the System V AMD64 /// initial stack at the top 4 KiB of the user region (user VA 0x5FF000). /// The SYSCALL epilogue is redirected to the new entry point with @@ -635,20 +641,48 @@ pub unsafe fn sys_execve(pathname_ptr: u64, argv_ptr: u64, envp_ptr: u64) -> i64 Some(s) => s, None => return -22, // EINVAL — too long or non-ASCII }; + if path.is_empty() { + return -2; + } - // Resolve `path` against the embedded binary set. Phase 23 - // recognises `/bin/{sh,echo,cat,true,false}` plus the matching - // bare names (a primitive `$PATH=/bin` shortcut). - let elf_bytes = match crate::arch::init_embed::embedded_lookup(path) { - Some(bytes) => bytes, - None => { - let _ = serial.write_str("[exec] path not in embedded set: "); - for &b in path { - let _ = serial.write_byte(b); + let mut path_buf = [0u8; MAX_PATHNAME + BIN_PREFIX_LEN]; + let vfs_path = if path.contains(&b'/') { + path + } else { + path_buf[..BIN_PREFIX_LEN].copy_from_slice(b"/bin/"); + path_buf[BIN_PREFIX_LEN..BIN_PREFIX_LEN + path.len()].copy_from_slice(path); + &path_buf[..BIN_PREFIX_LEN + path.len()] + }; + let vfs_image = match crate::state::with_global(|state| { + state.vfs.read_executable_bytes( + vfs_path, + &VfsCred::root(), + oncrix_mm::address_space::USER_REGION_SIZE, + ) + }) { + Some(Ok(image)) => Some(image), + Some(Err(Error::NotFound)) => None, + Some(Err(Error::PermissionDenied)) => return -13, + Some(Err(Error::OutOfMemory)) => return -12, + Some(Err(Error::InvalidArgument)) => return -22, + Some(Err(Error::Busy)) => return -16, + Some(Err(Error::WouldBlock)) => return -11, + Some(Err(Error::Interrupted)) => return -4, + Some(Err(Error::NotImplemented)) => return -38, + Some(Err(Error::AlreadyExists)) => return -17, + Some(Err(Error::IoError)) | None => return -5, + }; + let elf_bytes = match vfs_image.as_deref() { + Some(image) => image, + None => match crate::arch::init_embed::embedded_lookup(path) { + Some(bytes) => bytes, + None => { + let _ = serial.write_str("[exec] path not found: "); + write_exec_path(&mut serial, path); + let _ = serial.write_str("\n"); + return -2; } - let _ = serial.write_str("\n"); - return -2; // ENOENT - } + }, }; // Snapshot argv/envp from the CALLING process's address space @@ -699,9 +733,7 @@ pub unsafe fn sys_execve(pathname_ptr: u64, argv_ptr: u64, envp_ptr: u64) -> i64 match new_uas.map_elf_segments(elf_bytes) { Ok(e) => { let _ = serial.write_str("[exec] loaded "); - for &b in path { - let _ = serial.write_byte(b); - } + write_exec_path(&mut serial, path); let _ = serial.write_str(" at entry=0x"); write_hex(&mut serial, e); let _ = serial.write_str("\n"); @@ -737,9 +769,7 @@ pub unsafe fn sys_execve(pathname_ptr: u64, argv_ptr: u64, envp_ptr: u64) -> i64 } Err(_) => { let _ = serial.write_str("[exec] ELF parse/load failed for "); - for &b in path { - let _ = serial.write_byte(b); - } + write_exec_path(&mut serial, path); let _ = serial.write_str("\n"); new_uas.release(alloc); return -8; // ENOEXEC @@ -856,6 +886,12 @@ pub unsafe fn sys_execve(pathname_ptr: u64, argv_ptr: u64, envp_ptr: u64) -> i64 set_saved_user_rsp(0x5FF000); set_saved_user_rflags(DEFAULT_USER_RFLAGS); + if vfs_image.is_some() { + let _ = serial.write_str("[exec] loaded VFS image "); + write_exec_path(&mut serial, vfs_path); + let _ = serial.write_str("\n"); + } + // Return 0 — the SYSCALL epilogue will sysretq into sh's _start. 0 } @@ -905,6 +941,13 @@ unsafe fn collect_user_argv( count } +fn write_exec_path(serial: &mut Uart16550, path: &[u8]) { + for &b in path { + let out = if b < 0x20 || b == 0x7F { b'?' } else { b }; + let _ = serial.write_byte(out); + } +} + /// Write a 64-bit value as `0x`-prefixed hex to the serial console. fn write_hex(serial: &mut Uart16550, value: u64) { let mut buf = [0u8; 16]; diff --git a/crates/kernel/src/state.rs b/crates/kernel/src/state.rs index c3b7314b..3b3001b4 100644 --- a/crates/kernel/src/state.rs +++ b/crates/kernel/src/state.rs @@ -132,7 +132,7 @@ impl KernelState { /// directories. /// /// Creates a ramfs root and populates it with `/dev`, `/proc`, - /// `/tmp`, `/sbin`, and `/etc` (which contains `/etc/motd`). + /// `/tmp`, `/bin`, `/sbin`, and `/etc` (which contains `/etc/motd`). pub fn init_rootfs(&mut self) -> oncrix_lib::Result<()> { let root_ino = self.vfs.ramfs.root_inode(); let root_sb = Superblock::new(FsType::Ramfs, root_ino); @@ -150,8 +150,15 @@ impl KernelState { let _ = self.vfs.ramfs.mkdir(&root, "proc", FileMode::DIR_DEFAULT); let _ = self.vfs.ramfs.mkdir(&root, "tmp", FileMode::DIR_DEFAULT); + let bin = self.vfs.ramfs.mkdir(&root, "bin", FileMode::DIR_DEFAULT)?; let _ = self.vfs.ramfs.mkdir(&root, "sbin", FileMode::DIR_DEFAULT); + if let Some(shell) = crate::arch::init_embed::embedded_lookup(b"/bin/sh") { + self.vfs + .ramfs + .create_static_file(&bin, "sh", FileMode(0o555), shell)?; + } + // /etc and /etc/motd let etc = self.vfs.ramfs.mkdir(&root, "etc", FileMode::DIR_DEFAULT)?; let motd_content = b"Welcome to ONCRIX (Phase 15)\n"; diff --git a/crates/mm/src/address_space/elf_loader.rs b/crates/mm/src/address_space/elf_loader.rs index 57429d5a..d4adeecb 100644 --- a/crates/mm/src/address_space/elf_loader.rs +++ b/crates/mm/src/address_space/elf_loader.rs @@ -161,10 +161,18 @@ pub fn load_elf_into(elf_bytes: &[u8], dst: &mut [u8]) -> Result { if header.e_type != ET_EXEC && header.e_type != ET_DYN { return Err(Error::InvalidArgument); } + if header.e_ident[6] != 1 || header.e_version != 1 { + return Err(Error::InvalidArgument); + } + if usize::from(header.e_ehsize) != core::mem::size_of::() + || usize::from(header.e_phentsize) != core::mem::size_of::() + { + return Err(Error::InvalidArgument); + } - let ph_offset = header.e_phoff as usize; - let ph_size = header.e_phentsize as usize; - let ph_count = header.e_phnum as usize; + let ph_offset = usize::try_from(header.e_phoff).map_err(|_| Error::InvalidArgument)?; + let ph_size = usize::from(header.e_phentsize); + let ph_count = usize::from(header.e_phnum); let ph_end = ph_size .checked_mul(ph_count) @@ -294,10 +302,42 @@ fn read_phdr(elf_bytes: &[u8], ph_offset: usize, ph_size: usize, i: usize) -> Re let offset = ph_offset .checked_add(i.checked_mul(ph_size).ok_or(Error::InvalidArgument)?) .ok_or(Error::InvalidArgument)?; - if offset.checked_add(ph_size).ok_or(Error::InvalidArgument)? > elf_bytes.len() { + let read_end = offset + .checked_add(core::mem::size_of::()) + .ok_or(Error::InvalidArgument)?; + if read_end > elf_bytes.len() { return Err(Error::InvalidArgument); } - // SAFETY: Bounds checked above (offset + ph_size <= elf_bytes.len()). - // `read_unaligned` handles potentially unaligned input. + // SAFETY: Bounds checked above: offset + size_of::() <= + // elf_bytes.len(). `read_unaligned` handles potentially unaligned input. Ok(unsafe { core::ptr::read_unaligned(elf_bytes.as_ptr().add(offset) as *const Elf64Phdr) }) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn malformed_short_program_header_entry_returns_invalid_argument() { + // Given + let mut elf = [0u8; 64]; + elf[..4].copy_from_slice(&ELF_MAGIC); + elf[4] = ELFCLASS64; + elf[5] = ELFDATA2LSB; + elf[6] = 1; + elf[16..18].copy_from_slice(&ET_EXEC.to_le_bytes()); + elf[18..20].copy_from_slice(&EM_X86_64.to_le_bytes()); + elf[20..24].copy_from_slice(&1u32.to_le_bytes()); + elf[32..40].copy_from_slice(&63u64.to_le_bytes()); + elf[52..54].copy_from_slice(&64u16.to_le_bytes()); + elf[54..56].copy_from_slice(&1u16.to_le_bytes()); + elf[56..58].copy_from_slice(&1u16.to_le_bytes()); + let mut dst = [0u8; 1]; + + // When + let result = load_elf_into(&elf, &mut dst); + + // Then + assert!(matches!(result, Err(Error::InvalidArgument))); + } +} diff --git a/crates/vfs/src/kernel_api.rs b/crates/vfs/src/kernel_api.rs index 9267eebc..e428465a 100644 --- a/crates/vfs/src/kernel_api.rs +++ b/crates/vfs/src/kernel_api.rs @@ -23,6 +23,7 @@ extern crate alloc; use alloc::vec; use alloc::vec::Vec; +use crate::cred_check::{AccessResult, VfsCred, check_exec_access}; use crate::dentry::{Dentry, DentryCache, DentryName}; use crate::file::OpenFlags; use crate::inode::{FileMode, FileType, Inode, InodeNumber, InodeOps}; @@ -561,6 +562,45 @@ impl KernelVfs { Ok(buf) } + /// Read a bounded regular executable file into owned memory. + /// + /// The inode must be regular, executable by `cred`, and no larger than + /// `max_bytes`. Short reads are rejected rather than returning a partial + /// executable image. + pub fn read_executable_bytes( + &self, + path: &[u8], + cred: &VfsCred, + max_bytes: usize, + ) -> Result> { + let inode = self.lookup_path(path)?; + if inode.file_type != FileType::Regular + || check_exec_access(cred, inode.uid, inode.gid, inode.mode.0) != AccessResult::Granted + { + return Err(Error::PermissionDenied); + } + let size = usize::try_from(inode.size).map_err(|_| Error::OutOfMemory)?; + if size > max_bytes { + return Err(Error::OutOfMemory); + } + let mut image = Vec::new(); + image + .try_reserve_exact(size) + .map_err(|_| Error::OutOfMemory)?; + image.resize(size, 0); + let mut offset = 0; + while offset < size { + let count = self + .ramfs + .read(&inode, offset as u64, &mut image[offset..])?; + if count == 0 { + return Err(Error::IoError); + } + offset += count; + } + Ok(image) + } + /// Read a `/proc/` virtual file by name. /// /// Resolves the name against the procfs entry table, generates diff --git a/crates/vfs/src/ramfs.rs b/crates/vfs/src/ramfs.rs index 51cf7ae7..d581d510 100644 --- a/crates/vfs/src/ramfs.rs +++ b/crates/vfs/src/ramfs.rs @@ -3,9 +3,9 @@ //! RAM filesystem — a simple in-memory filesystem for early boot. //! -//! Ramfs stores all data in fixed-size memory buffers. It provides -//! a minimal but functional filesystem for the kernel's initial -//! root before a real filesystem is mounted. +//! Writable files use fixed-size in-memory buffers. Static read-only +//! files borrow immutable `'static` byte slices. Ramfs remains the +//! early-boot root filesystem. extern crate alloc; @@ -46,6 +46,11 @@ enum RamInodeData { /// Actual data length. len: usize, }, + /// Borrowed read-only file data with static lifetime. + StaticFile { + /// Immutable file contents. + data: &'static [u8], + }, /// Directory entries. Dir { /// Child entries. @@ -195,6 +200,34 @@ impl Ramfs { self.inodes.iter().filter(|slot| slot.is_some()).count() } + /// Create a read-only regular file backed by static bytes. + /// + /// Static files are not constrained by [`MAX_FILE_SIZE`] and reject + /// subsequent write and truncate operations. + pub fn create_static_file( + &mut self, + parent: &Inode, + name: &str, + mode: FileMode, + data: &'static [u8], + ) -> Result { + let parent_slot = self.slot_of(parent.ino).ok_or(Error::NotFound)?; + let (child_slot, child_ino) = self.alloc_inode(FileType::Regular, mode)?; + self.data[child_slot] = Some(RamInodeData::StaticFile { data }); + if let Some(inode) = self.inodes[child_slot].as_mut() { + inode.size = data.len() as u64; + } + if let Err(err) = self.add_dir_entry(parent_slot, name, child_ino) { + self.inodes[child_slot] = None; + self.data[child_slot] = None; + return Err(err); + } + self.inodes[child_slot] + .as_ref() + .copied() + .ok_or(Error::NotFound) + } + /// Find the slot index for an inode number. fn slot_of(&self, ino: InodeNumber) -> Option { self.inodes @@ -736,21 +769,32 @@ impl InodeOps for Ramfs { let slot = self.slot_of(inode.ino).ok_or(Error::NotFound)?; let data = self.data[slot].as_ref().ok_or(Error::NotFound)?; - if let RamInodeData::File { - data: file_data, - len, - } = data - { - let offset = offset as usize; - if offset >= *len { - return Ok(0); + match data { + RamInodeData::File { + data: file_data, + len, + } => { + let offset = offset as usize; + if offset >= *len { + return Ok(0); + } + let available = *len - offset; + let to_read = buf.len().min(available); + buf[..to_read].copy_from_slice(&file_data[offset..offset + to_read]); + Ok(to_read) + } + RamInodeData::StaticFile { data } => { + let offset = offset as usize; + if offset >= data.len() { + return Ok(0); + } + let to_read = buf.len().min(data.len() - offset); + buf[..to_read].copy_from_slice(&data[offset..offset + to_read]); + Ok(to_read) + } + RamInodeData::Dir { .. } | RamInodeData::Symlink { .. } | RamInodeData::Fifo { .. } => { + Err(Error::InvalidArgument) } - let available = *len - offset; - let to_read = buf.len().min(available); - buf[..to_read].copy_from_slice(&file_data[offset..offset + to_read]); - Ok(to_read) - } else { - Err(Error::InvalidArgument) } } @@ -758,31 +802,33 @@ impl InodeOps for Ramfs { let slot = self.slot_of(inode.ino).ok_or(Error::NotFound)?; let inode_data = self.data[slot].as_mut().ok_or(Error::NotFound)?; - if let RamInodeData::File { - data: file_data, - len, - } = inode_data - { - let offset = offset as usize; - let end = offset - .checked_add(data.len()) - .ok_or(Error::InvalidArgument)?; - if end > MAX_FILE_SIZE { - return Err(Error::OutOfMemory); - } - file_data[offset..end].copy_from_slice(data); - if end > *len { - *len = end; - } + match inode_data { + RamInodeData::File { + data: file_data, + len, + } => { + let offset = offset as usize; + let end = offset + .checked_add(data.len()) + .ok_or(Error::InvalidArgument)?; + if end > MAX_FILE_SIZE { + return Err(Error::OutOfMemory); + } + file_data[offset..end].copy_from_slice(data); + if end > *len { + *len = end; + } - // Update inode size. - if let Some(inode_meta) = self.inodes[slot].as_mut() { - inode_meta.size = *len as u64; - } + if let Some(inode_meta) = self.inodes[slot].as_mut() { + inode_meta.size = *len as u64; + } - Ok(data.len()) - } else { - Err(Error::InvalidArgument) + Ok(data.len()) + } + RamInodeData::StaticFile { .. } => Err(Error::PermissionDenied), + RamInodeData::Dir { .. } | RamInodeData::Symlink { .. } | RamInodeData::Fifo { .. } => { + Err(Error::InvalidArgument) + } } } @@ -790,24 +836,26 @@ impl InodeOps for Ramfs { let slot = self.slot_of(inode.ino).ok_or(Error::NotFound)?; let inode_data = self.data[slot].as_mut().ok_or(Error::NotFound)?; - if let RamInodeData::File { - data: file_data, - len, - } = inode_data - { - let new_len = (size as usize).min(MAX_FILE_SIZE); - if new_len < *len { - // Zero out truncated region. - file_data[new_len..*len].fill(0); - } - *len = new_len; + match inode_data { + RamInodeData::File { + data: file_data, + len, + } => { + let new_len = (size as usize).min(MAX_FILE_SIZE); + if new_len < *len { + file_data[new_len..*len].fill(0); + } + *len = new_len; - if let Some(inode_meta) = self.inodes[slot].as_mut() { - inode_meta.size = new_len as u64; + if let Some(inode_meta) = self.inodes[slot].as_mut() { + inode_meta.size = new_len as u64; + } + Ok(()) + } + RamInodeData::StaticFile { .. } => Err(Error::PermissionDenied), + RamInodeData::Dir { .. } | RamInodeData::Symlink { .. } | RamInodeData::Fifo { .. } => { + Err(Error::InvalidArgument) } - Ok(()) - } else { - Err(Error::InvalidArgument) } } @@ -815,3 +863,7 @@ impl InodeOps for Ramfs { self.read_link(inode.ino, buf) } } + +#[cfg(test)] +#[path = "ramfs_exec_tests.rs"] +mod exec_tests; diff --git a/crates/vfs/src/ramfs_exec_tests.rs b/crates/vfs/src/ramfs_exec_tests.rs new file mode 100644 index 00000000..94bb7a9d --- /dev/null +++ b/crates/vfs/src/ramfs_exec_tests.rs @@ -0,0 +1,111 @@ +// Copyright 2026 ONCRIX Contributors +// SPDX-License-Identifier: Apache-2.0 + +extern crate std; + +use super::Ramfs; +use crate::cred_check::VfsCred; +use crate::inode::{FileMode, FileType, Inode, InodeOps}; +use crate::kernel_api::KernelVfs; +use oncrix_lib::Error; + +static LARGE_PAYLOAD: [u8; 4097] = [0xA5; 4097]; +static EXEC_PAYLOAD: [u8; 5000] = [0x5A; 5000]; + +#[test] +fn static_file_reads_large_payload_and_offset() { + // Given + let mut ramfs = Ramfs::new(); + let root = Inode::new( + ramfs.root_inode(), + FileType::Directory, + FileMode::DIR_DEFAULT, + ); + let inode = ramfs + .create_static_file(&root, "tool", FileMode(0o555), &LARGE_PAYLOAD) + .unwrap(); + let mut all = [0u8; LARGE_PAYLOAD.len()]; + let mut tail = [0u8; 8]; + + // When + let all_count = ramfs.read(&inode, 0, &mut all); + let tail_count = ramfs.read(&inode, 4090, &mut tail); + + // Then + assert_eq!((inode.mode, inode.size), (FileMode(0o555), 4097)); + assert_eq!(all_count, Ok(LARGE_PAYLOAD.len())); + assert_eq!(all, LARGE_PAYLOAD); + assert_eq!(tail_count, Ok(7)); + assert_eq!(&tail[..7], &LARGE_PAYLOAD[4090..]); +} + +#[test] +fn static_file_rejects_write_and_truncate() { + // Given + let mut ramfs = Ramfs::new(); + let root = Inode::new( + ramfs.root_inode(), + FileType::Directory, + FileMode::DIR_DEFAULT, + ); + let inode = ramfs + .create_static_file(&root, "tool", FileMode(0o555), &LARGE_PAYLOAD) + .unwrap(); + + // When + let write_result = ramfs.write(&inode, 0, b"x"); + let truncate_result = ramfs.truncate(&inode, 0); + + // Then + assert_eq!(write_result, Err(Error::PermissionDenied)); + assert_eq!(truncate_result, Err(Error::PermissionDenied)); +} + +#[test] +fn static_file_creation_rolls_back_inode_when_directory_entry_fails() { + // Given + let mut ramfs = Ramfs::new(); + let root = Inode::new( + ramfs.root_inode(), + FileType::Directory, + FileMode::DIR_DEFAULT, + ); + ramfs + .create_static_file(&root, "tool", FileMode(0o555), &LARGE_PAYLOAD) + .unwrap(); + let used_before_duplicate = ramfs.used_inodes(); + + // When + let result = ramfs.create_static_file(&root, "tool", FileMode(0o555), &LARGE_PAYLOAD); + + // Then + assert!(matches!(result, Err(Error::AlreadyExists))); + assert_eq!(ramfs.used_inodes(), used_before_duplicate); +} + +#[test] +fn executable_reader_enforces_type_mode_and_bound() { + // Given + let mut vfs = KernelVfs::new(); + vfs.create_dir(b"/bin").unwrap(); + let bin = vfs.lookup_path(b"/bin").unwrap(); + vfs.ramfs + .create_static_file(&bin, "tool", FileMode(0o555), &EXEC_PAYLOAD) + .unwrap(); + vfs.ramfs + .create_static_file(&bin, "data", FileMode(0o444), &EXEC_PAYLOAD) + .unwrap(); + let cred = VfsCred::root(); + + // When + let directory_result = vfs.read_executable_bytes(b"/bin", &cred, EXEC_PAYLOAD.len()); + let mode_result = vfs.read_executable_bytes(b"/bin/data", &cred, EXEC_PAYLOAD.len()); + let bound_result = vfs.read_executable_bytes(b"/bin/tool", &cred, EXEC_PAYLOAD.len() - 1); + let executable_result = vfs.read_executable_bytes(b"/bin/tool", &cred, EXEC_PAYLOAD.len()); + + // Then + assert_eq!(directory_result, Err(Error::PermissionDenied)); + assert_eq!(mode_result, Err(Error::PermissionDenied)); + assert_eq!(bound_result, Err(Error::OutOfMemory)); + assert_eq!(executable_result, Ok(EXEC_PAYLOAD.to_vec())); +} diff --git a/tests/boot_tests/src/main.rs b/tests/boot_tests/src/main.rs index cf96bebf..f1a1a9db 100644 --- a/tests/boot_tests/src/main.rs +++ b/tests/boot_tests/src/main.rs @@ -40,6 +40,7 @@ const REQUIRED_MARKERS: &[&str] = &[ "[ONCRIX] Root filesystem mounted", "[ONCRIX] Service manager boot complete", "[init] hello from pid 1", + "[exec] loaded VFS image /bin/sh", ]; /// If this string appears the boot is considered failed immediately.