CVE-2004-0491
Description
The linux-2.4.21-mlock.patch in Red Hat Enterprise Linux 3 does not properly maintain the mlock page count when one process unlocks pages that belong to another process, which allows local users to mlock more memory than specified by the rlimit.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
The AI Insight narrative is available to signed-in members. Sign in or create a free account to read it.
Affected products
2- cpe:2.3:o:redhat:enterprise_linux:3.0:*:*:*:*:*:*:*
- Range: 3
Patches
Discovered fix commits and diffs is available to signed-in members. Sign in or create a free account to read it.
Vulnerability mechanics
Root cause
"Incorrect `mm->locked_vm` accounting when one process unlocks pages that belong to another process via SHM_UNLOCK, allowing bypass of RLIMIT_MEMLOCK."
Attack vector
A local attacker can exploit this by using the `SHM_LOCK` and `SHM_UNLOCK` operations on System V shared memory segments to manipulate the `mm->locked_vm` counter without proper rlimit enforcement. The original check only required `CAP_IPC_LOCK`, not the per-user rlimit, so an unprivileged process can unlock pages belonging to another process, causing `locked_vm` to underflow or remain inflated [ref_id=1]. This lets the attacker mlock more memory than the `RLIMIT_MEMLOCK` limit would normally allow, exhausting system memory.
Affected code
The linux-2.4.21-mlock.patch in Red Hat Enterprise Linux 3 contains an accounting flaw in `mm/mlock.c`, `mm/mmap.c`, `mm/mremap.c`, and `mm/shmem.c`. The vulnerability arises because `mm->locked_vm` is not correctly tracked when one process unlocks pages that belong to another process (e.g. via `SHM_UNLOCK` on a shared memory segment), allowing the mlock page count to become inconsistent.
What the fix does
The patch reworks the accounting in `shmem_lock()` to properly increment and decrement `mm->locked_vm` when `SHM_LOCK`/`SHM_UNLOCK` is performed, and ensures the rlimit check (`RLIMIT_MEMLOCK`) is applied before allowing the lock [ref_id=1]. It also introduces `can_do_mlock()` which returns true if the caller has either `CAP_IPC_LOCK` or a non-zero memlock rlimit, and adds rlimit checks (with `capable()` fallback) to `mlock.c`, `mmap.c`, and `mremap.c`. The default `RLIMIT_MEMLOCK` on many architectures is changed from `LONG_MAX` to `PAGE_SIZE` so that unprivileged users have a finite limit enforced from the start.
Preconditions
- authAttacker must be a local user with access to System V shared memory system calls (shmget, shmctl).
- configThe system must run an unpatched linux-2.4.21 kernel (Red Hat Enterprise Linux 3).
- inputThe attacker must be able to create or have access to a shared memory segment that can be locked/unlocked.
Generated on Jun 16, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- patches.sgi.com/support/free/security/advisories/20060402-01-Unvd
- marc.infonvd
- secunia.com/advisories/19607nvd
- www.redhat.com/support/errata/RHSA-2005-472.htmlnvd
- www.securityfocus.com/bid/13769nvd
- bugzilla.redhat.com/bugzilla/show_bug.cginvd
- oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A10672nvd
- oval.cisecurity.org/repository/search/definition/oval%3Aorg.mitre.oval%3Adef%3A1117nvd
News mentions
0No linked articles in our index yet.