VFS: fix TOCTOU bug in sync

This commit is contained in:
Thomas Veerman 2012-11-14 13:24:53 +00:00
parent ed23a7a7d2
commit 14e470be81

View file

@ -299,13 +299,13 @@ int do_sync()
int r = OK; int r = OK;
for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp) { for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp) {
if (vmp->m_dev != NO_DEV && vmp->m_fs_e != NONE &&
vmp->m_root_node != NULL) {
if ((r = lock_vmnt(vmp, VMNT_EXCL)) != OK) if ((r = lock_vmnt(vmp, VMNT_EXCL)) != OK)
break; break;
if (vmp->m_dev != NO_DEV && vmp->m_fs_e != NONE &&
vmp->m_root_node != NULL) {
req_sync(vmp->m_fs_e); req_sync(vmp->m_fs_e);
unlock_vmnt(vmp);
} }
unlock_vmnt(vmp);
} }
return(r); return(r);