Skip to content

Commit 14778cd

Browse files
committed
Address feedback
1 parent 557b200 commit 14778cd

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

volatility3/framework/plugins/linux/tracing/ftrace.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Public researches: https://i.blackhat.com/USA21/Wednesday-Handouts/us-21-Fixing-A-Memory-Forensics-Blind-Spot-Linux-Kernel-Tracing-wp.pdf
66

77
import logging
8-
from typing import Dict, List, Iterable, Optional
8+
from typing import Dict, List, Generator
99
from enum import Enum
1010
from dataclasses import dataclass
1111

@@ -67,7 +67,7 @@ class CheckFtrace(interfaces.plugins.PluginInterface):
6767
Investigate the ftrace infrastructure to uncover kernel attached callbacks, which can be leveraged
6868
to hook kernel functions and modify their behaviour."""
6969

70-
_version = (1, 0, 0)
70+
_version = (2, 0, 0)
7171
_required_framework_version = (2, 19, 0)
7272

7373
@classmethod
@@ -103,14 +103,14 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
103103
def extract_hash_table_filters(
104104
cls,
105105
ftrace_ops: interfaces.objects.ObjectInterface,
106-
) -> Optional[Iterable[interfaces.objects.ObjectInterface]]:
106+
) -> Generator[interfaces.objects.ObjectInterface, None, None]:
107107
"""Wrap the process of walking to every ftrace_func_entry of an ftrace_ops.
108108
Those are stored in a hash table of filters that indicates the addresses hooked.
109109
110110
Args:
111111
ftrace_ops: The ftrace_ops struct to walk through
112112
113-
Returns:
113+
Return, None, None:
114114
An iterable of ftrace_func_entry structs
115115
"""
116116

@@ -140,7 +140,7 @@ def parse_ftrace_ops(
140140
known_modules: Dict[str, List[extensions.module]],
141141
ftrace_ops: interfaces.objects.ObjectInterface,
142142
run_hidden_modules: bool = True,
143-
) -> Optional[Iterable[ParsedFtraceOps]]:
143+
) -> Generator[ParsedFtraceOps, None, None]:
144144
"""Parse an ftrace_ops struct to highlight ftrace kernel hooking.
145145
Iterates over embedded ftrace_func_entry entries, which point to hooked memory areas.
146146
@@ -237,12 +237,10 @@ def parse_ftrace_ops(
237237
formatted_ftrace_flags,
238238
)
239239

240-
return None
241-
242240
@classmethod
243241
def iterate_ftrace_ops_list(
244242
cls, context: interfaces.context.ContextInterface, kernel_name: str
245-
) -> Optional[Iterable[interfaces.objects.ObjectInterface]]:
243+
) -> Generator[interfaces.objects.ObjectInterface, None, None]:
246244
"""Iterate over (ftrace_ops *)ftrace_ops_list.
247245
248246
Returns:

volatility3/framework/plugins/linux/tracing/tracepoints.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import volatility3.framework.symbols.linux.utilities.modules as linux_utilities_modules
1212
from volatility3.plugins.linux import hidden_modules, modxview
13-
from volatility3.framework import constants, exceptions, interfaces, renderers
13+
from volatility3.framework import constants, exceptions, interfaces
1414
from volatility3.framework.configuration import requirements
1515
from volatility3.framework.renderers import format_hints, NotAvailableValue, TreeGrid
1616
from volatility3.framework.symbols.linux import extensions
@@ -197,7 +197,7 @@ def parse_tracepoint(
197197
if hasattr(tracepoint_func, "prio"):
198198
prio = tracepoint_func.prio
199199
else:
200-
prio = renderers.NotAvailableValue()
200+
prio = None
201201

202202
yield ParsedTracepointFunc(
203203
tracepoint_name,
@@ -293,7 +293,7 @@ def _generator(self):
293293
format_hints.Hex(tracepoint_parsed.tracepoint_address),
294294
tracepoint_parsed.probe_name or NotAvailableValue(),
295295
format_hints.Hex(tracepoint_parsed.probe_address),
296-
tracepoint_parsed.probe_priority,
296+
tracepoint_parsed.probe_priority or NotAvailableValue(),
297297
tracepoint_parsed.module_name or NotAvailableValue(),
298298
(
299299
format_hints.Hex(tracepoint_parsed.module_address)

0 commit comments

Comments
 (0)