On Thu, Apr 25, 2019 at 8:32 AM Christopher Lameter <cl@xxxxxxxxx> wrote: > > On Wed, 24 Apr 2019, Matthew Garrett wrote: > > > Applications that hold secrets and wish to avoid them leaking can use > > mlock() to prevent the page from being pushed out to swap and > > MADV_DONTDUMP to prevent it from being included in core dumps. Applications > > can also use atexit() handlers to overwrite secrets on application exit. > > However, if an attacker can reboot the system into another OS, they can > > dump the contents of RAM and extract secrets. We can avoid this by setting > > Well nothing in this patchset deals with that issue.... That hole still > exists afterwards. So is it worth to have this functionality? On UEFI systems we can set the MOR bit and the firmware will overwrite RAM on reboot. However, this can take a long time, which makes it difficult to justify doing by default. We want userland to be able to assert that secrets have been cleared from RAM and then clear the MOR flag, but we can't do that if applications can terminate in a way that prevents them from clearing their secrets. > > Unfortunately, if an application exits uncleanly, its secrets may still be > > present in RAM. This can't be easily fixed in userland (eg, if the OOM > > killer decides to kill a process holding secrets, we're not going to be able > > to avoid that), so this patch adds a new flag to madvise() to allow userland > > to request that the kernel clear the covered pages whenever the page > > reference count hits zero. Since vm_flags is already full on 32-bit, it > > will only work on 64-bit systems. > > But then the pages are cleared anyways when reallocated to another > process. This just clears it sooner before reuse. So it will reduce the > time that a page contains the secret sauce in case the program is > aborted and cannot run its exit handling. On a mostly idle system there's a real chance that nothing will end up re-using the page before a reboot happens. > Is that realy worth extending system calls and adding kernel handling for > this? Maybe the answer is yes given our current concern about anything > related to "security". If I didn't think it was worth it, I wouldn't be proposing it :)