Skip to content

Commit

Permalink
Align ELF segments to avoid subtract overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Jun 5, 2017
1 parent 138463b commit 8d89925
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/syscall/process.rs
Expand Up @@ -593,9 +593,12 @@ pub fn exec(path: &[u8], arg_ptrs: &[[usize; 2]]) -> Result<usize> {
let mut tls_option = None;
for segment in elf.segments() {
if segment.p_type == program_header::PT_LOAD {
let voff = segment.p_vaddr % 4096;
let vaddr = segment.p_vaddr - voff;

let mut memory = context::memory::Memory::new(
VirtualAddress::new(segment.p_vaddr as usize),
segment.p_memsz as usize,
VirtualAddress::new(vaddr as usize),
segment.p_memsz as usize + voff as usize,
entry::NO_EXECUTE | entry::WRITABLE,
true
);
Expand Down

0 comments on commit 8d89925

Please sign in to comment.