From 56825e9c676a3569555765ddf9bfa46cf3dbffce Mon Sep 17 00:00:00 2001 From: yoloyyh <1764163852@qq.com> Date: Mon, 11 Nov 2024 22:44:34 +0800 Subject: [PATCH] fix gobin lib version cause oom --- rasp/librasp/Cargo.toml | 2 +- rasp/librasp/src/golang.rs | 4 ++-- rasp/librasp/src/manager.rs | 2 +- rasp/librasp/src/parse_elf.rs | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rasp/librasp/Cargo.toml b/rasp/librasp/Cargo.toml index adeb7b21a..e713fa258 100644 --- a/rasp/librasp/Cargo.toml +++ b/rasp/librasp/Cargo.toml @@ -18,7 +18,7 @@ libc = "0.2.80" nix = "0.24" anyhow = "1.0.38" # elf -goblin = "0.8.0" +goblin = "0.3.4" byteorder = "1.0" # lru cache lru_time_cache = "0.11.8" diff --git a/rasp/librasp/src/golang.rs b/rasp/librasp/src/golang.rs index 2342567a0..1979997cd 100644 --- a/rasp/librasp/src/golang.rs +++ b/rasp/librasp/src/golang.rs @@ -139,8 +139,8 @@ pub fn golang_bin_inspect(bin_file: &PathBuf, elf: &Elf) -> Result { let shstrtab = &elf.shdr_strtab; for section in elf.section_headers.iter() { let offset = section.sh_name; - if let Some(name) = shstrtab.get_at(offset) { - if name == ".gopclntab" { + if let Some(name) = shstrtab.get(offset) { + if name.unwrap_or_default() == ".gopclntab" { return Ok(size); } } diff --git a/rasp/librasp/src/manager.rs b/rasp/librasp/src/manager.rs index cc8c4d9d5..9a72c79f1 100644 --- a/rasp/librasp/src/manager.rs +++ b/rasp/librasp/src/manager.rs @@ -332,7 +332,7 @@ impl RASPManager { let runtime_info = &process_info.runtime.clone().unwrap(); let root_dir = format!("/proc/{}/root", process_info.pid); let pid = process_info.pid; - let nspid = process_info.nspid; + // let nspid = process_info.nspid; // delete config // self.delete_config_file(pid, nspid)?; let attach_result = match runtime_info.name { diff --git a/rasp/librasp/src/parse_elf.rs b/rasp/librasp/src/parse_elf.rs index 7d79847f5..4dd716553 100644 --- a/rasp/librasp/src/parse_elf.rs +++ b/rasp/librasp/src/parse_elf.rs @@ -81,8 +81,8 @@ fn read_data_at_address(mut file: &File, elf: &Elf, address: u64, size: usize) - fn find_symbol<'a>(elf: &'a Elf<'a>, symbol_name: &str) -> Option { for sym in &elf.syms { - if let Some(name) = elf.strtab.get_at(sym.st_name) { - if name == symbol_name { + if let Some(name) = elf.strtab.get(sym.st_name) { + if name.unwrap_or_default() == symbol_name { return Some(sym.clone()); } } @@ -148,8 +148,8 @@ pub fn find_by_section(elf: &Elf, file: &File, mmap: &Mmap) -> Result { // find .go.buildinfo if let Some(go_buildinfo_section) = elf.section_headers.iter().find(|section| { - if let Some(sect_name) = elf.shdr_strtab.get_at(section.sh_name) { - sect_name == ".go.buildinfo" + if let Some(sect_name) = elf.shdr_strtab.get(section.sh_name) { + sect_name.unwrap_or_default() == ".go.buildinfo" } else { false }