Fix shadow bit for libafl_frida on Linux (#502)

This commit is contained in:
Dongjia Zhang 2022-01-28 17:26:24 +09:00 committed by GitHub
parent 21668b094b
commit efb5e25411
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,6 +107,7 @@ impl Allocator {
// max(userspace address) this is usually 0x8_0000_0000_0000 - 1 on x64 linux.
let mut userspace_max: usize = 0;
// Enumerate memory ranges that are already occupied.
for prot in [
PageProtection::Read,
PageProtection::Write,
@ -117,9 +118,23 @@ impl Allocator {
let end = start + details.memory_range().size();
occupied_ranges.push((start, end));
// println!("{:x} {:x}", start, end);
let base: usize = 2;
// On x64, if end > 2**48, then that's in vsyscall or something.
#[cfg(target_arch = "x86_64")]
if end <= base.pow(48) {
if end > userspace_max {
userspace_max = end;
}
}
// On x64, if end > 2**52, then range is not in userspace
#[cfg(target_arch = "aarch64")]
if end <= base.pow(52) {
if end > userspace_max {
userspace_max = end;
}
}
true
});
}