diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2012-11-02 13:56:36 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2012-11-02 13:56:36 +0000 |
commit | 140dedb81c5bee09f8bc21997b990f4f96192ce7 (patch) | |
tree | 77eb9f8e9de108d0ae7792cfceedcd340198177e /sys/fs/unionfs | |
parent | cd463097e966f4b968964c7de2c34d9ebe8d5226 (diff) | |
download | src-140dedb81c5bee09f8bc21997b990f4f96192ce7.tar.gz src-140dedb81c5bee09f8bc21997b990f4f96192ce7.zip |
The r241025 fixed the case when a binary, executed from nullfs mount,
was still possible to open for write from the lower filesystem. There
is a symmetric situation where the binary could already has file
descriptors opened for write, but it can be executed from the nullfs
overlay.
Handle the issue by passing one v_writecount reference to the lower
vnode if nullfs vnode has non-zero v_writecount. Note that only one
write reference can be donated, since nullfs only keeps one use
reference on the lower vnode. Always use the lower vnode v_writecount
for the checks.
Introduce the VOP_GET_WRITECOUNT to read v_writecount, which is
currently always bypassed to the lower vnode, and VOP_ADD_WRITECOUNT
to manipulate the v_writecount value, which manages a single bypass
reference to the lower vnode. Caling the VOPs instead of directly
accessing v_writecount provide the fix described in the previous
paragraph.
Tested by: pho
MFC after: 3 weeks
Notes
Notes:
svn path=/head/; revision=242476
Diffstat (limited to 'sys/fs/unionfs')
-rw-r--r-- | sys/fs/unionfs/union_subr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index d35320273214..64bd4acec35b 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -945,7 +945,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, vput(vp); goto unionfs_vn_create_on_upper_free_out1; } - vp->v_writecount++; + VOP_ADD_WRITECOUNT(vp, 1); CTR3(KTR_VFS, "%s: vp %p v_writecount increased to %d", __func__, vp, vp->v_writecount); *vpp = vp; @@ -1082,7 +1082,7 @@ unionfs_copyfile(struct unionfs_node *unp, int docopy, struct ucred *cred, } } VOP_CLOSE(uvp, FWRITE, cred, td); - uvp->v_writecount--; + VOP_ADD_WRITECOUNT(uvp, -1); CTR3(KTR_VFS, "%s: vp %p v_writecount decreased to %d", __func__, uvp, uvp->v_writecount); |