All Topics  
NX bit

 

   Email Print
   Bookmark   Link






 

NX bit



 
 
The NX bit, which stands for No eXecute, is a technology used in CPUs to segregate areas of memory for use by either storage of processor instructions (or code) or for storage of data, a feature normally only found in Harvard architecture
Harvard architecture

The Harvard architecture is a computer architecture with physically separate computer storage and signal pathways for instructions and data. The term originated from the Harvard Mark I relay-based computer, which stored instructions on punched tape and data in electro-mechanical counters ....
 processors. However, the NX bit is being increasingly used in conventional von Neumann architecture
Von Neumann architecture

The von Neumann architecture is a design model for a stored-program digital computer that uses a central processing unit and a single separate computer storage structure to hold both instructions and data ....
 processors, for security reasons.

An operating system with support for the NX bit may mark certain areas of memory as non-executable.






Discussion
Ask a question about 'NX bit'
Start a new discussion about 'NX bit'
Answer questions from other users
Full Discussion Forum



Encyclopedia


The NX bit, which stands for No eXecute, is a technology used in CPUs to segregate areas of memory for use by either storage of processor instructions (or code) or for storage of data, a feature normally only found in Harvard architecture
Harvard architecture

The Harvard architecture is a computer architecture with physically separate computer storage and signal pathways for instructions and data. The term originated from the Harvard Mark I relay-based computer, which stored instructions on punched tape and data in electro-mechanical counters ....
 processors. However, the NX bit is being increasingly used in conventional von Neumann architecture
Von Neumann architecture

The von Neumann architecture is a design model for a stored-program digital computer that uses a central processing unit and a single separate computer storage structure to hold both instructions and data ....
 processors, for security reasons.

An operating system with support for the NX bit may mark certain areas of memory as non-executable. The processor will then refuse to execute any code residing in these areas of memory. The general technique, known as executable space protection
Executable space protection

In computer security, executable space protection is the marking of Memory regions as non-executable, such that an attempt to execute machine code in these regions will cause an Exception handling....
, is used to prevent certain types of malicious software from taking over computers by inserting their code into another program's data storage area and running their own code from within this section; this is known as a buffer overflow
Buffer overflow

In computer security and computer programming, a buffer overflow, or buffer overrun, is an Anomaly in software condition where a process attempts to store data beyond the boundaries of a fixed-length buffer ....
 attack.

Intel markets the feature as the XD bit, for eXecute Disable. AMD uses the name Enhanced Virus Protection.

Hardware background


x86 processors, since the 80286, included a similar capability implemented at the segment
Memory segment

x86 memory segmentation refers to the implementation of memory segmentation on the x86 architecture. Memory is divided into portions that may be addressed by a single index register without changing a 16-bit segment selector....
 level. However, current operating systems implementing the flat memory model
Flat memory model

In low level software design, a flat memory model refers to the memory addressing paradigm. A flat memory model uses a linear addressing scheme, allowing direct addressing all of the available memory locations....
, do not use this capability. Therefore, Intel introduced a fresh marketing ploy by providing NX, a mechanism that can control execution per page rather than per whole segment.

The page-level mechanism has been around for years in various other processor architectures such as Sun's
Sun Microsystems

Sun Microsystems, Inc. is a multinational corporation vendor of computers, computer components, computer software, and information technology services, founded on February 24, 1982....
 SPARC
SPARC

SPARC is a Reduced Instruction Set Computer microprocessor instruction set Computer architecture originally designed in 1985 by Sun Microsystems....
, Alpha
DEC Alpha

Alpha, originally known as Alpha AXP, was a 64-bit reduced instruction set computer instruction set architecture developed by Digital Equipment Corporation , designed to replace the 32-bit VAX complex instruction set computer ISA and its implementations....
, and IBM
IBM

International Business Machines Corporation, abbreviated IBM and nicknamed "Big Blue" , is a multinational corporation computer technology and consulting corporation headquartered in Armonk, New York, New York, United States....
's PowerPC
PowerPC

PowerPC is a RISC instruction set architecture created by the 1991 Apple Inc.?IBM?Motorola alliance, known as AIM alliance. Originally intended for personal computers, PowerPC CPUs have since become popular embedded system and high-performance processors....
. Intel implemented a similar feature in its Itanium
Itanium

