From 6dae0c1e3e9efccab5f8342977dd7ef6ecaaf68f Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Wed, 19 Feb 2003 11:54:35 +0000 Subject: [PATCH] Do not call smbfs_attr_cacheremove() in the EXDEV case in smbfs_rename(). One of the vnodes is on different mount and is possibly on a different kind of filesystem; treating it as an smbfs vnode then writing to it will probably corrupt it. PR: 48381 MFC after: 1 month --- sys/fs/smbfs/smbfs_vnops.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index 29ff1d7b7754..ee1bee3465fb 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -624,8 +624,10 @@ smbfs_rename(ap) flags |= 2; } else if (fvp->v_type == VREG) { flags |= 1; - } else - return EINVAL; + } else { + error = EINVAL; + goto out; + } smb_makescred(&scred, tcnp->cn_thread, tcnp->cn_cred); /* * It seems that Samba doesn't implement SMB_COM_MOVE call... @@ -643,7 +645,7 @@ smbfs_rename(ap) if (tvp && tvp != fvp) { error = smbfs_smb_delete(VTOSMB(tvp), &scred); if (error) - goto out; + goto out_cacherem; } error = smbfs_smb_rename(VTOSMB(fvp), VTOSMB(tdvp), tcnp->cn_nameptr, tcnp->cn_namelen, &scred); @@ -654,6 +656,10 @@ smbfs_rename(ap) cache_purge(tdvp); cache_purge(fdvp); } + +out_cacherem: + smbfs_attr_cacheremove(fdvp); + smbfs_attr_cacheremove(tdvp); out: if (tdvp == tvp) vrele(tdvp); @@ -663,8 +669,6 @@ smbfs_rename(ap) vput(tvp); vrele(fdvp); vrele(fvp); - smbfs_attr_cacheremove(fdvp); - smbfs_attr_cacheremove(tdvp); #ifdef possible_mistake vgone(fvp); if (tvp)