Bad Address
Production Risk
HIGH — indicates a memory safety bug. Fix immediately.
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.
- 1Passing a NULL pointer to a system call that requires a valid buffer
- 2Passing a dangling pointer (memory that was freed or never allocated)
- 3Passing a pointer to a stack variable that has gone out of scope
- 4A buffer is too small for the requested operation
Passing NULL to read() as the buffer.
// 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
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.
✕ Ignore EFAULT in production code
EFAULT from a syscall means a memory safety bug. Left unaddressed it will cause crashes or security vulnerabilities.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev