0
votes

http://man7.org/linux/man-pages/man2/mmap.2.html says

MAP_ANONYMOUS
              The mapping is not backed by any file; its contents are
              initialized to zero. 

Why is it necessary to initialize the contents to zero? I think this may be quite expensive.

1

1 Answers

2
votes

Newly allocated pages are filled with zero to avoid sensitive information leakage from other processes. Those processes may have stored passwords in there, for example, and if this memory is not overwritten its contents leak elsewhere.