Linux EFAULT (errno 14) — Bad Address (Memory Access Error)
Errorerrno
Overview
Linux EFAULT error occurs when a system call is given a pointer to invalid memory, indicating a programming bug or memory corruption in the application.
Key Details
- EFAULT (errno 14) means a system call was passed a pointer outside the process's accessible address space
- This is almost always a programming bug — passing NULL, freed, or uninitialized pointers to syscalls
- The kernel validates user-space pointers before accessing them and returns EFAULT if invalid
- Unlike SIGSEGV which crashes the process, EFAULT is returned as an error code allowing recovery
- Common in C programs with incorrect memory management
Common Causes
- Passing NULL pointer to a system call that expects valid memory
- Using a pointer to freed memory (use-after-free)
- Buffer allocated on the stack that has gone out of scope
- Incorrect pointer arithmetic pointing outside allocated buffer
- Memory corruption from buffer overflow in a different part of the program
Steps
- 1Run the program under Valgrind: valgrind --track-origins=yes ./program to detect memory errors
- 2Compile with AddressSanitizer: gcc -fsanitize=address -g program.c
- 3Use strace to identify which system call returns EFAULT: strace -e trace=all ./program
- 4Enable core dumps: ulimit -c unlimited, then analyze with gdb ./program core
- 5Review code for NULL pointer checks before system calls
Tags
linuxefaulterrno-14bad-addressmemory-bug
More in Errno
linux-errno-1-epermLinux errno 1 (EPERM) — Operation Not Permitted
Warninglinux-errno-2-enoentLinux errno 2 (ENOENT) — No Such File or Directory
Warninglinux-errno-5-eioLinux errno 5 (EIO) — Input/Output Error
Errorlinux-errno-11-eagainLinux errno 11 (EAGAIN) — Resource Temporarily Unavailable
Informationallinux-errno-12-enomemLinux errno 12 (ENOMEM) — Out of Memory
Criticallinux-errno-13-eaccesLinux errno 13 (EACCES) — Permission Denied
WarningFrequently Asked Questions
Almost never. The kernel correctly detects the invalid pointer and returns EFAULT. The bug is in the user-space program.