is it possible to keep mmap'd memory from being synced?

From: Ben Pfaff (
Date: Tue Jul 01 2003 - 19:20:48 EST

Is there a way to keep mmap'd memory from being synced to disk?
In particular, we're trying to build tools that operate on a lot
of data that's security-sensitive. The data is mapped into
memory, and large parts of it are repeatedly decrypted in-place,
operated on, and then re-encrypted in-place for final storage to
disk. During the time that the data is in plaintext form, we'd
like it to not be written to disk.

Will mlock() do what we want? I know that it will keep the data
from being evicted from memory, but will it also keep it from
being written back to the mmap'd file? (We're mmap'ing a real
file, not /dev/zero, etc., because we do want to keep the data
for later use.)

We don't want to use MAP_PRIVATE, both because we do want the
data eventually to get written to disk and because we have
multiple processes that want to interact doing this at once.

It seems like not decrypting in-place would be another solution,
but we'd rather not use the extra memory--we're talking about
data on the order of 100 MB or so.

I'm posting this to linux-kernel because our software already
involves a small kernel module, so if need be we're willing to
add functionality to that module to help us do what we want.
But the program's data manipulation goes on in userspace.



<> <> <> <>
 Stanford Ph.D. Candidate - MSU Alumnus - Debian Maintainer - GNU Developer

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to More majordomo info at Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Jul 07 2003 - 22:00:14 EST