vmmcache: fix TOCTOU

This commit is contained in:
Matheus
2026-04-01 16:46:20 -03:00
parent 774ae10e99
commit a48edb99be
+8 -3
View File
@@ -369,10 +369,15 @@ int vmmcache_syncvnode(vnode_t *vnode, uintmax_t offset, size_t size) {
vnodedirtylist = vnodedirtylist->writenext;
page->writenext = NULL;
int error = syncpage(page, false);
// another thread could already have synced this page, verify if it is still dirty
if (page->flags & PAGE_FLAGS_DIRTY) {
int error = syncpage(page, false);
if (e == 0)
e = error;
if (e == 0)
e = error;
} else {
RELEASE_LOCK();
}
// syncpage returns with lock released
}