Itanium is the brand name for 64-bit Intel microprocessors that implement the Intel Itanium architecture . Intel has released two processor families using the brand: the original Itanium and the Itanium 2....
 (Merced) processor—having IA-64 architecture—in 2001, but did not bring it to the more popular x86 processor families (Pentium, Celeron, Xeon, etc). In x86 architecture it was implemented by AMD, as NX bit, for use by its AMD64 line of processors, such as the Athlon 64
Athlon 64

The Athlon 64 is an eighth-generation, AMD64-architecture microprocessor produced by AMD, released on September 23, 2003. It is the third processor to bear the name Athlon, and the immediate successor to the Athlon XP....
 and Opteron
Opteron

The Opteron is Advanced Micro Devices's x86 server Central processing unit line, and was the first processor to implement the AMD64 instruction set architecture ....
. The term NX bit seems to have now become commonly used to generically describe similar technologies in other processors.

After AMD's decision to include this functionality in its AMD64 instruction set, Intel implemented a similar feature in x86 processors beginning with the Pentium 4
Pentium 4

The Pentium 4 brand refers to Intel's line of single-core mainstream Desktop computer and laptop central processing units introduced on November 20, 2000 ....
 processors based on later iterations of the Prescott core.

The NX bit specifically refers to bit number 63 (i.e. the most significant bit) of a 64-bit entry in the page table
Page table

A page table is the data structure used by a virtual memory system in a computer operating system to store the mapping between virtual addresses and physical addresses....
. If this bit is set to 0, then code can be executed from that page; if set to 1, code cannot be executed from that page, and anything residing there is assumed to be data. Also note that it is used only with Physical Address Extension
Physical Address Extension

In computing, Physical Address Extension is a feature of x86 and x86-64 processors that enable the use of more than 4 gigabytes of physical memory to be used in 32-bit systems, given appropriate operating system support....
 (PAE) page table format, because the x86's original 32-bit page table format obviously has no bit 63.

A similar functionality was introduced in the Burroughs 5000 in 1961, and retained in its successors at least through 2006. In its implementation of tagged architecture
Tagged architecture

In computer science, a tagged architecture is a particular type of computer architecture where every word of memory constitutes a tagged union, being divided into a number of bits of data, and a tag section that describes the type of the data: how it is to be interpreted, and, if it is a reference, the type of the object that it points t...
, each word of memory had an associated, hidden tag bit designating it code or data. Thus, user programs cannot write or even read a program word, and data words cannot be executed.

Software emulation of feature

Prior to the onset of this feature within the hardware, various operating systems attempted to emulate this feature through software, such as W^X
W^X

W^X is the name of a Computer insecurity feature present in the OpenBSD operating system. It is a memory protection policy whereby every paging in a Process ' address space is either writable or executable, but not both simultaneously ....
 or Exec Shield
Exec Shield

Exec Shield is a project started at Red Hat, Inc in late 2002 with the aim of reducing the risk of worm or other automated remote attacks on Linux systems....
. They are described later in this article.

An operating system
Operating system

An operating system is an interface between hardware and applications; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer....
 with the ability to emulate and/or take advantage of an NX bit may prevent the stack
Call stack

In computer science, a call stack is a dynamic Stack data structure that stores information about the active subroutines of a computer program....
 and heap
Dynamic memory allocation

In computer science, dynamic memory allocation is the allocation of computer storage storage for use in a computer program during the runtime of that program....
 memory areas from being executable, and may prevent executable memory from being writable. This helps to prevent certain buffer overflow
Buffer overflow

In computer security and computer programming, a buffer overflow, or buffer overrun, is an Anomaly in software condition where a process attempts to store data beyond the boundaries of a fixed-length buffer ....
 exploits from succeeding, particularly those that inject and execute code, such as the Sasser and Blaster worms. These attacks rely on some part of memory, usually the stack, to be both writable and executable; if it is not, the attack fails.

Implementations

Many operating systems implement or have an available NX policy, and some implement or have available NX emulation. Here is a list of such systems in alphabetical order, each with technologies ordered from newest to oldest.

