8

Does the Linux kernel use DEP internally for its kernel memory? In other words, does the Linux kernel take care to ensure that, when the kernel is executing (in kernel mode), every executable location in memory is non-writeable, and every writeable location in memory is non-executable?

I've tried searching, but it's hard to find anything, both because most references about DEP in Linux refer to whether user-level address space has DEP protection, as well as because in the Linux kernel context, I get many hits that match on "dep" as the file extension. I recently learned that the Linux kernel doesn't presently use ASLR for kernel memory, for a variety of understandable reasons, which led me to wonder whether it uses DEP.

  • I believe it uses hw-enforced DEP where available, although I'd like someone to confirm this – Marco A. May 6 '14 at 7:48
  • I don't know for Linux, but you might want to know it's the case for Windows. 32-bit flavors comes with DEP applied by default to the stack, and 64-bit comes with stack, paged pool, and session pool as well. – ack__ May 7 '14 at 13:07
4

According to “Extending the use of RO and NX”, the Linux kernel applies DEP on architectures that supports it (such as arm and amd64, but not 32-bit x86) since kernel version 2.6.38 (I don't know if RHEL/CentOS have applied a similar patch to their kernel — a lot of the work on DEP originated from Red Hat).

The W^X principle is mostly followed, but not completely: some pages are left W+X, because otherwise it breaks some BIOS. (Don't you love x86?)

DEP was in the grsecurity patch well before it hit the main line.

  • Note that it's called NX under Linux (and virtually all other systems). "DEP" is a Windows-specific term. – forest Nov 1 '18 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.