diff options
author | wpaul <wpaul@FreeBSD.org> | 1996-12-31 07:10:19 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1996-12-31 07:10:19 +0000 |
commit | eb5560009c93fb329f989ff7baa7b0e9802138de (patch) | |
tree | d67e43924543c70a95e77a11db261a4977010ea0 /sys | |
parent | 65d1d7b4e9430ca3e6f7c914d86c6c6c0676e295 (diff) | |
download | FreeBSD-src-eb5560009c93fb329f989ff7baa7b0e9802138de.zip FreeBSD-src-eb5560009c93fb329f989ff7baa7b0e9802138de.tar.gz |
Fix (properly, I hope) 'panic: sillyrename dir' crash that can happen
if you do:
% cd /nfsdir
% mkdir -p foo/foo
% mv foo/foo .
nfs_sillyrename() self-destructs if you try to sillyrename a directory,
however nfs_rename() can be coerced into doing just that by the above
sequence of commands. To avoid this, nfs_rename() now checks that
v_type of the 'destination' vnode != VDIR before attempting the
sillyrename. The server correctly handles this particular situation
by returning ENOTEMPTY on the rename() attempt.
I asked if this was the correct fix for this on -hackers but nobody
ever answered.
This is a 2.2 candidate.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/nfs/nfs_vnops.c | 5 | ||||
-rw-r--r-- | sys/nfsclient/nfs_vnops.c | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 4405179..0bffdb6 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94 - * $Id: nfs_vnops.c,v 1.37 1996/11/06 10:53:12 dfr Exp $ + * $Id: nfs_vnops.c,v 1.38 1996/12/13 21:29:07 wollman Exp $ */ /* @@ -1606,9 +1606,10 @@ nfs_rename(ap) /* * If the tvp exists and is in use, sillyrename it before doing the * rename of the new file over it. + * XXX Can't sillyrename a directory. */ if (tvp && tvp->v_usecount > 1 && !VTONFS(tvp)->n_sillyrename && - !nfs_sillyrename(tdvp, tvp, tcnp)) { + tvp->v_type != VDIR && !nfs_sillyrename(tdvp, tvp, tcnp)) { vrele(tvp); tvp = NULL; } diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 4405179..0bffdb6 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94 - * $Id: nfs_vnops.c,v 1.37 1996/11/06 10:53:12 dfr Exp $ + * $Id: nfs_vnops.c,v 1.38 1996/12/13 21:29:07 wollman Exp $ */ /* @@ -1606,9 +1606,10 @@ nfs_rename(ap) /* * If the tvp exists and is in use, sillyrename it before doing the * rename of the new file over it. + * XXX Can't sillyrename a directory. */ if (tvp && tvp->v_usecount > 1 && !VTONFS(tvp)->n_sillyrename && - !nfs_sillyrename(tdvp, tvp, tcnp)) { + tvp->v_type != VDIR && !nfs_sillyrename(tdvp, tvp, tcnp)) { vrele(tvp); tvp = NULL; } |