EFAULT
Linux / POSIXERRORCommonMemoryHIGH confidence

Bad Address

Production Risk

HIGH — indicates a memory safety bug. Fix immediately.

What this means

EFAULT (errno 14) is returned when a system call is passed a pointer to memory outside the process's accessible address space, or to a region that is not mapped. It is the kernel's way of rejecting invalid userspace pointers.

Why it happens
  1. 1Passing a NULL pointer to a system call that requires a valid buffer
  2. 2Passing a dangling pointer (memory that was freed or never allocated)
  3. 3Passing a pointer to a stack variable that has gone out of scope
  4. 4A buffer is too small for the requested operation
How to reproduce

Passing NULL to read() as the buffer.

trigger — this will error
trigger — this will error
// C: invalid buffer pointer
ssize_t n = read(fd, NULL, 64);
// Returns -1, errno = EFAULT

expected output

read: Bad address (EFAULT)

Fix

Validate all pointers before passing to syscalls

WHEN Always — never pass unchecked pointers to system calls

Validate all pointers before passing to syscalls
char buf[64];
if (buf == NULL) { /* handle */ }
ssize_t n = read(fd, buf, sizeof(buf));

Why this works

Allocate buffers with known sizes, verify pointers are non-NULL, and ensure buffers remain live (not freed or out-of-scope) for the duration of the syscall.

What not to do

Ignore EFAULT in production code

EFAULT from a syscall means a memory safety bug. Left unaddressed it will cause crashes or security vulnerabilities.

Sources
Official documentation ↗

Linux Programmer Manual errno(3)

read(2)

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Linux / POSIX errors