For some technologies, there is a summary which gives the major features each technology supports. The summary is structured as below.

  • Hardware Supported Processors: (Comma separated list of CPU architectures)
  • Emulation: (No) or (Architecture Independent) or (Comma separated list of CPU architectures)
  • Other Supported: (None) or (Comma separated list of CPU architectures)
  • Standard Distribution: (No) or (Yes) or (Comma separated list of distributions or versions which support the technology)
  • Release Date: (Date of first release)


A technology supplying Architecture Independent emulation will be functional on all processors which aren't hardware supported. The "Other Supported" line is for processors which allow some grey-area method, where an explicit NX bit doesn't exist yet hardware allows one to be emulated in some way.

FreeBSD

Initial PG_NX support first appeared in FreeBSD
FreeBSD

FreeBSD is a Unix-like free software operating system descended from AT&T Unix via the Berkeley Software Distribution branch through the 386BSD and Berkeley Software Distribution#4.4BSD and descendants operating systems....
 -CURRENT on June 8, 2004 and is a part of FreeBSD since 5.3 release.

Linux

Linux kernel
Linux kernel

The Linux kernel is an operating system kernel used by a family of Unix-like operating systems. The term Linux distribution is used to refer to the various operating systems that run on top of the Linux Kernel....
 currently supports standard hardware NX on CPUs that support it, such as the current 64-bit CPUs of AMD, Intel, Transmeta and VIA.

The support for this feature in the 64-bit mode on x86_64 CPUs was added in 2004 by Andi Kleen, and later the same year, Ingo Molnar
Ingo Molnar

Ingo Moln?r, currently employed by Red Hat, is a Hungary Linux Linux kernel Hacker . He is best-known for his contributions to the operating system in terms of security and performance....
 added support for the NX bit in 32-bit mode on 64-bit CPUs. These features have been in the stable Linux kernel since release 2.6.8 in August 2004.

The availability of the NX bit on 32-bit x86 kernels, which may run on both 32-bit x86 CPUs and 64-bit x86 compatible CPUs, is significant because a 32-bit x86 kernel would not normally expect the NX bit that an AMD64 or IA-64 supplies; the NX enabler patch assures that these kernels will attempt to use the NX bit if present.

Some desktop Linux distribution
Linux distribution

A Linux distribution is a member of the family of Unix-like software distributions built on top of the Linux kernel. Such distributions consist of a large collection of software applications such as word processors, spreadsheets, media players and database applications....
s such as Fedora Core
Fedora (operating system)

Fedora is an RPM Package Manager-based, general purpose operating system built on top of the Linux kernel, developed by the community-supported Fedora Project and sponsored by Red Hat....
 6, Ubuntu and openSUSE
OpenSUSE

openSUSE, , is a general purpose operating system developed by the openSUSE Project. After acquiring SUSE Linux in January 2004, Novell decided to release the SUSE Linux Professional product as a 100% open source project, involving the community in the development process....
 do not enable the HIGHMEM64 option, which is required to gain access to the NX bit in 32-bit mode, in their default kernel; this is because the PAE
Physical Address Extension

In computing, Physical Address Extension is a feature of x86 and x86-64 processors that enable the use of more than 4 gigabytes of physical memory to be used in 32-bit systems, given appropriate operating system support....
 mode that is required to use the NX bit causes pre-Pentium Pro
Pentium Pro

The Pentium Pro is a sixth-generation x86-based microprocessor developed and manufactured by Intel introduced in November 1995. It introduced the Intel P6 and was originally intended to replace the original Pentium in a full range of applications....
 (including Pentium MMX) and Celeron M and Pentium M
Pentium M

The Pentium M brand refers to only two single-core 32-bit x86 microprocessors introduced in March 2003 , and forming a part of the Intel Centrino platform....
 processors without NX support to fail to boot. Other processors that do not support PAE are AMD K6
AMD K6

The K6 microprocessor was launched by AMD in 1997. The main advantage of this particular microprocessor is that it was designed to fit into existing desktop designs for Pentium branded CPUs....
 and earlier, Transmeta Crusoe, VIA C3
VIA C3

The VIA C3 is a family of x86 central processing units for personal computers designed by Centaur Technology and sold by VIA Technologies. The different CPU cores are built following the Centaur Technology#Design_methodology....
 and earlier, and Geode
Geode

