Concepts and theorems · Intermediate

Privilege levels: separating user and kernel execution

Understand restricted instructions, controlled trap entry, and why a privilege transition is not necessarily a process switch.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. Restricting privileged operations
  2. A syscall is a controlled entry
  3. Mode transitions versus process switches
  4. A boundary, not complete security
  5. Ask Logeia about this articleCheck your understanding

Restricting privileged operations

Privilege levels let a processor distinguish operations available to ordinary software from operations reserved for more trusted control code. If every application could freely change protection settings, isolation between applications would be difficult to enforce. Instructions and control-register accesses can therefore be restricted according to the current execution level. The exact number and naming of levels depend on the architecture. User mode and kernel mode are useful operating-system terms, but they should not be mistaken for a universal description of every processor privilege hierarchy.

A syscall is a controlled entry

A system call uses a defined entry mechanism to ask the operating system to perform work such as reading a file. Control reaches a designated handler, and the kernel validates arguments and access rights before carrying out the request. This does not give the caller permission to run arbitrary privileged instructions. User-supplied pointers and lengths still require careful validation. Crossing a hardware privilege boundary protects the entry mechanism; it does not automatically make every value supplied by the application trustworthy or every kernel implementation correct.

Mode transitions versus process switches

Consider a read request that the kernel can satisfy immediately before returning to the same process. Privilege changes can occur without scheduling a different process. If the request blocks for I/O and the scheduler runs another task, a context switch may also occur. These are related but distinct events. Performance analysis should distinguish entry and return overhead, argument checking, data copying, waiting, and scheduling work. Assuming that every syscall necessarily switches to another process makes it harder to explain why different system calls have very different costs.

A boundary, not complete security

Privilege separation is one protection layer rather than a complete security argument. A bug in privileged code can misuse its authority, and application roles or filesystem permissions operate at different abstraction levels. An account can have an application administrator role without running its application code in the processor's highest privilege level. Conversely, preventing user-mode privileged instructions does not prove an API authorization check is correct. Identify the hardware boundary, operating-system resource checks, and application policy separately so that each claimed protection has a clear enforcement mechanism.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Build your CS foundations · STEP 15

Understand the systems behind the web · STEP 3

Choose a learning path