Skip to contentSkip to conversation

When Are Free Pages Zeroed?

DISCUSSION Patrick Simmons 2 participants 2 messages Nov 10, 2011 – Nov 11, 2011

lore
Share & tools
lore
#0 lore raw

I'm looking into the Linux memory management subsystem and need to know when freed pages are zeroed. Specifically, are they zeroed just before they are reallocated, immediately after they are freed, or sometime in-between? Also, what files/functions would I need to modify to change this behavior?

Thanks for any help and kindest regards,
--Patrick

Signature · 1 line
If I'm not here, I've gone out to find myself.  If I get back before I return, please keep me here.
#1 lore raw

Hi patrick :)

Quoted 5 lines · Patrick Simmons

I'm looking into the Linux memory management subsystem and need to know when freed pages are zeroed. ?Specifically, are they zeroed just before they are reallocated, immediately after they are freed, or sometime in-between? ?Also, what files/functions would I need to modify to change this behavior?

I vaguely recall that zeroing is done in (re)-allocation. Thus, during freeing pages, you just mark it as free and let the allocator handle it further (perhaps doing block combining--forgot the technical name).

The function that does allocation while zeroing IIRC is kzalloc.

PS: IIRC too, once zero-ing isn't done anywhere. But later, it is found that it could be a security issue since it might leak sensitive data.

Signature · 7 lines
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com