Linux kernel memory protection

When the shared library is mapped into memory, the Linux kernel will assign virtual memory regions to that memory region and accordingly mark their permissions. But we know that in the x86 arch page table entry there is no executable bit. If the program calls the call command * invoke * edx to invoke a function in the shared library, how can the Linux kernel know if the destination address is executable or not? Will this cause a common security error if the resolution is not compatible in the vma list?

+4
source share
2 answers

He can not.

In an architecture (/ mode of operation), where there is no permission to execute a page other than read permission, the kernel will not be able to detect allegedly illegal address execution as a result of an error detected by the MMU.

+3
source

You are right that, in theory, the kernel can decide based on finer permissions for the memory region object, but such a decision-making procedure should be in the page error handler, which (I suppose) would make access to ordinary memory very expensive.

Instead, the kernel uses these x86 simplification rules:

  • the right of access to reading always implies the right to access.
  • The right to write access always implies the right to read.

Source: Understanding the Linux Kernel, 1st Edition, p. 205

0
source

All Articles