Skip to main content

patch_ioctl_slot

Function patch_ioctl_slot 

Source
unsafe fn patch_ioctl_slot(slot: *mut *mut c_void)
Expand description

Repoint one ioctl GOT slot to filtered_ioctl.

  1. Make the page writable: read the slot’s current protection via page_prot (defaulting to read/write when maps is unreadable) and mprotect the page to PROT_READ | PROT_WRITE.
  2. Publish the new pointer atomically: store filtered_ioctl into the slot with an AtomicPtr Release store, since another thread may be dispatching through this GOT slot concurrently and the write must not tear.
  3. Restore protection: return the page to its original protection rather than a hardcoded read-only — under partial RELRO these libraries lazily bind through this page, so leaving it read-only would fault the next symbol resolve.