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.
    Commented May 6, 2014 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__
    Commented May 7, 2014 at 13:07

1 Answer 1


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
    Commented Nov 1, 2018 at 7:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .