From 881a59ab9e299260a8156da632d621900864e7ef Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 25 Sep 2002 02:13:38 +0000 Subject: [PATCH] - Properly lock v_vflags in getdirents(). --- sys/kern/vfs_extattr.c | 18 ++++++++++++++---- sys/kern/vfs_syscalls.c | 18 ++++++++++++++---- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 5ad587cb19e6..ad9ae633bd86 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -3075,7 +3075,11 @@ ogetdirentries(td, uap) return (error); } } - mp_fixme("Accessing vflags w/o vn lock."); + /* + * XXX We could delay dropping the lock above but + * union_dircheckp complicates things. + */ + vn_lock(vp, LK_EXCLUSIVE|LK_RETRY, td); if ((vp->v_vflag & VV_ROOT) && (vp->v_mount->mnt_flag & MNT_UNION)) { struct vnode *tvp = vp; @@ -3083,9 +3087,10 @@ ogetdirentries(td, uap) VREF(vp); fp->f_data = vp; fp->f_offset = 0; - vrele(tvp); + vput(tvp); goto unionread; } + VOP_UNLOCK(vp, 0, td); } error = copyout(&loff, SCARG(uap, basep), sizeof(long)); fdrop(fp, td); @@ -3167,7 +3172,11 @@ getdirentries(td, uap) return (error); } } - mp_fixme("Accessing vflag without vn lock."); + /* + * XXX We could delay dropping the lock above but + * union_dircheckp complicates things. + */ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if ((vp->v_vflag & VV_ROOT) && (vp->v_mount->mnt_flag & MNT_UNION)) { struct vnode *tvp = vp; @@ -3175,9 +3184,10 @@ getdirentries(td, uap) VREF(vp); fp->f_data = vp; fp->f_offset = 0; - vrele(tvp); + vput(tvp); goto unionread; } + VOP_UNLOCK(vp, 0, td); } if (SCARG(uap, basep) != NULL) { error = copyout(&loff, SCARG(uap, basep), sizeof(long)); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 5ad587cb19e6..ad9ae633bd86 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3075,7 +3075,11 @@ ogetdirentries(td, uap) return (error); } } - mp_fixme("Accessing vflags w/o vn lock."); + /* + * XXX We could delay dropping the lock above but + * union_dircheckp complicates things. + */ + vn_lock(vp, LK_EXCLUSIVE|LK_RETRY, td); if ((vp->v_vflag & VV_ROOT) && (vp->v_mount->mnt_flag & MNT_UNION)) { struct vnode *tvp = vp; @@ -3083,9 +3087,10 @@ ogetdirentries(td, uap) VREF(vp); fp->f_data = vp; fp->f_offset = 0; - vrele(tvp); + vput(tvp); goto unionread; } + VOP_UNLOCK(vp, 0, td); } error = copyout(&loff, SCARG(uap, basep), sizeof(long)); fdrop(fp, td); @@ -3167,7 +3172,11 @@ getdirentries(td, uap) return (error); } } - mp_fixme("Accessing vflag without vn lock."); + /* + * XXX We could delay dropping the lock above but + * union_dircheckp complicates things. + */ + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); if ((vp->v_vflag & VV_ROOT) && (vp->v_mount->mnt_flag & MNT_UNION)) { struct vnode *tvp = vp; @@ -3175,9 +3184,10 @@ getdirentries(td, uap) VREF(vp); fp->f_data = vp; fp->f_offset = 0; - vrele(tvp); + vput(tvp); goto unionread; } + VOP_UNLOCK(vp, 0, td); } if (SCARG(uap, basep) != NULL) { error = copyout(&loff, SCARG(uap, basep), sizeof(long));