Skip to content

Commit

Permalink
Merge pull request #1346 from gcmoreira/linux_misc_fixes
Browse files Browse the repository at this point in the history
Linux - miscellaneous fixes
  • Loading branch information
ikelos authored Nov 12, 2024
2 parents 340bd6d + 3a734fd commit d2ae43c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion volatility3/framework/plugins/linux/pagecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def write_inode_content_to_file(
if current_fp + len(page_bytes) > inode_size:
vollog.error(
"Page out of file bounds: inode 0x%x, inode size %d, page index %d",
inode.vol.object,
inode.vol.offset,
inode_size,
page_idx,
)
Expand Down
22 changes: 10 additions & 12 deletions volatility3/framework/symbols/linux/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def get_symbols(self):
for sym in syms:
yield sym

def get_symbols_names_and_addresses(self) -> Tuple[str, int]:
def get_symbols_names_and_addresses(self) -> Iterable[Tuple[str, int]]:
"""Get names and addresses for each symbol of the module
Yields:
Expand Down Expand Up @@ -287,17 +287,15 @@ def section_symtab(self):
return self.kallsyms.symtab
elif self.has_member("symtab"):
return self.symtab
raise AttributeError("module -> symtab: Unable to get symtab")
raise AttributeError("Unable to get symtab")

@property
def num_symtab(self):
if self.has_member("kallsyms"):
return int(self.kallsyms.num_symtab)
elif self.has_member("num_symtab"):
return int(self.num_symtab)
raise AttributeError(
"module -> num_symtab: Unable to determine number of symbols"
)
return int(self.member("num_symtab"))
raise AttributeError("Unable to determine number of symbols")

@property
def section_strtab(self):
Expand All @@ -307,7 +305,7 @@ def section_strtab(self):
# Older kernels
elif self.has_member("strtab"):
return self.strtab
raise AttributeError("module -> strtab: Unable to get strtab")
raise AttributeError("Unable to get strtab")


class task_struct(generic.GenericIntelProcess):
Expand Down Expand Up @@ -1098,7 +1096,7 @@ def d_ancestor(self, ancestor_dentry):
current_dentry = current_dentry.d_parent
return None

def get_subdirs(self) -> interfaces.objects.ObjectInterface:
def get_subdirs(self) -> Iterable[interfaces.objects.ObjectInterface]:
"""Walks dentry subdirs
Yields:
Expand Down Expand Up @@ -2435,7 +2433,7 @@ def get_file_mode(self) -> str:
"""
return stat.filemode(self.i_mode)

def get_pages(self) -> interfaces.objects.ObjectInterface:
def get_pages(self) -> Iterable[interfaces.objects.ObjectInterface]:
"""Gets the inode's cached pages
Yields:
Expand Down Expand Up @@ -2643,7 +2641,7 @@ def idr_find(self, idr_id: int) -> int:

return idr_layer

def _old_kernel_get_entries(self) -> int:
def _old_kernel_get_entries(self) -> Iterable[int]:
# Kernels < 4.11
cur = self.cur
total = next_id = 0
Expand All @@ -2655,15 +2653,15 @@ def _old_kernel_get_entries(self) -> int:

next_id += 1

def _new_kernel_get_entries(self) -> int:
def _new_kernel_get_entries(self) -> Iterable[int]:
# Kernels >= 4.11
id_storage = linux.IDStorage.choose_id_storage(
self._context, kernel_module_name="kernel"
)
for page_addr in id_storage.get_entries(root=self.idr_rt):
yield page_addr

def get_entries(self) -> int:
def get_entries(self) -> Iterable[int]:
"""Walks the IDR and yield a pointer associated with each element.
Args:
Expand Down

0 comments on commit d2ae43c

Please sign in to comment.