pub struct MmapNone { /* private fields */ }
Expand description

Represents an inaccessible memory mapping.

Implementations

Yields the file backing this mapping, if this mapping is backed by a file.

Yields a raw immutable pointer of this mapping.

Yields the size of this mapping.

Locks the physical pages in memory such that accessing the mapping causes no page faults.

Unlocks the physical pages in memory, allowing the operating system to swap out the pages backing this memory mapping.

Flushes the memory mapping synchronously, i.e. this function waits for the flush to complete.

Flushes the memory mapping asynchronously.

This function can be used to flush the instruction cache on architectures where this is required.

While the x86 and x86-64 architectures guarantee cache coherency between the L1 instruction and the L1 data cache, other architectures such as Arm and AArch64 do not. If the user modified the pages, then executing the code may result in undefined behavior. To ensure correct behavior a user has to flush the instruction cache after modifying and before executing the page.

Remaps this memory mapping as inaccessible.

In case of failure, this returns the ownership of self.

Remaps this memory mapping as immutable.

In case of failure, this returns the ownership of self.

Remaps this memory mapping as executable.

In case of failure, this returns the ownership of self.

Remaps this memory mapping as executable, but does not flush the instruction cache. Note that this is unsafe.

While the x86 and x86-64 architectures guarantee cache coherency between the L1 instruction and the L1 data cache, other architectures such as Arm and AArch64 do not. If the user modified the pages, then executing the code may result in undefined behavior. To ensure correct behavior a user has to flush the instruction cache after modifying and before executing the page.

In case of failure, this returns the ownership of self.

Remaps this mapping to be mutable.

In case of failure, this returns the ownership of self.

Remaps this mapping to be executable and mutable.

While this may seem useful for self-modifying code and JIT engines, it is instead recommended to convert between mutable and executable mappings using Mmap::make_mut() and MmapMut::make_exec() instead.

As it may be tempting to use this function, this function has been marked as unsafe. Make sure to read the text below to understand the complications of this function before using it. The UnsafeMmapFlags::JIT flag must be set for this function to succeed.

RWX pages are an interesting targets to attackers, e.g. for buffer overflow attacks, as RWX mappings can potentially simplify such attacks. Without RWX mappings, attackers instead have to resort to return-oriented programming (ROP) gadgets. To prevent buffer overflow attacks, contemporary CPUs allow pages to be marked as non-executable which is then used by the operating system to ensure that pages are either marked as writeable or as executable, but not both. This is also known as W^X.

While the x86 and x86-64 architectures guarantee cache coherency between the L1 instruction and the L1 data cache, other architectures such as Arm and AArch64 do not. If the user modified the pages, then executing the code may result in undefined behavior. To ensure correct behavior a user has to flush the instruction cache after modifying and before executing the page.

In case of failure, this returns the ownership of self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.