Geodes are Geology Rock formations which occur in Sedimentary rocks and certain volcanic rocks. Geodes are essentially rock cavities or vugs with internal crystal formations or concentric banding....
 GX and LX. VMware versions older than 4.0, Parallels versions older than 4.0, and Microsoft Virtual PC does not support PAE on the guest. Fedora Core 6 does provide a kernel-PAE package which supports PAE and NX though.

Non-execute functionality has also been present for other non-x86 processors supporting this functionality for many releases.

Exec Shield
Red Hat
Red Hat

In computing, Red Hat, Inc. is a company in the free and open source software sector, and a major Linux distribution vendor. Founded in 1995, Red Hat has its corporate headquarters in Raleigh, North Carolina with satellite offices worldwide....
 kernel developer Ingo Molnar
Ingo Molnar

Ingo Moln?r, currently employed by Red Hat, is a Hungary Linux Linux kernel Hacker . He is best-known for his contributions to the operating system in terms of security and performance....
 released a Linux kernel patch named Exec Shield
Exec Shield

Exec Shield is a project started at Red Hat, Inc in late 2002 with the aim of reducing the risk of worm or other automated remote attacks on Linux systems....
 to approximate and use NX functionality on 32-bit
32-bit

The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295 or -2,147,483,648 through 2,147,483,647 using two's complement encoding....
 x86 CPUs.

The Exec Shield patch was released to the Linux kernel mailing list
Linux kernel mailing list

The Linux kernel mailing list is the main electronic mailing list for Linux kernel development, where majority of the announcements, discussions, debates, and flame wars over the kernel take place....
 on May 2, 2003. It was rejected for merging with the base kernel because it involved some intrusive changes to core code in order to handle the complex parts of the emulation trick.

  • Hardware Supported Processors: All that Linux supports NX on
  • Emulation: NX approximation using the code segment
    Code segment

    In computing, a code segment, also known as a text segment or simply as text, is a phrase used to refer to a portion of memory or of an object file that contains executable Instruction s....
     limit on IA-32
    IA-32

    IA-32 , often generically called x86 or x86-32, is the instruction set architecture of Intel's most commercially successful microprocessors....
     (x86) and compatible
  • Other Supported: None
  • Standard Distribution: Fedora Core and Red Hat Enterprise Linux
    Red Hat Enterprise Linux

    Red Hat Enterprise Linux is a Linux distribution produced by Red Hat and targeted toward the business market, including Mainframe computer. Red Hat commits to supporting each version of Red Hat Enterprise Linux for 7 years after its release....
  • Release Date: May 2, 2003


PaX
The PaX
Pax

Pax may refer to:* the Latin language word for peace, used in phrases such as Pax Romana ; also, its personification, Pax , goddess of peace in Roman mythology...
 NX technology can emulate an NX bit or NX functionality, or use a hardware NX bit. PaX works on x86 CPUs that do not have the NX bit, such as 32-bit x86.

The PaX project originated October 1, 2000. It was later ported to 2.6, and is at the time of this writing still in active development.

The Linux kernel still does not ship with PaX (as of March, 2008); the patch must be merged manually.

  • Hardware Supported Processors: Alpha, AMD64, IA-64, MIPS
    MIPS architecture

    MIPS is a RISC instruction set architecture developed by MIPS Technologies . In the mid to late 1990s, it was estimated that one in three RISC microprocessors produced were MIPS implementations....
     (32 and 64 bit), PA-RISC, PowerPC
    PowerPC

    PowerPC is a RISC instruction set architecture created by the 1991 Apple Inc.?IBM?Motorola alliance, known as AIM alliance. Originally intended for personal computers, PowerPC CPUs have since become popular embedded system and high-performance processors....
    , SPARC
    SPARC

    SPARC is a Reduced Instruction Set Computer microprocessor instruction set Computer architecture originally designed in 1985 by Sun Microsystems....
  • Emulation: IA-32
    IA-32

    IA-32 , often generically called x86 or x86-32, is the instruction set architecture of Intel's most commercially successful microprocessors....
     (x86)
  • Other Supported: PowerPC
    PowerPC

    PowerPC is a RISC instruction set architecture created by the 1991 Apple Inc.?IBM?Motorola alliance, known as AIM alliance. Originally intended for personal computers, PowerPC CPUs have since become popular embedded system and high-performance processors....
     (32 and 64 bit), SPARC
    SPARC

    SPARC is a Reduced Instruction Set Computer microprocessor instruction set Computer architecture originally designed in 1985 by Sun Microsystems....
     (32 and 64 bit)
  • Standard Distribution: Adamantix, Hardened Gentoo
    Hardened Gentoo

    Hardened Gentoo is a project of Gentoo Linux that is enhancing the distribution with security addons. Current security enhancements to Gentoo Linux can be:...
    , Hardened Linux
  • Release Date: October 1, 2000


