c - How does mprotect() work? -


i stracing of common commands in linux kernel, , saw mprotect() used lot many times. i'm wondering, deciding factor mprotect() uses find out memory address setting protection value for, in own address space?

on architectures mmu1, address mprotect() takes argument virtual address. each process has own independent virtual address space, there's 2 possibilities:

  • the requested address within process's own address range; or
  • the requested address within kernel's address range (which mapped every process).

mprotect() works internally altering flags attached vma2. first thing must vma corresponding address passed - if passed address within kernel's address range, there no vma, , search fail. same thing happens if try change protections on area of address space not mapped.

you can see representation of vmas in process's address space examining /proc/<pid>/smaps or /proc/<pid>/maps.


1. memory management unit
2. virtual memory area, kernel data structure describing contiguous section of process's memory.


Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -