KPasswordDialog / KPasswordEdit

Brad Hards bradh at frogmouth.net
Sun Jan 15 08:22:53 GMT 2006


On Sunday 15 January 2006 18:17 pm, Stefan Teleman wrote:
> On Saturday 14 January 2006 16:44, Brad Hards wrote:
> > Justin Karneges and I have done some work on a QSecureArray class (closer
> > to the Qt4 QByteArray than to QString, but perhaps appropriate for this
> > purpose) in QCA. The implementation uses mlock() or mmap() to avoid
> > swapping the passwords out.
>
> - mmap()'ed memory gets swapped out -- actually, memory pages reserved for
> mmap(2) are allocated on swap, unless MAP_NORESERVE is passed to mmap(2),
> in which case the caller is responsible for creating a shared memory region
> for the memory-mapped pages, previous to calling mmap(2), and passing the
> properly aligned address of the start of the memory region as the first
> argument to mmap(2)
I don't follow you. The way QCA does it (actually the way Botan does it, we 
just copied it) is to mmap a temporary file. You have to zero the file 
afterwards of course, but pages that need to be swapped out won't be put on 
the swap space / swap partition - they will be put on the file.
> - mlock(3C) does not guarantee that the memory region being locked will not
> be implicitly unlocked and swapped out (unless the previous applies)
That isn't what the man page for mlock(2) says on my system. 
"mlock disables paging for the memory in the range starting at addr with 
length len bytes. All pages which contain a part of the specified memory 
range are guaranteed be resident in RAM when the mlock system call returns 
successfully and they  are  guaranteed  to  stay  in RAM until the pages are 
unlocked by munlock or munlockall, until the pages are unmapped via munmap, 
or until the process terminates or starts another program with exec.  Child 
processes do not inherit page locks across a fork."

The only case I know of where your mlock()ed or mmap()ed memory gets put to 
swap is if you suspend to disk.

Can you explain the problem more?

Brad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060115/a0e5583e/attachment.sig>


More information about the kde-core-devel mailing list