Skip to content

Commit

Permalink
add note on self modifying code and flush cache
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidVentura committed Mar 28, 2024
1 parent c213a0d commit af8cfca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ path = "src/lib.rs"
name = "tpom"
path = "src/bin.rs"
[dependencies]
cacheflush-sys = "0.1.0"
ctor = "0.2.6"
goblin = "0.6.0"
libc = "0.2.151"
Expand Down
6 changes: 3 additions & 3 deletions src/vdso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use goblin::strtab::Strtab;
use core::slice;
use std::error::Error;
use std::fs;
use cacheflush_sys;

#[derive(Debug, PartialEq)]
pub(crate) struct DynSym {
Expand Down Expand Up @@ -115,11 +116,10 @@ impl vDSO {
// We need to clear the instruction cache, otherwise it's possible that the old
// instructions (the trampoline) get executed with the new data (the original vDSO
// function)
self.change_mode(false);
unsafe {
//doesn't exist ((
//libc::cacheflush(dst_addr, opcodes.len(), libc::BCACHE);
cacheflush_sys::flush(dst_addr as *const u8, opcodes.len());
}
self.change_mode(false);
}

pub fn entry(&self, wanted: Kind) -> Option<impl TVDSOFun + '_> {
Expand Down

0 comments on commit af8cfca

Please sign in to comment.