Kernel space and User space

C. Burak Ongay
brakulla
Published in
1 min readJul 6, 2018

In UNIX-like operating systems, there are two spaces in virtual memory. Kernel space in which the kernel is located and executed and user space.

This separation provides protection on processes over memory.

Typically, in the x86 architecture, there are 4 rings of protection. Ring 0 (kernel mode), ring 1 (may be used by virtual machine hypervisors or drivers), ring 2 (may be used by drivers), ring 3 (where user applications run).

The programs running outside of kernel is executed in user space. They are located at the outermost ring, therefore, have no access to the inner rings, and privileged instructions.

This way, if I write a very bad code, and try to access to some places in memory that I shouldn’t by mistake, I get a segmentation fault for example. Why? Because it is not permitted. I cannot access other programs’ data, I cannot access some stuff related to operating a computer.

This prevents both bad programmers and hackers to do some bad stuff.

--

--