aya,aya-obj: preserve pointer provenance

pull/1161/merge
Tamir Duberstein 2 weeks ago
parent b500a6326b
commit 9a47495227

@ -1591,7 +1591,7 @@ mod tests {
pinning: PinningType::ByName,
};
let mut buf = [0u8; 128];
unsafe { ptr::write_unaligned(buf.as_mut_ptr() as *mut _, def) };
unsafe { ptr::write_unaligned(buf.as_mut_ptr().cast(), def) };
assert_eq!(parse_map_def("foo", &buf).unwrap(), def);
}

@ -934,10 +934,10 @@ impl<T: Pod> PerCpuValues<T> {
pub(crate) fn build_kernel_mem(&self) -> Result<PerCpuKernelMem, io::Error> {
let mut mem = Self::alloc_kernel_mem()?;
let mem_ptr = mem.as_mut_ptr() as usize;
let mem_ptr = mem.as_mut_ptr();
let value_size = (mem::size_of::<T>() + 7) & !7;
for i in 0..self.values.len() {
unsafe { ptr::write_unaligned((mem_ptr + i * value_size) as *mut _, self.values[i]) };
for (i, value) in self.values.iter().enumerate() {
unsafe { ptr::write_unaligned(mem_ptr.byte_add(i * value_size).cast(), *value) };
}
Ok(mem)

@ -354,10 +354,6 @@ mod tests {
}
#[test]
#[cfg_attr(
miri,
ignore = "`ptr::write_unaligned(dst, value)` is attempting a write access but no exposed tags have suitable permission in the borrow stack for this location"
)]
fn test_read_first_lost() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],
@ -397,10 +393,9 @@ mod tests {
}
fn write<T: Debug>(mmapped_buf: &mut MMappedBuf, offset: usize, value: T) -> usize {
let dst = (mmapped_buf as *const _ as usize + PAGE_SIZE + offset) as *const PerfSample<T>
as *mut T;
let dst: *mut _ = mmapped_buf;
unsafe {
ptr::write_unaligned(dst, value);
ptr::write_unaligned(dst.byte_add(PAGE_SIZE + offset).cast(), value);
mmapped_buf.mmap_page.data_head = (offset + mem::size_of::<T>()) as u64;
mmapped_buf.mmap_page.data_head as usize
}
@ -430,10 +425,6 @@ mod tests {
}
#[test]
#[cfg_attr(
miri,
ignore = "`ptr::write_unaligned(dst, value)` is attempting a write access but no exposed tags have suitable permission in the borrow stack for this location"
)]
fn test_read_first_sample() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],
@ -451,10 +442,6 @@ mod tests {
}
#[test]
#[cfg_attr(
miri,
ignore = "`ptr::write_unaligned(dst, value)` is attempting a write access but no exposed tags have suitable permission in the borrow stack for this location"
)]
fn test_read_many_with_many_reads() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],
@ -477,10 +464,6 @@ mod tests {
}
#[test]
#[cfg_attr(
miri,
ignore = "`ptr::write_unaligned(dst, value)` is attempting a write access but no exposed tags have suitable permission in the borrow stack for this location"
)]
fn test_read_many_with_one_read() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],
@ -502,10 +485,6 @@ mod tests {
}
#[test]
#[cfg_attr(
miri,
ignore = "`ptr::write_unaligned(dst, value)` is attempting a write access but no exposed tags have suitable permission in the borrow stack for this location"
)]
fn test_read_last_sample() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],
@ -525,10 +504,6 @@ mod tests {
}
#[test]
#[cfg_attr(
miri,
ignore = "`ptr::write_unaligned(dst, value)` is attempting a write access but no exposed tags have suitable permission in the borrow stack for this location"
)]
fn test_read_wrapping_sample_size() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],
@ -566,10 +541,6 @@ mod tests {
}
#[test]
#[cfg_attr(
miri,
ignore = "`ptr::write_unaligned(dst, value)` is attempting a write access but no exposed tags have suitable permission in the borrow stack for this location"
)]
fn test_read_wrapping_value() {
let mut mmapped_buf = MMappedBuf {
data: [0; PAGE_SIZE * 2],

Loading…
Cancel
Save