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

Ben Pfaff (blp@cs.stanford.edu)
01 Jul 2003 17:20:48 -0700


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.

Thanks,

Ben.

-- 
<blp@cs.stanford.edu> <pfaffben@msu.edu> <pfaffben@debian.org> <blp@gnu.org>
 Stanford Ph.D. Candidate - MSU Alumnus - Debian Maintainer - GNU Developer
                              www.benpfaff.org

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/