Re: kernel zeroing of user space memory?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Mar 31, 2007 at 08:08:52PM -0400, Ryan MacArthur wrote:
> I am trying to understand the process by which pages of memory get
> de/re-allocated.
> 
> Lets say I have a process that exits, will the kernel memory management
> system zero out (entirely) the pages that my process was using, or will it
> just re-assign them with the old data still present.

Pages are never reassigned with old data still present. The kernel is
lazy and won't zero any page unless it's really necessary. At exit the
pages are unmapped and returned to the free pool (when there are no
other users, of course).

When the next process starts, its binary will be mmap()ed. Again, the
kernel is lazy and will only load pages from disk when they are really
needed. When that happens, it will take a page from the free pool, load
the contents from disk and make it available to the process.

An anonymous page (i.e.: without file backing) for the userspace heap
will just be a write-only copy of the zero page. When the process
writes it, it will get a page fault, the kernel will assign a new page
from the free pool and copy the contents from the zero page (which
happen to be all zero) into it.

> I found this gfp mask:
> 
> #define __GFP_ZERO 0x8000u /* Return zeroed page on success */
> 
> So it seems that a calling process would have to specifically _ask_ for a
> zeroed out page, otherwise it would get a page with old application data in
> it (passwords,keys?)

The GFP masks are for internal kernel allocation (kmalloc etc).


Erik

- -- 
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGEiyS/PlVHJtIto0RAsFqAJ0T6UGbxunOUE4j+QdOfB0pL9OveACfQ5FH
kRp6Ug6tvl7dMDEsIGDvY1g=
=YAHd
-----END PGP SIGNATURE-----

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux