From e4c838e8b0e35825e6ef1d53511e1be6c5b4d290 Mon Sep 17 00:00:00 2001 From: Guillume DIDIER Date: Thu, 10 Jun 2021 11:17:31 +0200 Subject: [PATCH] Rust nightly update - basic_timing_cache_channel Make sure this compiles with th newer nightly --- basic_timing_cache_channel/Cargo.toml | 2 +- basic_timing_cache_channel/src/lib.rs | 17 +++++++++++------ basic_timing_cache_channel/src/naive.rs | 15 ++++++++++----- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/basic_timing_cache_channel/Cargo.toml b/basic_timing_cache_channel/Cargo.toml index c94cf69..bebb16a 100644 --- a/basic_timing_cache_channel/Cargo.toml +++ b/basic_timing_cache_channel/Cargo.toml @@ -9,5 +9,5 @@ edition = "2018" [dependencies] cache_utils = { path = "../cache_utils" } cache_side_channel = { path = "../cache_side_channel" } -nix = "0.18.0" +nix = "0.20.0" covert_channels_evaluation = {path = "../covert_channels_evaluation"} diff --git a/basic_timing_cache_channel/src/lib.rs b/basic_timing_cache_channel/src/lib.rs index 96bb332..68ab0e9 100644 --- a/basic_timing_cache_channel/src/lib.rs +++ b/basic_timing_cache_channel/src/lib.rs @@ -26,7 +26,8 @@ use cache_utils::complex_addressing::CacheSlicing; use cache_utils::mmap::MMappedMemory; use cache_utils::{find_core_per_socket, flush, maccess, noop}; use covert_channels_evaluation::{BitIterator, CovertChannel}; -use nix::sched::{sched_getaffinity, CpuSet}; +use nix::sched::sched_getaffinity; +use nix::sched::CpuSet; use nix::unistd::Pid; use std::collections::HashSet; use std::fmt; @@ -537,10 +538,14 @@ impl MultipleAddrCacheSideChannel for TopologyAwareT } impl CovertChannel for TopologyAwareTimingChannel { - type Handle = CovertChannelHandle>; + type CovertChannelHandle = CovertChannelHandle>; const BIT_PER_PAGE: usize = 1; - unsafe fn transmit<'a>(&self, handle: &mut Self::Handle, bits: &mut BitIterator<'a>) { + unsafe fn transmit<'a>( + &self, + handle: &mut Self::CovertChannelHandle, + bits: &mut BitIterator<'a>, + ) { let page = handle.0.addr; if let Some(b) = bits.next() { @@ -552,7 +557,7 @@ impl CovertChannel for TopologyAwareTimingChannel } } - unsafe fn receive(&self, handle: &mut Self::Handle) -> Vec { + unsafe fn receive(&self, handle: &mut Self::CovertChannelHandle) -> Vec { let r = unsafe { self.test_one_impl(&mut handle.0) }; match r { Err(e) => panic!("{:?}", e), @@ -564,7 +569,7 @@ impl CovertChannel for TopologyAwareTimingChannel } } - unsafe fn ready_page(&mut self, page: *const u8) -> Result { + unsafe fn ready_page(&mut self, page: *const u8) -> Result { let vpn: VPN = get_vpn(page); // Check if the page has already been readied. If so should error out ? if let Some(preferred) = self.preferred_address.get(&vpn) { @@ -613,7 +618,7 @@ impl CovertChannel for TopologyAwareTimingChannel if self.get_slice(addr) == best_slice { self.preferred_address.insert(vpn, addr); // Create the right handle - let mut handle = Self::Handle { + let mut handle = Self::CovertChannelHandle { 0: TopologyAwareTimingChannelHandle { threshold: self .thresholds diff --git a/basic_timing_cache_channel/src/naive.rs b/basic_timing_cache_channel/src/naive.rs index eaecaa5..afaa657 100644 --- a/basic_timing_cache_channel/src/naive.rs +++ b/basic_timing_cache_channel/src/naive.rs @@ -6,7 +6,8 @@ use cache_side_channel::{ use cache_utils::calibration::{get_vpn, only_flush, only_reload, HashMap, Threshold, VPN}; use cache_utils::flush; use covert_channels_evaluation::{BitIterator, CovertChannel}; -use nix::sched::{sched_getaffinity, CpuSet}; +use nix::sched::sched_getaffinity; +use nix::sched::CpuSet; use nix::unistd::Pid; use std::fmt::Debug; @@ -102,10 +103,14 @@ impl CoreSpec for NaiveTimingChannel { } impl CovertChannel for NaiveTimingChannel { - type Handle = NaiveTimingChannelHandle; + type CovertChannelHandle = NaiveTimingChannelHandle; const BIT_PER_PAGE: usize = 1; - unsafe fn transmit<'a>(&self, handle: &mut Self::Handle, bits: &mut BitIterator<'a>) { + unsafe fn transmit<'a>( + &self, + handle: &mut Self::CovertChannelHandle, + bits: &mut BitIterator<'a>, + ) { if let Some(b) = bits.next() { if b { unsafe { only_reload(handle.addr) }; @@ -115,7 +120,7 @@ impl CovertChannel for NaiveTimingChan } } - unsafe fn receive(&self, handle: &mut Self::Handle) -> Vec { + unsafe fn receive(&self, handle: &mut Self::CovertChannelHandle) -> Vec { let r = unsafe { self.test_impl(handle) }; match r { Err(e) => panic!(), @@ -126,7 +131,7 @@ impl CovertChannel for NaiveTimingChan } } - unsafe fn ready_page(&mut self, page: *const u8) -> Result { + unsafe fn ready_page(&mut self, page: *const u8) -> Result { unsafe { self.calibrate_impl(page) }.map_err(|_| ()) } }