nanovms / nanos

A kernel designed to run one and only one application in a virtualized environment
https://nanos.org
Apache License 2.0
2.58k stars 133 forks source link

On-demand program file paging: fix initialization of BSS areas #2032

Closed francescolavra closed 2 months ago

francescolavra commented 2 months ago

When on-demand paging of the program file is enabled, BSS areas in pages faulted-in on demand are zeroed in-place, i.e. a newly mapped page retrieved via the page cache is zeroed starting from the BSS offset set up when initializing the relevant vmap. This creates a problem if the page contains other data (e.g. from another loadable section of the program) at or after the BSS offset, in which case this data would be overwritten. This change fixes the above issue by using a separate page (instead of the page from the page cache) where the initialized program data (located before the BSS offset) is copied from the page cache page, and the rest of the page (starting at the BSS offset) is zeroed out. Closes https://github.com/nanovms/ops/issues/1629.

The last commit fixes an assertion failure that occurs when a page fault during a kernel context cannot be resolved synchronously.

francescolavra commented 2 months ago

I fixed two issues that could potentially cause the kernel to fail to release a lock when under memory pressure.