All Topics  
Ring (computer security)

 

   Email Print
   Bookmark   Link






 

Ring (computer security)



 
 
In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, hierarchical protection domains, often called protection rings, are a mechanism to protect data and functionality from faults (fault tolerance) and malicious behaviour (computer security
Computer security

Computer security is a branch of technology known as information security as applied to computers. The objective of computer security can include protection of information from theft or corruption, or the preservation of availability, as defined in the security policy....
). This approach is diametrically opposite to that of capability-based security
Capability-based security

Capability-based security is a concept in the design of secure computing systems. A capability is a communicable, unforgeable token of authority....
.

Computer operating systems provide different levels of access to resources. A protection ring is one of two or more hierarchical levels or layers of privilege within the architecture of a computer system.






Discussion
Ask a question about 'Ring (computer security)'
Start a new discussion about 'Ring (computer security)'
Answer questions from other users
Full Discussion Forum



Encyclopedia


In computer science
Computer science

Computer science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems....
, hierarchical protection domains, often called protection rings, are a mechanism to protect data and functionality from faults (fault tolerance) and malicious behaviour (computer security
Computer security

Computer security is a branch of technology known as information security as applied to computers. The objective of computer security can include protection of information from theft or corruption, or the preservation of availability, as defined in the security policy....
). This approach is diametrically opposite to that of capability-based security
Capability-based security

Capability-based security is a concept in the design of secure computing systems. A capability is a communicable, unforgeable token of authority....
.

Computer operating systems provide different levels of access to resources. A protection ring is one of two or more hierarchical levels or layers of privilege within the architecture of a computer system. This is generally hardware-enforced by some CPU
Central processing unit

A central processing unit is an electronic circuit that can execute computer programs. This broad definition can easily be applied to many early computers that existed long before the term "CPU" ever came into widespread usage....
 architecture
Computer architecture

Computer architecture in computer engineering is the conceptual design and fundamental operational structure of a computer system. It is a blueprint and functional description of requirements and design implementations for the various parts of a computer, focusing largely on the way by which the central processing unit performs internally an...
s that provide different CPU modes
CPU modes

CPU modes are operating modes for the central processing unit of some computer architectures that place restrictions on the operations that can be performed by the Process currently running in the CPU....
 at the firmware
Firmware

Firmware is a term sometimes used to denote the fixed, usually rather small, programs that internally control various electronic devices. Typical examples range from end user products such as remote controls or calculators, via computer parts and devices like harddisks, keyboard s, TFT screens or memory cards, all the way to scientific instr...
 level. 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 the physical hardware such as the CPU and memory.

Special gates between rings are provided to allow an outer ring to access an inner ring's resources in a predefined manner, as opposed to allowing arbitrary usage. Correctly gating access between rings can improve security by preventing programs from one ring or privilege level from misusing resources intended for programs in another. For example, spyware running as a user program in Ring 3 should be prevented from turning on a web camera without informing the user, since hardware access should be a Ring 1 function reserved for device drivers
Device driver

In computing, a device driver or software driver is a computer program allowing higher-level computer programs to interact with a hardware device....
. Programs such as web browsers running in higher numbered rings must request access to the network, a resource restricted to a lower numbered ring.

Implementations


Hardware supported rings were among the more revolutionary concepts introduced by the Multics
Multics

Multics was an extremely influential early time-sharing operating system. The project was started in 1964. The last known running Multics installation was shut down on October 30, 2000....
 operating system, a highly secure predecessor of today's UNIX
Unix

Unix is a computer operating system originally developed in 1969 by a group of American Telephone & Telegraph employees at Bell Labs, including Ken Thompson , Dennis Ritchie, Douglas McIlroy, and Joe Ossanna....
 family of operating systems. However, most general-purpose UNIX systems use only two rings, even if the hardware it runs on provides more CPU modes
CPU modes

CPU modes are operating modes for the central processing unit of some computer architectures that place restrictions on the operations that can be performed by the Process currently running in the CPU....
 than that.

Many modern CPU architectures (including the popular Intel x86 architecture) include some form of ring protection, although the Windows NT
Windows NT

Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was originally designed to be a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix....
 operating system, like Unix, does not fully exploit this feature. Its predecessor, OS/2
