improving the computation of page struct size (#3346)

pull/3350/head
jxuanli 2 months ago committed by GitHub
parent 9a6f4434ad
commit 7c87ab0f19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -68,13 +68,13 @@ class ArchPagingInfo:
# true with the most common set of configurations
# this struct should always present if a vmlinux is added
return 0x40
return a.sizeof
# needs to be rounded up to a power of 2 (consider the layout of vmemmap)
return 1 << math.ceil(math.log2(a.sizeof))
@property
@pwndbg.lib.cache.cache_until("objfile")
def STRUCT_PAGE_SHIFT(self):
# needs to be rounded up (consider the layout of vmemmap)
return math.ceil(math.log2(self.STRUCT_PAGE_SIZE))
return int(math.log2(self.STRUCT_PAGE_SIZE))
@property
def page_shift(self) -> int:

@ -32,7 +32,7 @@ class KernelVmmap:
self.pages = pages
self.sections = None
self.pi = pwndbg.aglib.kernel.arch_paginginfo()
if self.pi and pwndbg.aglib.kernel.has_debug_symbols():
if self.pi:
self.sections = self.pi.markers()
def get_name(self, addr: int) -> str:

@ -181,9 +181,6 @@ def get_slab_object_address():
# gdb.execute(f"msr MSR_LSTAR -w {prev_msr_lstar}")
@pytest.mark.skipif(
not pwndbg.aglib.kernel.has_debug_symbols(), reason="test requires debug symbols"
)
def test_command_kernel_vmmap():
res = gdb.execute("vmmap", to_string=True)
assert all(

Loading…
Cancel
Save