Mac OS X

Mac OS X
Mac OS X

Mac OS X is a line of computer operating systems developed, marketed, and sold by Apple Inc., and since 2002 has been included with all new Macintosh computer systems....
 for Intel supports the NX bit and PAE
Physical Address Extension

In computing, Physical Address Extension is a feature of x86 and x86-64 processors that enable the use of more than 4 gigabytes of physical memory to be used in 32-bit systems, given appropriate operating system support....
 on all CPUs supported by Apple (from 10.4.4 – the first Intel release – onwards).

Microsoft Windows

Starting with Windows XP
Windows XP

Windows XP is a line of operating systems produced by Microsoft for use on personal computers, including home and business desktops, laptop, and media centers....
 Service Pack
Service pack

A service pack is a collection of updates, fixes and/or enhancements to a computer program delivered in the form of a single installable package....
 2 and Windows Server 2003
Windows Server 2003

Windows Server 2003 is a Server operating system produced by Microsoft. Introduced on 24 April 2003 as the successor to Windows 2000 Server, it is considered by Microsoft to be the cornerstone of its Windows Server System line of business server products....
 Service Pack 1, the NX features were implemented for the first time on the x86 architecture.

Microsoft Windows uses NX protection on critical Windows service
Windows Service

On Microsoft Windows operating systems, a Windows service is a long-running executable that performs specific functions and which is designed not to require user intervention....
s exclusively by default. Under Windows XP or Server 2003, the feature is called Data Execution Prevention
Data Execution Prevention

Data Execution Prevention is a security feature included in modern Microsoft Windows operating systems that is intended to prevent an Application software or service from executing code from a non-executable memory region....
 (abbreviated DEP), and it can be configured through the advanced tab of "System" properties. If the x86 processor supports this feature in hardware, then the NX features are turned on automatically in Windows XP/Server 2003 by default. If the feature is not supported by the x86 processor, then no protection is given.

"Software DEP" is unrelated to the NX bit, and is what Microsoft calls their enforcement of Safe Structured Exception Handling. Software DEP/SafeSEH checks when an exception is thrown to make sure that the exception is registered in a function table for the application, and requires the program to be built with it.

Early implementations of DEP provided no address space layout randomization
Address space layout randomization

Address space layout randomization is a Computer insecurity technique which involves randomly arranging the positions of key data areas, usually including the base of the executable and position of Library , Dynamic memory allocation, and Stack-based memory allocation, in a Process 's address space....
 (ASLR), which allowed potential return-to-libc attack
Return-to-libc attack

A return-to-libc attack is a computer security attack usually starting with a buffer overflow in which the return statement on the stack is replaced by the address of another function and an additional portion of the stack is overwritten to provide arguments to this function....
s that could have been feasibly used to . The PaX
Pax

Pax may refer to:* the Latin language word for peace, used in phrases such as Pax Romana ; also, its personification, Pax , goddess of peace in Roman mythology...
 documentation on why ASLR is necessary; a was produced detailing a method by which DEP could be circumvented in the absence of ASLR. It may be possible to develop a successful attack if the address of prepared data such as corrupted images or MP3
MP3

MPEG-1 Audio Layer 3, more commonly referred to as MP3, is a digital audio Encoder format using a form of lossy data compression. It is a common audio format for consumer audio storage, as well as a de facto standard encoding for the transfer and playback of music on digital audio players....
s can be known by the attacker. Microsoft added ASLR functionality in Windows Vista
Windows Vista

Windows Vista is one member in a family of operating systems developed by Microsoft for use on personal computers, including home and business Desktop computer, laptops, Tablet PCs, and media center PCs....
 and Windows Server 2008 to address this avenue of attack.

