Skip to content

Commit

Permalink
Merge pull request #197 from P403n1x87/chore/remove-vm-bounds-tracking
Browse files Browse the repository at this point in the history
chore: remove VM bounds tracking logic
  • Loading branch information
P403n1x87 committed Sep 8, 2023
2 parents 911fdd3 + 9485016 commit a95aa28
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 35 deletions.
10 changes: 0 additions & 10 deletions src/linux/py_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ _py_proc__parse_maps_file(py_proc_t * self) {
crc32_t file_hash = fhash(fp);
long modified_time = fmtime_ns(fp);

self->min_raddr = (void *) -1;
self->max_raddr = NULL;

sfree(self->bin_path);
sfree(self->lib_path);

Expand Down Expand Up @@ -434,13 +431,6 @@ _py_proc__parse_maps_file(py_proc_t * self) {
log_d("PyRuntime section inferred from VM maps for %s: %lx-%lx", map->path, lower, upper);
}

if (field_count == 0 || strstr(pathname, "[v") == NULL) {
// Skip meaningless addresses like [vsyscall] which would give
// ridiculous values.
if ((void *) lower < self->min_raddr) self->min_raddr = (void *) lower;
if ((void *) upper > self->max_raddr) self->max_raddr = (void *) upper;
}

if (pathname[0] == '[')
continue;

Expand Down
9 changes: 0 additions & 9 deletions src/mac/py_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@ _py_proc__get_maps(py_proc_t * self) {
FAIL;
}

self->min_raddr = (void *) -1;
self->max_raddr = NULL;

sfree(self->bin_path);
sfree(self->lib_path);

Expand Down Expand Up @@ -521,12 +518,6 @@ _py_proc__get_maps(py_proc_t * self) {
&count,
&object_name
) == KERN_SUCCESS) {
if ((void *) address < self->min_raddr)
self->min_raddr = (void *) address;

if ((void *) address + size > self->max_raddr)
self->max_raddr = (void *) address + size;

int path_len = proc_regionfilename(self->pid, address, path, MAXPATHLEN);

if (isvalid(prev_path) && strcmp(path, prev_path) == 0) { // Avoid analysing a binary multiple times
Expand Down
5 changes: 0 additions & 5 deletions src/py_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,6 @@ _py_proc__run(py_proc_t * self) {
if (!(isvalid(self->bin_path) || isvalid(self->lib_path)))
log_w("No Python binary files detected");

if (self->min_raddr > self->max_raddr)
log_w("Invalid remote VM maximal bounds.");

if (
self->symbols[DYNSYM_RUNTIME] == NULL &&
self->gc_state_raddr == NULL
Expand All @@ -688,7 +685,6 @@ _py_proc__run(py_proc_t * self) {
#ifdef DEBUG
if (self->bin_path != NULL) log_d("Python binary: %s", self->bin_path);
if (self->lib_path != NULL) log_d("Python library: %s", self->lib_path);
log_d("Maximal VM address space: %p-%p", self->min_raddr, self->max_raddr);
#endif

self->timestamp = gettime();
Expand All @@ -713,7 +709,6 @@ py_proc_new(int child) {
return NULL;

py_proc->child = child;
py_proc->min_raddr = (void *) -1;
py_proc->gc_state_raddr = NULL;

_prehash_symbols();
Expand Down
2 changes: 0 additions & 2 deletions src/py_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ typedef struct {
char * lib_path;

proc_vm_map_t map;
void * min_raddr;
void * max_raddr;

int sym_loaded;
python_v * py_v;
Expand Down
9 changes: 0 additions & 9 deletions src/win/py_proc.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,6 @@ _py_proc__get_modules(py_proc_t * self) {
MODULEENTRY32 module;
module.dwSize = sizeof(module);

self->min_raddr = (void *) -1;
self->max_raddr = NULL;

sfree(self->bin_path);
sfree(self->lib_path);

Expand Down Expand Up @@ -249,12 +246,6 @@ _py_proc__get_modules(py_proc_t * self) {
FAIL;
}
do {
if ((void *) module.modBaseAddr < self->min_raddr)
self->min_raddr = module.modBaseAddr;

if ((void *) module.modBaseAddr + module.modBaseSize > self->max_raddr)
self->max_raddr = module.modBaseAddr + module.modBaseSize;

if (isvalid(prev_path) && strcmp(module.szExePath, prev_path) == 0) { // Avoid analysing a binary multiple times
continue;
}
Expand Down

0 comments on commit a95aa28

Please sign in to comment.