From 2b19a055abbc5be2fe11287f37ab71974593eb9c Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Fri, 27 May 2005 19:21:08 +0000 Subject: [PATCH] Sync locking in freebsd4_getfsstat() with getfsstat(). Giant is probably also needed in kern_fhstatfs(). --- sys/kern/vfs_extattr.c | 3 +++ sys/kern/vfs_syscalls.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index dc2838800ee0..e59bc09280b6 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -526,6 +526,7 @@ freebsd4_getfsstat(td, uap) maxcount = uap->bufsize / sizeof(struct ostatfs); sfsp = (caddr_t)uap->buf; count = 0; + mtx_lock(&Giant); mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { if (!prison_check_mount(td->td_ucred, mp)) { @@ -567,6 +568,7 @@ freebsd4_getfsstat(td, uap) error = copyout(&osb, sfsp, sizeof(osb)); if (error) { vfs_unbusy(mp, td); + mtx_unlock(&Giant); return (error); } sfsp += sizeof(osb); @@ -577,6 +579,7 @@ freebsd4_getfsstat(td, uap) vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); + mtx_unlock(&Giant); if (sfsp && count > maxcount) td->td_retval[0] = maxcount; else diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index dc2838800ee0..e59bc09280b6 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -526,6 +526,7 @@ freebsd4_getfsstat(td, uap) maxcount = uap->bufsize / sizeof(struct ostatfs); sfsp = (caddr_t)uap->buf; count = 0; + mtx_lock(&Giant); mtx_lock(&mountlist_mtx); for (mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) { if (!prison_check_mount(td->td_ucred, mp)) { @@ -567,6 +568,7 @@ freebsd4_getfsstat(td, uap) error = copyout(&osb, sfsp, sizeof(osb)); if (error) { vfs_unbusy(mp, td); + mtx_unlock(&Giant); return (error); } sfsp += sizeof(osb); @@ -577,6 +579,7 @@ freebsd4_getfsstat(td, uap) vfs_unbusy(mp, td); } mtx_unlock(&mountlist_mtx); + mtx_unlock(&Giant); if (sfsp && count > maxcount) td->td_retval[0] = maxcount; else