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

pagecache: fix on-demand mapping of evicted pages #2016

Closed francescolavra closed 4 months ago

francescolavra commented 4 months ago

When a page fault occurs on a file-backed mapping for a page that was previously in the page cache but has later been evicted, the fault handler calls pagecache_map_page_if_filled(), which should return false because the newly re-allocated page has not been filled yet. Commit 132a832e79c8a50fd9f5d47b0661fd3295b8605f introduced a regression which causes pagecache_map_page_if_filled() to return true instead; this leads to page cache contents inconsistent with file contents and erroneous data accessed by the user program via the file-backed mapping. This change fixes the above issue by amending the touch_or_fill_page_nodelocked() function so that it returns false when the relevant page is in the ALLOC state.