Outside of the x86 sphere, a version of NX also exists for Intel's IA-64 which is implemented in Windows on that architecture.

  • Hardware Supported Processors: x86-64
    X86-64

    x86-64 is a superset of the x86. x86-64 Central processing units can run existing 32-bit or 16-bit x86 programs at full speed, but also support new programs written with a 64-bit address space and other additional capabilities....
     (AMD64 and Intel 64), IA-64, Efficeon, Pentium M
    Pentium M

    The Pentium M brand refers to only two single-core 32-bit x86 microprocessors introduced in March 2003 , and forming a part of the Intel Centrino platform....
     (later revisions), AMD Sempron (later revisions)
  • Emulation: No
  • Other Supported: None
  • Standard Distribution: Windows XP
    Windows XP

    Windows XP is a line of operating systems produced by Microsoft for use on personal computers, including home and business desktops, laptop, and media centers....
     Service Pack 2, Windows Server 2003
    Windows Server 2003

    Windows Server 2003 is a Server operating system produced by Microsoft. Introduced on 24 April 2003 as the successor to Windows 2000 Server, it is considered by Microsoft to be the cornerstone of its Windows Server System line of business server products....
     Service Pack 1, Windows XP Professional x64 Edition, Windows Vista
    Windows Vista

    Windows Vista is one member in a family of operating systems developed by Microsoft for use on personal computers, including home and business Desktop computer, laptops, Tablet PCs, and media center PCs....
  • Release Date: August 6, 2004


NetBSD

As of NetBSD
NetBSD

NetBSD is a freely redistributable, open source version of the Unix-derivative Berkeley Software Distribution computer operating system. It was the second open source BSD descendant to be formally released, after 386BSD, and continues to be actively developed....
 2.0 and later (December 9, 2004), architectures which support it have non-executable stack and heap.

Those which have per-page granularity consist of: amd64, sparc64, sparc (sun4m, sun4d), powerpc (ibm4xx), alpha, sh5, hppa.

Those which can only support these with region granularity are: powerpc (eg. macppc), i386.

Other architectures do not benefit from non-executable stack or heap, NetBSD not by default using any software emulation to offer these features.

OpenBSD


W^X
A technology in the OpenBSD
OpenBSD

OpenBSD is a Unix-like computer operating system descended from Berkeley Software Distribution , a Unix derivative developed at the University of California, Berkeley....
 operating system
Operating system

An operating system is an interface between hardware and applications; it is responsible for the management and coordination of activities and the sharing of the limited resources of the computer....
, known as W^X
W^X

W^X is the name of a Computer insecurity feature present in the OpenBSD operating system. It is a memory protection policy whereby every paging in a Process ' address space is either writable or executable, but not both simultaneously ....
, currently takes advantage of the NX bit in the AMD64 port. OpenBSD also supports W^X on some CPUs without an NX bit.

W^X makes use of the NX bit on Alpha, AMD64, HPPA, and SPARC
SPARC

SPARC is a Reduced Instruction Set Computer microprocessor instruction set Computer architecture originally designed in 1985 by Sun Microsystems....
 processors. Intel 64 processors may or may not be supported, depending on hardware. Intel added the NX (called XD by Intel) support to its later chips.

OpenBSD 3.3 shipped May 1, 2003, and was the first operating system to include W^X.

  • Hardware Supported Processors: Alpha
    DEC Alpha

    Alpha, originally known as Alpha AXP, was a 64-bit reduced instruction set computer instruction set architecture developed by Digital Equipment Corporation , designed to replace the 32-bit VAX complex instruction set computer ISA and its implementations....
    , AMD64, HPPA, SPARC
    SPARC

    SPARC is a Reduced Instruction Set Computer microprocessor instruction set Computer architecture originally designed in 1985 by Sun Microsystems....
  • Emulation: IA-32
    IA-32

    IA-32 , often generically called x86 or x86-32, is the instruction set architecture of Intel's most commercially successful microprocessors....
     (x86)
  • Other Supported: None
  • Standard Distribution: Yes
  • Release Date: May 1, 2003


Solaris


Solaris
Solaris Operating System

Solaris is a Unix-based operating system introduced by Sun Microsystems in 1992 as the successor to SunOS.Solaris is known for its scalability, especially on SPARC systems, and for originating many innovative features such as DTrace and ZFS....
 has supported globally disabling stack execution on SPARC processors since Solaris 2.6 (1997); in Solaris 9 (2002), support for disabling stack execution on a per-executable basis was added.

