Just getting into OS and was confused why exactly we have to 0 out our page all the time before we're able to allocate it to the requestor?
Asked
Active
Viewed 24 times
1 Answers
1
What happens if my OS doesn't 0 out a page before I allocate it?
The simple answer is that data that was in the page before it was freed can be accessed by the process that allocates it next; which means you end up with potentially confidential information leaking everywhere (a security disaster).
For the more complex answer; it depends what you mean by "allocated". For some cases (allocating physical pages as part of/before fetching data from swap space, loading data from memory mapped file, or doing a "copy on write") there's no need for the kernel to fill the page with zeros because it must fill the page with other data anyway.

Brendan
- 35,656
- 2
- 39
- 66