WIPIVERSE All articles

Ring protection

Ring protection (also called protection rings or hierarchical protection domains) is a mechanism in computer science used to protect data and functionality from faults and malicious behavior. It is a hardware-enforced system of hierarchical privilege levels implemented by certain CPU architectures.

Overview

A protection ring is one of two or more hierarchical levels or layers of privilege within the architecture of a computer system. Rings are arranged in a hierarchy from most privileged (most trusted, usually numbered zero) to least privileged (least trusted, usually with the highest ring number). On most operating systems, Ring 0 is the level with the most privileges and interacts most directly with physical hardware, such as control registers and I/O controllers.

Special mechanisms allow an outer ring to access an inner ring's resources only in a predefined manner, rather than allowing arbitrary usage. Correctly gating access between rings improves security by preventing programs in one ring from misusing resources intended for programs in another.

History

Multiple rings of protection were among the most revolutionary concepts introduced by the Multics operating system, a highly secure predecessor of the Unix family. The GE 645 mainframe had some hardware access control but insufficient support for rings in hardware, so Multics initially supported them by trapping ring transitions in software. Its successor, the Honeywell 6180, implemented them in hardware with support for eight rings.

Implementation in x86 Architecture

The x86 architecture provides four privilege levels (rings), ranging from 0 (most privileged) to 3 (least privileged):

  • Ring 0 – Kernel mode; the operating system kernel runs here with full access to all hardware and instructions.
  • Ring 1 and Ring 2 – Intermediate privilege levels; rarely used by modern operating systems.
  • Ring 3 – User mode; application programs run here with restricted access.

Most general-purpose operating systems (Windows, Linux, macOS) use only two rings: Ring 0 for kernel mode and Ring 3 for user mode. This is partly because some hardware architectures that these operating systems have supported in the past (such as PowerPC or MIPS) implemented only two privilege levels.

OS/2 made partial use of three rings: Ring 0 for kernel code and device drivers, Ring 2 for privileged code (user programs with I/O access permissions), and Ring 3 for unprivileged code.

Extended Ring Concepts

In x86 systems, additional privilege levels are sometimes referred to with negative ring numbers:

  • Ring −1 – x86 hardware virtualization (Intel VT-x and AMD-V), used by hypervisors.
  • Ring −2 – System Management Mode (SMM).
  • Ring −3 – Intel Management Engine (ME) and AMD Platform Security Processor (PSP).

Supervisor Mode

Supervisor mode (also called kernel mode or privileged mode) is a hardware-mediated flag that allows execution of all instructions, including privileged ones. It may also provide access to a different address space, memory management hardware, and other peripherals. In a monolithic kernel, the operating system runs in supervisor mode while applications run in user mode.

Hypervisor Mode

Intel VT-x and AMD-V provide x86 virtualization instructions that allow a hypervisor to control Ring 0 hardware access. These technologies allow a guest operating system to run Ring 0 operations natively without affecting other guests or the host OS. VT-x introduces VMX Root Operation (for the hypervisor) and VMX Non-Root Operation (for guest operating systems).

Criticism

Maurice Wilkes wrote that "it eventually became clear that the hierarchical protection that rings provided did not closely match the requirements of the system programmer and gave little or no improvement on the simple system of having two modes only." The attractiveness of fine-grained protection remained, but rings of protection were seen as not providing the answer.

Modern Usage

The canceled Intel x86S architecture (published in 2024) was to remove Rings 1 and 2, keeping only Ring 0 and Ring 3, since modern operating systems do not utilize the intermediate rings. ARM architecture implements its own variant: ARMv7 uses three privilege levels (PL0, PL1, PL2), and ARMv8 uses four exception levels (EL0 through EL3).

Browse

More topics to explore

    Browse all articles