Struct framehop::aarch64::PtrAuthMask
source · pub struct PtrAuthMask(pub u64);
Expand description
Aarch64 CPUs support special instructions which interpret pointers as pair of the pointer address and an encrypted hash: The address is stored in the lower bits and the hash in the high bits. These are called “authenticated” pointers. Special instructions exist to verify pointers before dereferencing them.
Return address can be such authenticated pointers. To return to an authenticated return address, the “retab” instruction is used instead of the regular “ret” instruction.
Stack walkers need to strip the encrypted hash from return addresses because they need the raw code address.
On macOS arm64, system libraries compiled with the arm64e target use pointer pointer authentication for return addresses.
Tuple Fields§
§0: u64
Implementations§
source§impl PtrAuthMask
impl PtrAuthMask
sourcepub fn new_no_strip() -> Self
pub fn new_no_strip() -> Self
Create a no-op mask which treats all bits of the pointer as address bits, so no bits are stripped.
sourcepub fn new_24_40() -> Self
pub fn new_24_40() -> Self
Create a mask for 24 bits hash + 40 bits pointer. This appears to be what macOS arm64e uses. It is unclear whether we can rely on this or whether it can change.
On macOS arm64, this mask can be applied to both authenticated pointers and to non-authenticated pointers without data loss; non-authenticated don’t appear to use the top 24 bits (they’re always zero).
sourcepub fn from_max_known_address(address: u64) -> Self
pub fn from_max_known_address(address: u64) -> Self
Deduce a mask based on the highest known address. The leading zero bits in this address will be reserved for the hash.
sourcepub fn strip_ptr_auth(&self, ptr: u64) -> u64
pub fn strip_ptr_auth(&self, ptr: u64) -> u64
Apply the mask to the given pointer.
Trait Implementations§
source§impl Clone for PtrAuthMask
impl Clone for PtrAuthMask
source§fn clone(&self) -> PtrAuthMask
fn clone(&self) -> PtrAuthMask
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for PtrAuthMask
impl Debug for PtrAuthMask
source§impl Hash for PtrAuthMask
impl Hash for PtrAuthMask
source§impl Ord for PtrAuthMask
impl Ord for PtrAuthMask
source§fn cmp(&self, other: &PtrAuthMask) -> Ordering
fn cmp(&self, other: &PtrAuthMask) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for PtrAuthMask
impl PartialEq for PtrAuthMask
source§fn eq(&self, other: &PtrAuthMask) -> bool
fn eq(&self, other: &PtrAuthMask) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for PtrAuthMask
impl PartialOrd for PtrAuthMask
source§fn partial_cmp(&self, other: &PtrAuthMask) -> Option<Ordering>
fn partial_cmp(&self, other: &PtrAuthMask) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more