optimizing `first_kernel_ro_page` part 2 (#3395)

* optimizing `first_kernel_ro_page` part 2

* Improve comment clarity

Clarified comment about kernel text search optimization.
pull/3397/head
jxuanli 1 month ago committed by GitHub
parent 17979d4c1a
commit e91e883e59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -131,7 +131,9 @@ def first_kernel_ro_page() -> pwndbg.lib.memory.Page | None:
if result:
return mapping
for mapping in fallback_mappings:
# optimization: observe that the first Linux kernel region is the kernel text so search it last
# it now finds the first ro page almost instantly even for kernels that are partially initialized
for mapping in fallback_mappings[1:] + [fallback_mappings[0]]:
# this loop handles when the kernel has not finished initialization
# and the permission of the first ro page has not been properly set
result = next(pwndbg.search.search(b"Linux version", mappings=[mapping]), None)

Loading…
Cancel
Save