patch: private areas, mlock()/munlock() and MAP_LOCKED for mmap()
|Reported by:||Blub||Owned by:||axeld|
|Has a Patch:||no||Platform:||All|
Recently I found myself trying to create a private region of memory which is locked into RAM (so it is not swapped), yet not accessible to others, for storing the input of a password field in it. I've come across several problems there: Areas have a B_FULL_LOCK flag, however, it is not possible to prevent them from being cloned. mmap() allocates areas named "mmap area" which can just as well be cloned, and there's no implementation of mlock() (and munlock())
I have implemented mlock() and munlock(), and also added the possibility to use MAP_LOCKED with mmap(). Also I have added a B_PRIVATE_AREA flag which may be used by the user to prevent people from cloning the area, which is also used by mmap() when using the MAP_PRIVATE flag.
With this, it is possible for applications to allocate private, protected and locked memory regions where they can store sensitive data when needed.
Looking forward to feedback of any kind :) (about the implementation as well as coding style and anything else which would be useful for me to know to be able to provide patches of a good quality if my skills allow it :) )