Skip to content

Commit

Permalink
Merge pull request volatilityfoundation#1096 from eve-mem/linux_updat…
Browse files Browse the repository at this point in the history
…e_mm_extension

Linux update mm extension
  • Loading branch information
ikelos authored Feb 20, 2024
2 parents 3703e11 + a597ee1 commit 1ccbf33
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions volatility3/framework/plugins/linux/pslist.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PsList(interfaces.plugins.PluginInterface):

_required_framework_version = (2, 0, 0)

_version = (2, 2, 0)
_version = (2, 2, 1)

@classmethod
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
Expand Down Expand Up @@ -128,7 +128,7 @@ def _get_file_output(self, task: interfaces.objects.ObjectInterface) -> str:
else:
# Find the vma that belongs to the main ELF of the process
file_output = "Error outputting file"
for v in task.mm.get_mmap_iter():
for v in task.mm.get_vma_iter():
if v.vm_start == task.mm.start_code:
file_handle = elfs.Elfs.elf_dump(
self.context,
Expand Down
37 changes: 31 additions & 6 deletions volatility3/framework/symbols/linux/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,25 @@ def _parse_maple_tree_node(


class mm_struct(objects.StructType):

# TODO: As of version 3.0.0 this method should be removed
def get_mmap_iter(self) -> Iterable[interfaces.objects.ObjectInterface]:
"""Returns an iterator for the mmap list member of an mm_struct."""
"""
Deprecated: Use either get_vma_iter() or _get_mmap_iter().
"""
vollog.warning(
"This method has been deprecated in favour of using the get_vma_iter() method."
)
yield from self.get_vma_iter()

def _get_mmap_iter(self) -> Iterable[interfaces.objects.ObjectInterface]:
"""Returns an iterator for the mmap list member of an mm_struct. Use this only if
required, get_vma_iter() will choose the correct _get_maple_tree_iter() or
_get_mmap_iter() automatically as required."""

if not self.has_member("mmap"):
raise AttributeError(
"get_mmap_iter called on mm_struct where no mmap member exists."
"_get_mmap_iter called on mm_struct where no mmap member exists."
)
if not self.mmap:
return None
Expand All @@ -466,12 +479,24 @@ def get_mmap_iter(self) -> Iterable[interfaces.objects.ObjectInterface]:
seen.add(link.vol.offset)
link = link.vm_next

# TODO: As of version 3.0.0 this method should be removed
def get_maple_tree_iter(self) -> Iterable[interfaces.objects.ObjectInterface]:
"""Returns an iterator for the mm_mt member of an mm_struct."""
"""
Deprecated: Use either get_vma_iter() or _get_maple_tree_iter().
"""
vollog.warning(
"This method has been deprecated in favour of using the get_vma_iter() method."
)
yield from self.get_vma_iter()

def _get_maple_tree_iter(self) -> Iterable[interfaces.objects.ObjectInterface]:
"""Returns an iterator for the mm_mt member of an mm_struct. Use this only if
required, get_vma_iter() will choose the correct _get_maple_tree_iter() or
get_mmap_iter() automatically as required."""

if not self.has_member("mm_mt"):
raise AttributeError(
"get_maple_tree_iter called on mm_struct where no mm_mt member exists."
"_get_maple_tree_iter called on mm_struct where no mm_mt member exists."
)
symbol_table_name = self.get_symbol_table_name()
for vma_pointer in self.mm_mt.get_slot_iter():
Expand All @@ -487,9 +512,9 @@ def get_vma_iter(self) -> Iterable[interfaces.objects.ObjectInterface]:
"""Returns an iterator for the VMAs in an mm_struct. Automatically choosing the mmap or mm_mt as required."""

if self.has_member("mmap"):
yield from self.get_mmap_iter()
yield from self._get_mmap_iter()
elif self.has_member("mm_mt"):
yield from self.get_maple_tree_iter()
yield from self._get_maple_tree_iter()
else:
raise AttributeError("Unable to find mmap or mm_mt in mm_struct")

Expand Down

0 comments on commit 1ccbf33

Please sign in to comment.