summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_syscalls.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-01-08 23:06:53 +0000
committerkib <kib@FreeBSD.org>2012-01-08 23:06:53 +0000
commit5ccad4b353ca1fd0386d62755bc00f146cdddec5 (patch)
tree628b27022e4f620628af64c85c5a17f7aaee3d3d /sys/kern/vfs_syscalls.c
parent12b863c4bef4df9c3de3099bb3a4cef60d5443da (diff)
downloadFreeBSD-src-5ccad4b353ca1fd0386d62755bc00f146cdddec5.zip
FreeBSD-src-5ccad4b353ca1fd0386d62755bc00f146cdddec5.tar.gz
Avoid LOR between vfs_busy() lock and covered vnode lock on quotaon().
The vfs_busy() is after covered vnode lock in the global lock order, but since quotaon() does recursive VFS call to open quota file, we usually end up locking covered vnode after mp is busied in sys_quotactl(). Change the interface of VFS_QUOTACTL(), requiring that mp was unbusied by fs code, and do not try to pick up vfs_busy() reference in ufs quotaon, esp. if vfs_busy cannot succeed due to unmount being performed. Reported and tested by: pho MFC after: 1 week
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r--sys/kern/vfs_syscalls.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index d56e631..31ad276 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -86,6 +86,8 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_page.h>
#include <vm/uma.h>
+#include <ufs/ufs/quota.h>
+
static MALLOC_DEFINE(M_FADVISE, "fadvise", "posix_fadvise(2) information");
SDT_PROVIDER_DEFINE(vfs);
@@ -212,7 +214,20 @@ sys_quotactl(td, uap)
return (error);
}
error = VFS_QUOTACTL(mp, uap->cmd, uap->uid, uap->arg);
- vfs_unbusy(mp);
+
+ /*
+ * Since quota on operation typically needs to open quota
+ * file, the Q_QUOTAON handler needs to unbusy the mount point
+ * before calling into namei. Otherwise, unmount might be
+ * started between two vfs_busy() invocations (first is our,
+ * second is from mount point cross-walk code in lookup()),
+ * causing deadlock.
+ *
+ * Require that Q_QUOTAON handles the vfs_busy() reference on
+ * its own, always returning with ubusied mount point.
+ */
+ if ((uap->cmd >> SUBCMDSHIFT) != Q_QUOTAON)
+ vfs_unbusy(mp);
VFS_UNLOCK_GIANT(vfslocked);
return (error);
}
OpenPOWER on IntegriCloud