Conceptual
Login

Copying Data Between User and Kernel Memory Safely

A pointer handed to you from a program is just a number in that program's address space: it may be invalid, may point at memory the program is not allowed to touch, or may be swapped out right now. So kernel code never dereferences it directly; it uses copy routines that check the address, handle a fault instead of crashing, and can report failure. Dereferencing it anyway turns a bad user pointer into a kernel crash or a security hole that lets a program read anything.

Questions this Concept answers

  • Why can kernel code never dereference a user-supplied pointer directly, even one that looks perfectly reasonable?