OS/2

OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "IBM Personal System/2 " line of second-generation personal computers....
, did to some extent, as it used 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 (nearly all user programs).

There has been a renewed interest in this design structure, with the proliferation of the Xen
Xen

Xen is a Hypervisor for IA-32 , IA-64 and PowerPC 970 architectures. It allows several guest operating systems to be executed on the same computer hardware concurrently....
 VMM software, ongoing discussion
Tanenbaum-Torvalds debate

The Tanenbaum?Torvalds debate is a debate between Andrew S. Tanenbaum and Linus Torvalds, regarding Linux kernel and kernel architecture in general....
 on monolithic
Monolithic kernel

A monolithic kernel is a Kernel architecture where the entire operating system is run in kernel space as supervisor mode. In difference with other architectures , the monolithic kernel defines alone a high-level virtual interface over computer hardware, with a set of primitives or system calls to implement all operating system services such...
- vs. micro-kernel
Microkernel

In computer science, a microkernel is a computer kernel which provides the mechanisms needed to implement an operating system, such as low-level address space management, thread management, and inter-process communication....
 (particularly in Usenet
Usenet

Usenet, a portmanteau of "user" and "network", is a worldwide distributed Internet discussion system. It evolved from the general purpose UUCP architecture of the same name....
 newsgroups and Web forums), Microsoft's Ring-1 design structure as part of their NGSCB
Next-Generation Secure Computing Base

The Next-Generation Secure Computing Base , formerly known as Palladium, is a software architecture designed by Microsoft which is expected to implement parts of the controversial "Trusted Computing" concept on future versions of the Microsoft Windows operating system....
 initiative and hypervisor
Hypervisor

A hypervisor, also called virtual machine monitor , is a computer hardware platform virtualization software that allows multiple operating systems to run on a host computer concurrently....
s embedded in firmware
Firmware

Firmware is a term sometimes used to denote the fixed, usually rather small, programs that internally control various electronic devices. Typical examples range from end user products such as remote controls or calculators, via computer parts and devices like harddisks, keyboard s, TFT screens or memory cards, all the way to scientific instr...
 such as Intel VT (formerly Vanderpool).

The original Multics system had eight rings, but many modern systems have fewer. The hardware is aware of the current ring of the executing instruction thread
Thread (computer science)

In computer science, a thread of execution is a Fork of a computer program into two or more Concurrency running task s. The implementation of threads and process es differs from one operating system to another, but in most cases, a thread is contained inside a process....
 at all times, thanks to special machine registers. In some systems, areas of virtual memory are also assigned ring numbers in hardware, and/or the most privileged ring is given special capabilities (such as real memory addressing that bypasses the virtual-memory
Virtual memory

Virtual memory is a computer system technique which gives an application program the impression that it has contiguous working memory , while in fact it may be physically fragmented and may even overflow on to disk storage....
 hardware).

The hardware severely restricts the ways in which control can be passed from one ring to another, and also enforces restrictions on the types of memory access that can be performed across rings. Typically there is a special gate or call instruction that transfers control in a secure way towards predefined entry points in lower-level (more trusted) rings; this functions as a supervisor call in many operating systems that use the ring architecture. The hardware restrictions are designed to limit opportunities for accidental or malicious breaches of security.

Ring protection can be combined with processor modes (master/kernel/privileged mode versus slave/user/unprivileged mode) in some systems. Operating systems running on hardware supporting both may use both forms of protection or only one.

Effective use of ring architecture requires close cooperation between hardware and the operating system. Operating systems designed to work on multiple hardware platforms may make only limited use of rings if they are not present on every supported platform. Often the security model is simplified to "kernel" and "user" even if hardware provides finer granularity through rings.

Supervisor mode


In computer terms supervisor mode (sometimes called kernel mode) is a hardware-mediated flag which can be changed by code running in system-level software. System-level tasks or threads will have this flag set while they are running, whereas user-space applications will not. This flag determines whether it would be possible to execute machine code operations such as modifying registers for various descriptor tables, or performing operations such as disabling interrupts. The idea of having two different modes to operate in comes from “with more control comes more responsibility” — a program in supervisor mode is trusted never to fail, since a failure may cause the whole computer system to crash.

