What are Rings in Operating System? Ring Protection scheme layers
The concept of protected rings in the operating system was introduced to provide a different level of access to resources to provide security and reduce crashes. These rings are also known as CPU Privilege rings or Protection Rings.
Types of rings in different Operating Systems
In Windows x86 protected mode there are 4 rings-:
- Ring 0 (Kernel Mode)
- Ring 1 (Device Drivers)
- Ring 2 (Device Drivers)
- Ring 3 (User Mode)
In Linux protected mode generally there are 2 rings-:
- Ring 0
- Ring 3
If you are interested why Rings 1 & 2 aren’t much you can read here at StackOverflow.
Why have multiple rings in an OS?
- To have greater security, as spyware running in the user mode cannot give itself permission to run in kernel mode, thus increasing the security.
- To isolate the user mode and kernel mode, to avoid overlapping of memory and reduce crashes.
Difference between Ring 0 and Ring 3 in Operating Systems
Among all the rings of the CPU, for Reverse Engineering 2 rings are most often used i.e Ring 0 and Ring 3.
Ring 0 is used for Kernel Mode. It is the Highest privileged level and in this mode code directly interacts with hardware. Any crash in Kernel mode is disastrous for eg- you may have experienced Blue Screen Of Death or BSOD which can occur due to driver or hardware failure.
Ring 3 is used for User Mode. It is the Least privileged level among all of the rings. This ring cannot change current Segment descriptor i.e it cannot change its own ring as there would be no use of the concept of protection rings. For example, any program cannot record the keywords, screen without first asking permission from the user. Thus enhancing the protection of the OS. Crashes in User mode not that much fatal as in kernel or driver modes because of isolation.
What is the purpose of Rings 1 and 2 in the CPU?
Rings 1 and 2 are used for Device Drivers which are privileged enough to interact with hardware but not privileged enough to modify the kernel mode. They are not often used.
I hope this post is helpful for beginners who want to know about rings and their purpose in the Operating System.
Have a nice day!