Open Orycterope opened 5 years ago
We should at least clean up on deallocation
Can probably be closed with https://github.com/sunriseos/SunriseOS/blob/master/shell/img/meme7.gif
Given the number of "reboot and use some state left in RAM" attacks on various systems, I think that you cannot assume that never-used pages are clean.
There's a trade-off between whether you want allocation to be fast, or freeing to be fast. If you zero on allocation:
If you zero on free:
Upon thinking about this, I think I actually prefer zeroing on free due to the implications it has. Either a page is used and has valid(?) data, or is zero.
One unmentioned problem is that to bzero a page, it needs to be mapped. However the allocation of pages and their mapping is highly decoupled (frame_allocator vs. paging). This means we either have to:
The kernel must bzero every page that it gives to userspace, to prevent leaking data from a process to another.
Unfortunately this implies a lot of overhead. We should find a way to be smart about it, and do it the less often possible.
First we need to decide if either:
Secondly, we need to find a strategy to keep track of dirty pages, and bzero them only once. I imagine we can put to use the
dirty
flag in the page tables, but i don't really know when would be the best moment to do the clean. On allocation ? On clean ?Also: Do we consider never-used pages as clean ? Are they guaranteed to be all zeros on boot ?
A lot of questions 😕