Skip to content

fix:add off_t conversion #106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions preload/src/api.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::mem;
use std::ptr;
use std::num::NonZeroUsize;

use std::convert::TryInto;
use libc::{
c_void,
c_int,
Expand Down Expand Up @@ -76,7 +76,7 @@ pub unsafe extern "C" fn bytehound_jemalloc_raw_mmap( addr: *mut c_void, length:
return ptr;
}

mmap_internal( addr, length, prot, flags, fildes, off, MapKind::Jemalloc )
mmap_internal( addr, length, prot, flags, fildes, off.try_into().unwrap(), MapKind::Jemalloc )
}

#[no_mangle]
Expand Down Expand Up @@ -878,14 +878,14 @@ unsafe fn call_mmap( addr: *mut c_void, length: size_t, prot: c_int, flags: c_in
if !crate::global::is_pr_set_vma_anon_name_supported() && flags & (libc::MAP_FIXED | libc::MAP_FIXED_NOREPLACE) == 0 {
let p0 = syscall::mmap( std::ptr::null_mut(), length + 8192, 0, libc::MAP_PRIVATE, crate::global::dummy_memfd(), 0 );
if p0 != libc::MAP_FAILED {
ptr = syscall::mmap( p0.add( 4096 ), length, prot, flags | libc::MAP_FIXED, fildes, off );
ptr = syscall::mmap( p0.add( 4096 ), length, prot, flags | libc::MAP_FIXED, fildes, off.try_into().unwrap() );
if ptr == libc::MAP_FAILED {
error!( "Failed to mmap over a dummy mapping!" );
libc::abort();
}
}
} else {
ptr = syscall::mmap( addr, length, prot, flags, fildes, off )
ptr = syscall::mmap( addr, length, prot, flags, fildes, off.try_into().unwrap() )
}

ptr
Expand All @@ -894,7 +894,7 @@ unsafe fn call_mmap( addr: *mut c_void, length: size_t, prot: c_int, flags: c_in
#[inline(always)]
unsafe fn mmap_internal( addr: *mut c_void, length: size_t, prot: c_int, flags: c_int, fildes: c_int, off: libc::off64_t, kind: MapKind ) -> *mut c_void {
if !opt::is_initialized() || !opt::get().gather_maps {
return syscall::mmap( addr, length, prot, flags, fildes, off );
return syscall::mmap( addr, length, prot, flags, fildes, off.try_into().unwrap() );
}

let id = crate::global::next_map_id();
Expand Down