Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Processes with elevated privileges can disable paging by "locking" memory in place using POSIX mlock() function [Open Group 04]. This ensures that memory is never copied to the hard drive, where it may be retained indefinitely in nonvolatile storage.

...

Windows processes running with elevated privileges can disable paging by locking memory in place using VirtualLock() (Windows) [MSDN]:

Code Block
bgColor#CCCCFF
char *secret;

secret = (char *)malloc(size+1);
if (!secret) {
  /* Handle error */
}

if (VirtualLock(secret, size+1) != 0) {
    /* Handle error */
}

/* Perform operations using secret... */

free(secret);
secret = NULL;

...

Wiki Markup
\[[ISO/IEC PDTR 24772|AA. References#ISOBibliography#ISO/IEC PDTR 24772]\] "XZX Memory Locking"
\[[MITRE 07|AA. References#MITREBibliography#MITRE 07]\] [CWE ID 591|http://cwe.mitre.org/data/definitions/591.html], "Sensitive Data Storage in Improperly Locked Memory," and [CWE ID 528|http://cwe.mitre.org/data/definitions/528.html], "Information Leak Through Core Dump Files"
\[[Open Group 04|AA. References#AABibliography#AA. CReferences-OpenGroup04]\]{{mlock(), setrlimit()}}
\[[Wheeler 03|AA. References#WheelerBibliography#Wheeler 03]\] Sections 7.14 and 11.4

...