fmt
This commit is contained in:
parent
2ca415c1c2
commit
d6f52bff27
@ -206,11 +206,7 @@ fn tb_reborrow(
|
||||
// Make sure the new permission makes sense as the initial permission of a fresh tag.
|
||||
assert!(new_perm.initial_state.is_initial());
|
||||
// Ensure we bail out if the pointer goes out-of-bounds (see miri#1050).
|
||||
this.check_ptr_access(
|
||||
place.ptr(),
|
||||
ptr_size,
|
||||
CheckInAllocMsg::InboundsTest,
|
||||
)?;
|
||||
this.check_ptr_access(place.ptr(), ptr_size, CheckInAllocMsg::InboundsTest)?;
|
||||
|
||||
// It is crucial that this gets called on all code paths, to ensure we track tag creation.
|
||||
let log_creation = |this: &MiriInterpCx<'mir, 'tcx>,
|
||||
|
@ -1017,10 +1017,7 @@ fn atomic_access_check(&self, place: &MPlaceTy<'tcx, Provenance>) -> InterpResul
|
||||
// even if the type they wrap would be less aligned (e.g. AtomicU64 on 32bit must
|
||||
// be 8-aligned).
|
||||
let align = Align::from_bytes(place.layout.size.bytes()).unwrap();
|
||||
this.check_ptr_align(
|
||||
place.ptr(),
|
||||
align,
|
||||
)?;
|
||||
this.check_ptr_align(place.ptr(), align)?;
|
||||
// Ensure the allocation is mutable. Even failing (read-only) compare_exchange need mutable
|
||||
// memory on many targets (i.e., they segfault if taht memory is mapped read-only), and
|
||||
// atomic loads can be implemented via compare_exchange on some targets. There could
|
||||
|
@ -868,9 +868,7 @@ fn write_wide_str(
|
||||
let size2 = Size::from_bytes(2);
|
||||
let this = self.eval_context_mut();
|
||||
this.check_ptr_align(ptr, Align::from_bytes(2).unwrap())?;
|
||||
let mut alloc = this
|
||||
.get_ptr_alloc_mut(ptr, size2 * string_length)?
|
||||
.unwrap(); // not a ZST, so we will get a result
|
||||
let mut alloc = this.get_ptr_alloc_mut(ptr, size2 * string_length)?.unwrap(); // not a ZST, so we will get a result
|
||||
for (offset, wchar) in wide_str.iter().copied().chain(iter::once(0x0000)).enumerate() {
|
||||
let offset = u64::try_from(offset).unwrap();
|
||||
alloc.write_scalar(alloc_range(size2 * offset, size2), Scalar::from_u16(wchar))?;
|
||||
|
@ -805,12 +805,7 @@ fn emulate_foreign_item_inner(
|
||||
this.ptr_get_alloc_id(ptr_dest)?;
|
||||
this.ptr_get_alloc_id(ptr_src)?;
|
||||
|
||||
this.mem_copy(
|
||||
ptr_src,
|
||||
ptr_dest,
|
||||
Size::from_bytes(n),
|
||||
true,
|
||||
)?;
|
||||
this.mem_copy(ptr_src, ptr_dest, Size::from_bytes(n), true)?;
|
||||
this.write_pointer(ptr_dest, dest)?;
|
||||
}
|
||||
"strcpy" => {
|
||||
@ -826,12 +821,7 @@ fn emulate_foreign_item_inner(
|
||||
// reason to have `strcpy` destroy pointer provenance.
|
||||
// This reads at least 1 byte, so we are already enforcing that this is a valid pointer.
|
||||
let n = this.read_c_str(ptr_src)?.len().checked_add(1).unwrap();
|
||||
this.mem_copy(
|
||||
ptr_src,
|
||||
ptr_dest,
|
||||
Size::from_bytes(n),
|
||||
true,
|
||||
)?;
|
||||
this.mem_copy(ptr_src, ptr_dest, Size::from_bytes(n), true)?;
|
||||
this.write_pointer(ptr_dest, dest)?;
|
||||
}
|
||||
|
||||
|
@ -756,11 +756,7 @@ fn read(
|
||||
trace!("Reading from FD {}, size {}", fd, count);
|
||||
|
||||
// Check that the *entire* buffer is actually valid memory.
|
||||
this.check_ptr_access(
|
||||
buf,
|
||||
Size::from_bytes(count),
|
||||
CheckInAllocMsg::MemoryAccessTest,
|
||||
)?;
|
||||
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccessTest)?;
|
||||
|
||||
// We cap the number of read bytes to the largest value that we are able to fit in both the
|
||||
// host's and target's `isize`. This saves us from having to handle overflows later.
|
||||
@ -809,11 +805,7 @@ fn write(
|
||||
// Isolation check is done via `FileDescriptor` trait.
|
||||
|
||||
// Check that the *entire* buffer is actually valid memory.
|
||||
this.check_ptr_access(
|
||||
buf,
|
||||
Size::from_bytes(count),
|
||||
CheckInAllocMsg::MemoryAccessTest,
|
||||
)?;
|
||||
this.check_ptr_access(buf, Size::from_bytes(count), CheckInAllocMsg::MemoryAccessTest)?;
|
||||
|
||||
// We cap the number of written bytes to the largest value that we are able to fit in both the
|
||||
// host's and target's `isize`. This saves us from having to handle overflows later.
|
||||
|
@ -85,10 +85,7 @@ pub fn futex<'tcx>(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let timeout = this.deref_pointer_as(
|
||||
&args[3],
|
||||
this.libc_ty_layout("timespec"),
|
||||
)?;
|
||||
let timeout = this.deref_pointer_as(&args[3], this.libc_ty_layout("timespec"))?;
|
||||
let timeout_time = if this.ptr_is_null(timeout.ptr())? {
|
||||
None
|
||||
} else {
|
||||
|
@ -321,8 +321,8 @@ fn WaitOnAddress(
|
||||
this.atomic_fence(AtomicFenceOrd::SeqCst)?;
|
||||
|
||||
let layout = this.machine.layouts.uint(size).unwrap();
|
||||
let futex_val = this
|
||||
.read_scalar_atomic(&this.ptr_to_mplace(ptr, layout), AtomicReadOrd::Relaxed)?;
|
||||
let futex_val =
|
||||
this.read_scalar_atomic(&this.ptr_to_mplace(ptr, layout), AtomicReadOrd::Relaxed)?;
|
||||
let compare_val = this.read_scalar(&this.ptr_to_mplace(compare, layout))?;
|
||||
|
||||
if futex_val == compare_val {
|
||||
|
@ -73,12 +73,7 @@ fn emulate_x86_sse3_intrinsic(
|
||||
let src_ptr = this.read_pointer(src_ptr)?;
|
||||
let dest = dest.force_mplace(this)?;
|
||||
|
||||
this.mem_copy(
|
||||
src_ptr,
|
||||
dest.ptr(),
|
||||
dest.layout.size,
|
||||
/*nonoverlapping*/ true,
|
||||
)?;
|
||||
this.mem_copy(src_ptr, dest.ptr(), dest.layout.size, /*nonoverlapping*/ true)?;
|
||||
}
|
||||
_ => return Ok(EmulateForeignItemResult::NotSupported),
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Should be caught even without retagging
|
||||
//@compile-flags: -Zmiri-disable-stacked-borrows
|
||||
#![feature(strict_provenance)]
|
||||
use std::ptr::{addr_of_mut, self};
|
||||
use std::ptr::{self, addr_of_mut};
|
||||
|
||||
// Deref'ing a dangling raw pointer is fine, but for a dangling box it is not.
|
||||
// We do this behind a pointer indirection to potentially fool validity checking.
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Should be caught even without retagging
|
||||
//@compile-flags: -Zmiri-disable-stacked-borrows
|
||||
#![feature(strict_provenance)]
|
||||
use std::ptr::{addr_of_mut, self};
|
||||
use std::ptr::{self, addr_of_mut};
|
||||
|
||||
// Deref'ing a dangling raw pointer is fine, but for a dangling reference it is not.
|
||||
// We do this behind a pointer indirection to potentially fool validity checking.
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![feature(strict_provenance)]
|
||||
use std::ptr::{self, addr_of};
|
||||
use std::mem;
|
||||
use std::ptr::{self, addr_of};
|
||||
|
||||
fn basic_raw() {
|
||||
let mut x = 12;
|
||||
|
Loading…
Reference in New Issue
Block a user