As summarized on , supervisor mode is “An execution mode on some processors which enables execution of all instructions, including privileged instructions. It may also give access to a different address space, to memory management hardware and to other peripherals. This is the mode in which the operating system usually runs.”

In a monolithic kernel, the kernel runs in supervisor mode and the applications run in user mode. Other types of 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....
s, like those with an exokernel
Exokernel

Exokernel is an operating system kernel developed by the MIT Parallel and Distributed Operating Systems group, and also a class of similar operating systems....
 or microkernel
Microkernel

In computer science, a microkernel is a computer kernel which provides the mechanisms needed to implement an operating system, such as low-level address space management, thread management, and inter-process communication....
 do not necessarily share this behavior.

Some examples from the PC world:

Linux
Linux

Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel. Their development is one of the most prominent examples of free and open source software collaboration; typically all the underlying source code can be used, freely modified, and redistributed by anyone under the terms of the GNU GPL license...
 and Windows
Microsoft Windows

Microsoft Windows is a series of software operating systems and graphical user interfaces produced by Microsoft. Microsoft first introduced an operating environment named Windows in November 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces ....
 are two operating systems that use supervisor/user-mode. To perform specialized functions, user-mode code must perform a system call
System call

In computing, a system call is the mechanism used by an application program to request service from the kernel based on the Monolithic_kernel or to system servers on operating systems based on the microkernel-structure....
 into kernel-space (running in supervisor mode) where trusted code in the operating system will perform the needed task.


DOS
DOS

DOS, short for "Disk Operating System", is a shorthand term for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions Windows 95, Windows 98, and Windows Me....
, other simple operating systems, and many embedded devices run in supervisor mode permanently, meaning that drivers can be written directly as user programs.


Most processors have at least two different modes. The x86-processors have four different modes divided into four different rings. Programs that run in Ring 0 can do anything with the system, and code that runs in Ring 3 should be able to fail at any time without impact to the rest of the computer system. Ring 1 and Ring 2 are rarely used, but could be configured with different levels of access.

Switching from “user mode” to “kernel mode” is, in most existing systems, very expensive. It has been measured, on the basic request getpid, to cost 1000-1500 cycles on most machines. Of these just around 100 are for the actual switch (70 from user to kernel space, and 40 back), the rest is "kernel overhead". In the L3 microkernel
L3 microkernel

L3 is a microkernel running on Intel's x86 computers. L3 is designed to be "very lean and features fast, message-based, synchronous IPC, simple-to-use external paging mechanisms and a security mechanism based on secure domains ." It is the predecessor of L4 microkernel family, another microkernel with similar design goals....
 the minimization of this overhead reduced the overall cost to around 150 cycles.

Maurice Wilkes wrote:
... 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. Rings of protection lent themselves to efficient implementation in hardware, but there was little else to be said for them. [...] The attractiveness of fine-grained protection remained, even after it was seen that rings of protection did not provide the answer... This again proved a blind alley...


To gain performance and determinism, some systems place functions that would likely be viewed as application logic, rather than as device drivers, in kernel mode; security applications (access control
Access control

Access control is the ability to permit or deny the use of a particular resource by a particular entity. Access control mechanisms can be used in managing physical resources , logical resources , or digital resources ....
, firewalls, etc.) and operating system monitors are cited as examples. At least one embedded database management system, eXtremeDB Kernel Mode
EXtremeDB

eXtremeDB is an ACID-compliant embedded database management system designed for embedded systems and applications with real-time computing performance requirements....
, has been developed specifically for kernel mode deployment, to provide a local database for kernel-based application functions, and to eliminate the context switch
Context switch

A context switch is the computing process of storing and restoring the State of a Central processing unit such that multiple Process es can share a single CPU resource....
es that would otherwise occur when kernel functions interact with a database system running in user mode.

Hypervisor mode

Recent CPUs from Intel and AMD offer x86 virtualization
X86 virtualization

