Skip to content

Commit

Permalink
fix: Warn instead of panicking if /proc/iomem segment size and /proc/…
Browse files Browse the repository at this point in the history
…kcore sizes are different. Use max between the two to dump
  • Loading branch information
rmccrystal committed Jan 27, 2023
1 parent d023d34 commit 1f21ef6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use std::io::SeekFrom;
use std::io::prelude::*;
use std::io::BufReader;
use std::{mem, env, cmp};
use std::cmp::max;
use std::time::{Instant};

use nix::unistd::Uid;
Expand Down Expand Up @@ -386,7 +387,9 @@ impl DumpItForLinux {
let memsz = h.p_filesz(endian);
assert_eq!(h.p_filesz(endian), h.p_memsz(endian));
if !is_virtual {
assert_eq!(memsz, mem_range.memsz);
if memsz != mem_range.memsz {
log::warn!("Mismatch between /proc/iomem segment size ({:#X}) and /proc/kcore segment size ({:#X}). Dumping {:#X} bytes.", mem_range.memsz, memsz, max(memsz, mem_range.memsz));
}
}
let end_phys_addr = start_phys_addr + memsz;
let virt_addr = h.p_vaddr(endian);
Expand All @@ -395,7 +398,7 @@ impl DumpItForLinux {
self.mem_ranges.push(MemoryRange {
start_phys_addr,
end_phys_addr,
memsz,
memsz: max(memsz, mem_range.memsz),
virt_addr,
kcore_file_off,
out_file_off,
Expand Down

0 comments on commit 1f21ef6

Please sign in to comment.