Remove SYS_EXEC from existence
This commit is contained in:
16
src/call.rs
16
src/call.rs
@@ -1,5 +1,5 @@
|
||||
use super::arch::*;
|
||||
use super::data::{ExecMemRange, Map, SigAction, Stat, StatVfs, TimeSpec};
|
||||
use super::data::{Map, SigAction, Stat, StatVfs, TimeSpec};
|
||||
use super::error::Result;
|
||||
use super::flag::*;
|
||||
use super::number::*;
|
||||
@@ -80,20 +80,6 @@ pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result<usize> {
|
||||
unsafe { syscall3(SYS_FCNTL, fd, cmd, arg) }
|
||||
}
|
||||
|
||||
// TODO: Support specifying FDs to keep/close (for FDs not included in that list, it would take
|
||||
// into account O_CLOEXEC).
|
||||
// TODO: Allow setting all registers of the target process?
|
||||
/// Replace the current process with a new executable, allowing the user to specify memory ranges
|
||||
/// to either keep, move, or add. It will then jump to [`instruction_ptr`] in the new process
|
||||
/// memory specified by the range map, with the stack pointer set accordingly. This syscall does
|
||||
/// not support setuid/setgid; instead, privilege escalation must be done by a higher-privileged
|
||||
/// process performing these actions via ptrace.
|
||||
// TODO: never type
|
||||
pub fn exec(memranges: &[ExecMemRange], instruction_ptr: usize, stack_ptr: usize) -> Result<core::convert::Infallible> {
|
||||
unsafe { syscall4(SYS_EXEC, memranges.as_ptr() as usize, memranges.len(), instruction_ptr, stack_ptr)?; }
|
||||
panic!("SYS_EXEC should only return in case of an error");
|
||||
}
|
||||
|
||||
/// Map a file into memory, but with the ability to set the address to map into, either as a hint
|
||||
/// or as a requirement of the map.
|
||||
///
|
||||
|
||||
57
src/data.rs
57
src/data.rs
@@ -295,60 +295,3 @@ macro_rules! ptrace_event {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct ExecMemRange {
|
||||
/// The address where the range is intended to be.
|
||||
pub address: usize,
|
||||
/// The size of the memory range.
|
||||
pub size: usize,
|
||||
/// Flags describing permissions (i.e. R/W/X)
|
||||
pub flags: usize,
|
||||
/// If this equals [`address`], the range is kept untouched although flags can change, and the
|
||||
/// range can be shortened or partly zeroed. If it is different, it will move `[old_address,
|
||||
/// old_address+size)` to `[address, address+size]`.
|
||||
pub old_address: usize,
|
||||
}
|
||||
impl Deref for ExecMemRange {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const ExecMemRange as *const u8, mem::size_of::<ExecMemRange>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for ExecMemRange {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut ExecMemRange as *mut u8, mem::size_of::<ExecMemRange>())
|
||||
}
|
||||
}
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct CloneInfo {
|
||||
/// The newly allocated stack to use for the child process when [`CLONE_VM`] is set. Otherwise
|
||||
/// it is ignored.
|
||||
pub target_stack: usize,
|
||||
/// The newly allocated signal stack, when [`CLONE_VM`] is set, otherwise ignored. If no signal
|
||||
/// stack is desired (i.e. all sigactions are SIG_DFL), then this may be set to `usize::MAX`.
|
||||
pub target_sigstack: usize,
|
||||
}
|
||||
impl Deref for CloneInfo {
|
||||
type Target = [u8];
|
||||
fn deref(&self) -> &[u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self as *const Self as *const u8, mem::size_of::<Self>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for CloneInfo {
|
||||
fn deref_mut(&mut self) -> &mut [u8] {
|
||||
unsafe {
|
||||
slice::from_raw_parts_mut(self as *mut Self as *mut u8, mem::size_of::<Self>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118;
|
||||
pub const SYS_FTRUNCATE: usize = SYS_CLASS_FILE | 93;
|
||||
pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320;
|
||||
|
||||
pub const SYS_EXEC: usize = 101;
|
||||
pub const SYS_CHDIR: usize = 12;
|
||||
pub const SYS_CLOCK_GETTIME: usize = 265;
|
||||
pub const SYS_EXIT: usize = 1;
|
||||
|
||||
Reference in New Issue
Block a user