3 ms·
Arguably, a leakage of information already happens when you deallocate memory without zeroing it first.
by _0ffh 4y ago
Arguably, a leakage of information already happens when you deallocate memory without zeroing it first.
- saagarjha 4y agoMake sure your compiler is actually doing that zeroing, as memory that is destined for deallocation does not have many requirements imposed on it.
- pornel 4y agoIn what security model? If you assume there's an adversary that can read all your memory, then you're pretty screwed no matter what you do. In C's and Rust's model deallocated memory is assumed to be completely inaccessible (and Rust does its best to ensure it is inaccessible), so in a valid (non-UB) program there is nothing that could leak its secrets.
- _0ffh 4y agoI thought of a scenario like, your process deallocates a page of memory, so it gets marked as unused by the OS, then some other application requests memory and gets handed your old page, with all the data you left in there. Would that not be leaking information?
- kragen 4y agoon linux the os zeroes the page to prevent this
- butlerm 4y agoOperating systems with support for memory protection and virtual memory generally don't behave that way for security reasons. Everything that is allocated to a process will be zeroed explicitly or on first reference. There are older operating systems that don't do that though. On the Amiga you have to explicitly ask the OS for memory to be cleared, and if you don't you may get uncleared memory left over from some other process.