Merge branch 'wip/dueno/madvice' into 'master'

egg: Request that secure memory not be dumped to disk

See merge request GNOME/libsecret!30
This commit is contained in:
Daiki Ueno 2019-06-05 10:51:49 +00:00
commit 7844baa78e

View File

@ -885,6 +885,19 @@ sec_acquire_pages (size_t *sz,
DEBUG_ALLOC ("gkr-secure-memory: new block ", *sz); DEBUG_ALLOC ("gkr-secure-memory: new block ", *sz);
#if defined(MADV_DONTDUMP)
if (madvise (pages, *sz, MADV_DONTDUMP) < 0) {
if (show_warning && egg_secure_warnings) {
/*
* Not fatal - this was added in Linux 3.4 and older
* kernels will legitimately fail this at runtime
*/
fprintf (stderr, "couldn't MADV_DONTDUMP %lu bytes of memory (%s): %s\n",
(unsigned long)*sz, during_tag, strerror (errno));
}
}
#endif
show_warning = 1; show_warning = 1;
return pages; return pages;