As of Solaris 10 (2005), NX protection is automatically enabled by default on x86 processors that support this feature. Exceptions are made for the 32-bit legacy ABI's treatment of a program's stack segment. The vast majority of programs will work without changes. However, if a program fails, the protection may be disabled via the enforce-prot-exec EEPROM option. Sun recommends that failures should be reported as program bugs.

Functional comparison of technologies

Here, features of the NX technologies will be compared and contrasted.

Generally, NX bit emulation is available only on x86 CPUs. The sections within dealing with emulation are concerned only with x86 CPUs unless otherwise stated.

While it has been proven that some NX bit emulation methods incur an extremely low overhead, it has also been proven that such methods can become inaccurate. On the other hand, other methods may incur an extremely high overhead and be absolutely accurate. No method has been discovered as of yet without a significant trade-off, whether in processing power, accuracy, or virtual memory space.

Overhead

Overhead is the amount of extra CPU processing power that is required for each technology to function. It is important because technologies which somehow emulate or supply an NX bit will usually impose a measurable overhead; while using a hardware supplied NX bit will impose no measurable overhead. All technologies create overhead due to the extra programming logic that must be created to control the state of the NX bit for various areas of memory; however, evaluation usually handled by the CPU itself when a hardware NX bit exists, and thus produces no overhead.

On CPUs supplying a hardware NX bit, none of the listed technologies imposes any significant measurable overhead unless explicitly noted.

Exec Shield
Exec Shield's legacy CPU support approximates (Ingo Molnar's word for it) NX emulation by tracking the upper code segment limit. This imposes only a few cycles of overhead during context switches, which is for all intents and purposes immeasurable.

PaX
PaX
Pax

Pax may refer to:* the Latin language word for peace, used in phrases such as Pax Romana ; also, its personification, Pax , goddess of peace in Roman mythology...
 supplies two methods of NX bit emulation, called SEGMEXEC and PAGEEXEC.

The SEGMEXEC method imposes a measurable but low overhead, typically less than 1%. This is a constant scalar incurred due to the virtual memory mirroring used. SEGMEXEC also has the effect of halving the task's virtual address space, allowing the task to access less memory than it normally could. This is not a problem until the task requires access to more than half the normal address space, which is rare. SEGMEXEC does not cause programs to use more system memory (i.e. RAM); it only restricts how much they can access. On 32-bit CPUs, this becomes 1.5 GiB
Gib

Gib may refer to:* A castrated male cat or ferret* Gibibit , a unit of information used, for example, to quantify computer memory or storage capacity...
 rather than 3 GiB.

PaX supplies a method similar to Exec Shield's approximation in the PAGEEXEC as a speedup; however, when higher memory is marked executable, this method loses its protections. In these cases, PaX falls back to the older, variable overhead method used by PAGEEXEC to protect pages below the CS limit, which may become a quite high overhead operation in certain memory access patterns.

When the PAGEEXEC method is used on a CPU supplying a hardware NX bit, the hardware NX bit is used; no emulation is used, thus no significant overhead is incurred.

Accuracy

Some technologies approximately emulate (or approximate) an NX bit on CPUs which do not support them. Others strictly emulate an NX bit for these CPUs, but decrease performance or virtual memory space significantly. Here, these methods will be compared for accuracy.

All technologies listed here are 100% accurate in the presence of a hardware NX bit, unless otherwise stated.

Exec Shield
For legacy CPUs without an NX bit, Exec Shield fails to protect pages below the code segment limit; an mprotect call to mark higher memory, such as the stack, executable will mark all memory below that limit executable as well. Thus, in these situations, Exec Shield's schemes fails. This is the cost of Exec Shield's low overhead (see above).

PaX
SEGMEXEC does not rely on such volatile systems as that used in Exec Shield, and thus does not encounter conditions in which finegrained NX bit emulation cannot be enforced; it does, however, have the halving of virtual address space mentioned above.

PAGEEXEC will fall back to the original PAGEEXEC method used before the speed-up when data pages exist below the upper code segment limit. In both cases, PaX' emulation remains 100% accurate; no pages will become executable unless the operating system explicitly makes them as such.