x86 virtualization is the method by which x86-based "guest" operating systems are run under another "host" x86 operating system, with little or no modification of the guest OS....
 instructions for a hypervisor
Hypervisor

A hypervisor, also called virtual machine monitor , is a computer hardware platform virtualization software that allows multiple operating systems to run on a host computer concurrently....
 to control Ring 0 hardware access. Although they are mutually incompatible, both Intel VT (codenamed "Vanderpool") and AMD-V (codenamed "Pacifica") create a new "Ring -1" so that a guest operating system can run Ring 0 operations natively without affecting other guests or the host OS.

Interoperation between CPU and OS levels of abstraction

Many CPU hardware architectures provide far more flexibility than is exploited by the 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....
s that they normally run. Proper use of complex CPU modes requires very close cooperation between the operating system and the CPU, and thus tends to tie the OS to the CPU architecture. When the OS and the CPU are specifically designed for each other, this is not a problem (although some hardware features may still be left unexploited), but when the OS is designed to be compatible with multiple, different CPU architectures, a large part of the CPU mode features may be ignored by the OS. For example, Windows NT
Windows NT

Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was originally designed to be a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix....
 was designed to be portable and many architectures at the time only supported user and kernel mode.

Multics
Multics

Multics was an extremely influential early time-sharing operating system. The project was started in 1964. The last known running Multics installation was shut down on October 30, 2000....
 was an operating system designed specifically for a special CPU architecture (which in turn was designed specifically for Multics), and it took full advantage of the CPU modes available to it. However, it was an exception to the rule. Today, this high degree of interoperation between the OS and the hardware is not often cost-effective, despite the potential advantages for security and stability.

Ultimately, the purpose of distinct operating modes for the CPU is to provide hardware protection against accidental or deliberate corruption of the system environment (and corresponding breaches of system security) by software. Only "trusted" portions of system software are allowed to execute in the unrestricted environment of kernel mode, and only then when absolutely necessary. All other software executes in one or more user modes. If a processor generates a fault or exception condition in a user mode, in most cases system stability is unaffected; if a processor generates a fault or exception condition in kernel mode, most operating systems will halt the system with an unrecoverable error. When a hierarchy of modes exists (ring-base security), faults and exceptions at one privilege level may destabilize only the higher-numbered privilege levels. Thus, a fault in Ring 0 (the kernel mode with the highest privilege) will crash the entire system, but a fault in Ring 2 will only affect rings 3 and beyond and Ring 2 itself, at most.

Transitions between modes are at the discretion of the executing thread
Thread (computer science)

In computer science, a thread of execution is a Fork of a computer program into two or more Concurrency running task s. The implementation of threads and process es differs from one operating system to another, but in most cases, a thread is contained inside a process....
 when the transition is from a level of high privilege to one of low privilege (as from kernel to user modes), but transitions from lower to higher levels of privilege can take place only through secure, hardware-controlled "gates" that are traversed by executing special instructions or when external interrupts are received.

Microkernel
Microkernel

In computer science, a microkernel is a computer kernel which provides the mechanisms needed to implement an operating system, such as low-level address space management, thread management, and inter-process communication....
 operating systems attempt to minimize the amount of code running in privileged mode, for purposes of security
Computer security

Computer security is a branch of technology known as information security as applied to computers. The objective of computer security can include protection of information from theft or corruption, or the preservation of availability, as defined in the security policy....
 and elegance
Elegance

Elegance is the attribute of being unusually effective and simple. It is frequently used as a standard of tastefulness, particularly in the areas of visual design and beauty....
.

See also

  • System call
    System call

    In computing, a system call is the mechanism used by an application program to request service from the kernel based on the Monolithic_kernel or to system servers on operating systems based on the microkernel-structure....
  • Protected mode
    Protected mode

    In computing, protected mode, also called protected virtual address mode, is an operational mode of x86-compatible central processing units ....
     (x86-compatible CPUs of the 80286 series or later)
  • Multics
    Multics

    Multics was an extremely influential early time-sharing operating system. The project was started in 1964. The last known running Multics installation was shut down on October 30, 2000....


Further reading