Skip to content

Commit 5525ce5

Browse files
authored
Merge pull request #1260 from gcmoreira/linux_pidhashtable_plugin_pointer_verification_improvements
Linux pidhashtable plugin pointer verification improvements
2 parents 6c5b838 + c77c662 commit 5525ce5

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

volatility3/framework/plugins/linux/pidhashtable.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PIDHashTable(plugins.PluginInterface):
2020

2121
_required_framework_version = (2, 0, 0)
2222

23-
_version = (1, 0, 0)
23+
_version = (1, 0, 1)
2424

2525
@classmethod
2626
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
@@ -45,9 +45,7 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
4545
]
4646

4747
def _is_valid_task(self, task) -> bool:
48-
vmlinux = self.context.modules[self.config["kernel"]]
49-
vmlinux_layer = self.context.layers[vmlinux.layer_name]
50-
return bool(task and task.pid > 0 and vmlinux_layer.is_valid(task.parent))
48+
return bool(task and task.pid > 0 and task.parent.is_readable())
5149

5250
def _get_pidtype_pid(self):
5351
vmlinux = self.context.modules[self.config["kernel"]]
@@ -96,7 +94,7 @@ def _walk_upid(self, seen_upids, upid):
9694
seen_upids.add(upid.vol.offset)
9795

9896
pid_chain = upid.pid_chain
99-
if not (pid_chain and vmlinux_layer.is_valid(pid_chain.vol.offset)):
97+
if not (pid_chain.next and pid_chain.next.is_readable()):
10098
break
10199

102100
upid = linux.LinuxUtilities.container_of(
@@ -105,7 +103,6 @@ def _walk_upid(self, seen_upids, upid):
105103

106104
def _get_upids(self):
107105
vmlinux = self.context.modules[self.config["kernel"]]
108-
vmlinux_layer = self.context.layers[vmlinux.layer_name]
109106

110107
# 2.6.24 <= kernels < 4.15
111108
pidhash = self._get_pidhash_array()
@@ -115,7 +112,7 @@ def _get_upids(self):
115112
# each entry in the hlist is a upid which is wrapped in a pid
116113
ent = hlist.first
117114

118-
while ent and vmlinux_layer.is_valid(ent.vol.offset):
115+
while ent and ent.is_readable():
119116
# upid->pid_chain exists 2.6.24 <= kernel < 4.15
120117
upid = linux.LinuxUtilities.container_of(
121118
ent.vol.offset, "upid", "pid_chain", vmlinux
@@ -143,7 +140,7 @@ def _pid_hash_implementation(self):
143140
continue
144141

145142
pid_tasks_0 = pid.tasks[pidtype_pid].first
146-
if not pid_tasks_0:
143+
if not (pid_tasks_0 and pid_tasks_0.is_readable()):
147144
continue
148145

149146
task = vmlinux.object(
@@ -160,7 +157,7 @@ def _task_for_radix_pid_node(self, nodep):
160157
pidtype_pid = self._get_pidtype_pid()
161158

162159
pid_tasks_0 = pid.tasks[pidtype_pid].first
163-
if not pid_tasks_0:
160+
if not (pid_tasks_0 and pid_tasks_0.is_readable()):
164161
return None
165162

166163
task_struct_type = vmlinux.get_type("task_struct")

0 commit comments

Comments
 (0)