Skip to content

Commit 346a5d9

Browse files
authored
Merge pull request #1592 from volatilityfoundation/kthread_name_smear
Prevent backtraces when kthread full name is smeared
2 parents 4df047b + 644b967 commit 346a5d9

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

volatility3/framework/plugins/linux/kthreads.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,35 @@ def _generator(self):
7272

7373
if task.has_member("worker_private"):
7474
# kernels >= 5.17 e32cf5dfbe227b355776948b2c9b5691b84d1cbd
75-
ktread_base_pointer = task.worker_private
75+
kthread_base_pointer = task.worker_private
7676
else:
7777
# 5.8 <= kernels < 5.17 in 52782c92ac85c4e393eb4a903a62e6c24afa633f threadfn
7878
# was added to struct kthread. task.set_child_tid is safe on those versions.
79-
ktread_base_pointer = task.set_child_tid
79+
kthread_base_pointer = task.set_child_tid
8080

81-
if not ktread_base_pointer.is_readable():
81+
if not kthread_base_pointer.is_readable():
8282
continue
8383

84-
kthread = ktread_base_pointer.dereference().cast("kthread")
84+
kthread = kthread_base_pointer.dereference().cast("kthread")
8585
threadfn = kthread.threadfn
8686
if not (threadfn and threadfn.is_readable()):
8787
continue
8888

8989
task_name = utility.array_to_string(task.comm)
9090

91+
thread_name = task_name
92+
9193
# kernels >= 5.17 in d6986ce24fc00b0638bd29efe8fb7ba7619ed2aa full_name was added to kthread
92-
thread_name = (
93-
utility.pointer_to_string(kthread.full_name, count=255)
94-
if kthread.has_member("full_name")
95-
else task_name
96-
)
94+
if kthread.has_member("full_name"):
95+
try:
96+
thread_name = utility.pointer_to_string(
97+
kthread.full_name, count=255
98+
)
99+
except exceptions.InvalidAddressException:
100+
vollog.debug(
101+
f"full_name pointer for thread at {kthread.vol.offset:#x} is paged out."
102+
)
103+
97104
module_name, symbol_name = (
98105
linux_utilities_modules.Modules.lookup_module_address(
99106
self.context, vmlinux.name, handlers, threadfn

0 commit comments

Comments
 (0)