Can one container see memory that another container freed?
I understand that two containers do not have access to the same memory at the same time — the isolation there is clear enough. My question is about the handover.
Memory is over-provisioned on this host. If one container allocates a large amount, writes sensitive data into it, and then frees it, that memory presumably becomes available to the host again and can be handed to a different container.
So at the moment the second container receives those pages, what is in them? Is there a wipe step, or could it read what the first one left?
@kernel_kaya · 2d ago
You are safe here, and the reason is more fundamental than anything containers do — the kernel zeroes pages before handing them to a process, full stop.
This is not a container feature. It is a property of the operating system's memory management that predates containers by decades. When any process asks for anonymous memory and first touches it, what it gets is a page of zeros. There is no mechanism by which a normal process receives a page still holding another process's data, because that would be an obvious information leak between ordinary users on a shared machine.
The thing to understand about containers on Linux is that they are not a separate kind of process. Processes in containers are ordinary processes with restricted views of the system through namespaces and limits through control groups. They go through exactly the same allocation path as anything else, and inherit the same guarantee.
So the answer to your specific question is: zeros.
Reply
Report