disable speculative store bypass
This commit is contained in:
21
src/main.rs
21
src/main.rs
@@ -1,5 +1,6 @@
|
|||||||
use libc::{
|
use libc::{
|
||||||
c_int, c_void, mmap, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE,
|
c_int, c_void, mmap, prctl, MAP_FAILED, MAP_SHARED, PROT_READ, PROT_WRITE,
|
||||||
|
PR_SET_SPECULATION_CTRL, PR_SPEC_FORCE_DISABLE, PR_SPEC_STORE_BYPASS,
|
||||||
};
|
};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::os::fd::AsRawFd;
|
use std::os::fd::AsRawFd;
|
||||||
@@ -13,6 +14,18 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
unsafe {
|
||||||
|
assert!(
|
||||||
|
prctl(
|
||||||
|
PR_SET_SPECULATION_CTRL,
|
||||||
|
PR_SPEC_STORE_BYPASS,
|
||||||
|
PR_SPEC_FORCE_DISABLE,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
) >= 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
let shared_fd: c_int = args[0]
|
let shared_fd: c_int = args[0]
|
||||||
@@ -54,7 +67,11 @@ fn main() {
|
|||||||
.expect("Cannot open KEY_FILE");
|
.expect("Cannot open KEY_FILE");
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
agent_start(shared_memory, sync_memory, private_file.as_raw_fd().try_into().unwrap());
|
agent_start(
|
||||||
|
shared_memory,
|
||||||
|
sync_memory,
|
||||||
|
private_file.as_raw_fd().try_into().unwrap(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
drop(private_file); // don't drop (and close) private file before here
|
drop(private_file); // don't drop (and close) private file before here
|
||||||
|
|||||||
Reference in New Issue
Block a user