mincore
mincore is a system call that reports a page-residency vector for a mapped virtual-address range.
Only the low bit of each result byte is defined. The start address must be page-aligned; length rounds up to pages. Success returns zero, failure returns -1 with errno, and the snapshot may already be stale on return. [1]
Linux v6.17 permits file-cache disclosure when the caller owns the inode, has the relevant capability, or passes the file write-permission check. Otherwise it returns all-one bytes for that mapping without measuring its residency. Opening a file read-only is not itself the deciding condition. [2]
Page Cache Attacks (CCS 2019), section 9, explains why exposing residency can disclose another process's access pattern. Restricting or masking this API mitigates the direct observation channel, not every timing channel. This is historical security context, not a claim that all current kernels are vulnerable. [4]
The vector belongs to the mapping, not just the file. In v6.17, a present page-table entry returns one; an absent entry in a file mapping instead triggers a file-cache lookup. A MAP_PRIVATE write can create an anonymous copy while the original file page is later evicted. [2] [5]
In two five-trial captures on Linux 6.8.0-147-generic, the locked private copy reported one while an untouched mapping of the same offset reported zero after file-range DONTNEED. The private byte remained B; the other mapping and file returned A. These sequential observations are not a simultaneous snapshot, hit-rate estimate or security test. [6]
Relations
- related
- Page cache, Memory-mapped file, POSIX_FADV_DONTNEED, RWF_NOWAIT, readahead (Linux syscall), cachestat
Limitations
- Residency does not measure read latency, persistent storage or an application's cache-hit ratio. [3]
Citations
- Linux man-pages 6.19: mincore(2), residency snapshots and return values.
- Linux v6.17 mm/mincore.c: can_do_mincore, do_mincore and page-cache lookup.
- Hesela. Five self-owned-file mincore observations, source and environment.
- Gruss et al. Page Cache Attacks. CCS 2019, section 9. DOI: 10.1145/3319535.3339809
- Linux man-pages 6.19: mmap(2), MAP_PRIVATE copy-on-write semantics.
- Hesela: mincore private-COW and untouched-mapping observations, method, code and two captures.