From: Thomas Veerman Date: Wed, 14 Nov 2012 13:24:53 +0000 (+0000) Subject: VFS: fix TOCTOU bug in sync X-Git-Tag: v3.2.1~229 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/rndc-confgen.html?a=commitdiff_plain;h=14e470be81ad5ba79b74f9ccd54bcbdcf15622c5;p=minix.git VFS: fix TOCTOU bug in sync --- diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index f32ec88e2..cd7319f46 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -299,13 +299,13 @@ int do_sync() int r = OK; for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; ++vmp) { + if ((r = lock_vmnt(vmp, VMNT_EXCL)) != OK) + break; if (vmp->m_dev != NO_DEV && vmp->m_fs_e != NONE && vmp->m_root_node != NULL) { - if ((r = lock_vmnt(vmp, VMNT_EXCL)) != OK) - break; req_sync(vmp->m_fs_e); - unlock_vmnt(vmp); } + unlock_vmnt(vmp); } return(r);