1313
1414from volatility3 .framework import constants , exceptions , objects , interfaces , symbols
1515from volatility3 .framework .renderers import conversion
16- from volatility3 .framework .constants .linux import SOCK_TYPES , SOCK_FAMILY
17- from volatility3 .framework .constants .linux import IP_PROTOCOLS , IPV6_PROTOCOLS
18- from volatility3 .framework .constants .linux import TCP_STATES , NETLINK_PROTOCOLS
19- from volatility3 .framework .constants .linux import ETH_PROTOCOLS , BLUETOOTH_STATES
20- from volatility3 .framework .constants .linux import BLUETOOTH_PROTOCOLS , SOCKET_STATES
21- from volatility3 .framework .constants .linux import CAPABILITIES , PT_FLAGS
16+ from volatility3 .framework .constants .linux import (
17+ SOCK_TYPES ,
18+ SOCK_FAMILY ,
19+ IP_PROTOCOLS ,
20+ IPV6_PROTOCOLS ,
21+ TCP_STATES ,
22+ NETLINK_PROTOCOLS ,
23+ ETH_PROTOCOLS ,
24+ BLUETOOTH_STATES ,
25+ BLUETOOTH_PROTOCOLS ,
26+ SOCKET_STATES ,
27+ CAPABILITIES ,
28+ PT_FLAGS ,
29+ MODULE_MAXIMUM_CORE_SIZE ,
30+ MODULE_MAXIMUM_CORE_TEXT_SIZE ,
31+ MODULE_MINIMUM_SIZE ,
32+ )
33+
2234from volatility3 .framework .layers import linear
2335from volatility3 .framework .objects import utility
2436from volatility3 .framework .symbols import generic , linux , intermed
@@ -36,16 +48,23 @@ def __init__(self, *args, **kwargs):
3648 self ._mod_mem_type = None # Initialize _mod_mem_type to None for memoization
3749
3850 def is_valid (self ):
51+ """Determine whether it is a valid module object by verifying the self-referential
52+ in module_kobject. This also confirms that the module is actively allocated and
53+ not a remnant of freed memory or a failed module load attempt by verifying the
54+ module memory section sizes.
55+ """
3956 layer = self ._context .layers [self .vol .layer_name ]
4057 # Make sure the entire module content is readable
4158 if not layer .is_valid (self .vol .offset , self .vol .size ):
4259 return False
4360
4461 core_size = self .get_core_size ()
62+ core_text_size = self .get_core_text_size ()
63+ init_size = self .get_init_size ()
4564 if not (
46- 1 <= core_size <= 20000000
47- and core_size + self . get_init_size () >= 4096
48- and 1 <= self . get_core_text_size () <= 20000000
65+ 0 < core_text_size <= MODULE_MAXIMUM_CORE_TEXT_SIZE
66+ and 0 < core_size <= MODULE_MAXIMUM_CORE_SIZE
67+ and core_size + init_size >= MODULE_MINIMUM_SIZE
4968 ):
5069 return False
5170
0 commit comments