Skip to main content

page_prot

Function page_prot 

Source
fn page_prot(addr: usize) -> i32
Expand description

Reports the current PROT_* protection of the page holding addr (from /proc/self/maps, or -1 when the address is not found or maps is unreadable) for two reasons the GOT patch depends on: so it can refuse to dereference an address that a wrong relative/absolute guess landed in an unreadable page, and so it can restore a patched GOT page to its true original protection rather than a hardcoded read-only.

Each maps line begins lo-hi perms ...; the address range and the rwxp permission string are the first two whitespace fields. For the line whose [lo, hi) range contains addr, the r, w, and x characters are translated into PROT_READ/PROT_WRITE/PROT_EXEC.