From ab5c685978ec6452b0b7a9ec2e0308311b929360 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 21 Jul 2022 11:13:57 +0200 Subject: [PATCH] Remove SYS_EXEC from existence --- src/call.rs | 16 +-------------- src/data.rs | 57 --------------------------------------------------- src/number.rs | 1 - 3 files changed, 1 insertion(+), 73 deletions(-) diff --git a/src/call.rs b/src/call.rs index f42eaf9..1e8eac6 100644 --- a/src/call.rs +++ b/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 { 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 { - 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. /// diff --git a/src/data.rs b/src/data.rs index 683a4be..45d2dd8 100644 --- a/src/data.rs +++ b/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::()) - } - } -} - -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::()) - } - } -} -#[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::()) - } - } -} - -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::()) - } - } -} diff --git a/src/number.rs b/src/number.rs index 5cf50f7..a35f469 100644 --- a/src/number.rs +++ b/src/number.rs @@ -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;