It is also interesting to note that PaX supplies mprotect restrictions to prevent programs from marking memory in ways which produce memory useful for a potential exploit. This policy causes certain applications to cease to function; but can be disabled for affected programs.

Control over restrictions

Some technologies allow executable programs to be marked so that the operating system knows to relax the restrictions imposed by the NX technology for that particular program. Various systems provide various controls; such controls are described here.

Exec Shield
Exec Shield supplies executable markings. Exec Shield only checks for two ELF header markings, which dictate whether the stack or heap needs to be executable. These are called PT_GNU_STACK and PT_GNU_HEAP, respectively. Exec Shield allows these controls to be set for both binary executables and for libraries; if an executable loads a library requiring a given restriction relaxed, the executable will inherit that marking and have that restriction relaxed.

PaX
PaX supplies fine-grained control over protections. It allows individual control over the following functions of the technology for each binary executable:

  • Executable space protection
    Executable space protection

    In computer security, executable space protection is the marking of Memory regions as non-executable, such that an attempt to execute machine code in these regions will cause an Exception handling....
    s
    • PAGEEXEC
    • SEGMEXEC
  • mprotect restrictions
  • Trampoline emulation
  • Randomized executable base
  • Randomized mmap base


See the PaX article for more details about these restrictions.

PaX completely ignores both PT_GNU_STACK and PT_GNU_HEAP. There was a point in time when PaX had a configuration option to honor these settings; that option has henceforth been intentionally removed for security reasons, as it was deemed not useful. The same results of PT_GNU_STACK can normally be attained by disabling mprotect restrictions, as the program will normally mprotect the stack on load. This may not always be true; for situations where this fails, simply disabling both PAGEEXEC and SEGMEXEC will effectively remove all executable space restrictions, giving the task the same protections on its executable space as a non-PaX system.

Windows
When NX is supported, it is enabled by default. Windows allows programs to control which pages disallow execution through its API
Application programming interface

An application programming interface is a set of subroutine, data structures, class and/or Protocol provided by library and/or operating system Service s in order to support the building of applications....
 as well as through the section headers in a PE file
Portable Executable

The Portable Executable format is a file format for executables, object file, and Dynamic-link librarys, used in 32-bit and 64-bit versions of Microsoft Windows operating systems....
.

In the API, runtime access to the NX bit is exposed through the Win32 API calls VirtualAlloc[Ex] and VirtualProtect[Ex]. In these functions, a page protection setting is specified by the programmer. Each page may be individually flagged as executable or non-executable. Despite the lack of previous x86 hardware support, both executable and non-executable page settings have been provided since the beginning. On pre-NX CPUs, the presence of the 'executable' attribute has no effect. It was documented as if it did function, and, as a result, most programmers used it properly.

In the PE file format, each section can specify its executability. The execution flag has existed since the beginning of the format; standard linker
Linker

In computer science, a linker or link editor is a computer program that takes one ormore object file generated by a compiler and combines them into a single executable program....
s have always used this flag correctly, even long before the NX bit.

Because of these things, Windows is able to enforce the NX bit on old programs. Assuming the programmer complied with "best practices", applications should work correctly now that NX is actually enforced. Only in a few cases have there been problems; Microsoft's own .NET Runtime had problems with the NX bit and was updated.

Xbox
In Microsoft's Xbox
Xbox

The Xbox is a History of video games video game console produced by Microsoft. It was Microsoft's first foray into the gaming console market, and competed with Sony's PlayStation 2 and Nintendo's GameCube....
, although the CPU does not have the NX bit, newer versions of the XDK set the code segment limit to the beginning of the kernel's .data section (no code should be after this point in normal circumstances). This was probably in response to the 007: Agent Under Fire saved game exploit; however, this change does not fix the problem, as the memory from which the payload executes is well below the beginning of the kernel's .data section.

Starting with version 51xx, this change was also implemented into the kernel of new Xboxes. This broke the techniques old exploits used to become a TSR
Terminate and Stay Resident

Terminate and Stay Resident is a computer system call in DOS computer operating systems that returns control to the system as if the program has quit, but keeps the program in memory....
; new versions were quickly released supporting this new version because the fundamental exploit was unaffected.

External links