After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 151999 - allocation of unpageable memory
allocation of unpageable memory
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2004-09-06 17:24 UTC by albrecht.dress
Modified: 2011-02-18 16:14 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement



Description albrecht.dress 2004-09-06 17:24:49 UTC
I would like to propose the introduction of a set of functions to allocate or
free a chunk of unswappable memory, e.g.

gpointer g_malloc_locked(gulong n_bytes, GError ** error);
gpointer g_malloc0_locked(gulong n_bytes, GError ** error);
gpointer g_free_locked(GError ** error);
etc.

The main use for such chunks of memory is for routines which require a high
level of security, e.g. for processing GnuPG passphrases which must not be
leaked to swap space. Of course, an application using this feature must be suid
root.

After the allocation of the memory using the g_malloc*locked family of calls, it
should be protected from being paged by calling mlock() on Posix/SysV systems.
If this failes (e.g. as the application does not have proper permissions), an
error should be returned.

When calling g_free_locked, the chunk of memory should first be overwritten with
random data and/or a pattern to prevent any leak of information.

The pinentry application which is part of the Aegypten project provides a set of
such calls (based upon their own "memory management", though). Please see [1]
for details.

[1]
http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/pinentry/secmem/secmem.c?cvsroot=Project+Aegypten
Comment 1 Matthias Clasen 2005-12-03 07:02:07 UTC
Fairly special-case, I'd say just use mlock directly.