diff options
| author | pooka <pooka@NetBSD.org> | 2009-04-03 14:47:40 +0000 |
|---|---|---|
| committer | pooka <pooka@NetBSD.org> | 2009-04-03 14:47:40 +0000 |
| commit | bb78ae5d1bb04a4962faaca39c1d03c98c5ea72d (patch) | |
| tree | d344a61fe52e4a49ef996c094e80bf0db9ac70d4 /sys | |
| parent | 54f76d2fa4697c2986371f510e7fdacca442de2b (diff) | |
Fix yet another recent crashy bug in tmpfs rename: since the source
dirent is no longer cached in lookup and we do the lookup ourselves
in rename, we are most definitely not allowed to assert that it
matches the source vnode passed as an argument. In case the source
node does not exist or has been replaced, punt with ENOENT.
Also, nuke some misleading prehistoric comments which haven't been
valid in over a year.
Fixes PR kern/41128 by Nicolas Joly
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/fs/tmpfs/tmpfs_vnops.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index b40dfa0b74c..0167d0eb0be 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.54 2009/03/19 13:47:32 pooka Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.55 2009/04/03 14:47:40 pooka Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.54 2009/03/19 13:47:32 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.55 2009/04/03 14:47:40 pooka Exp $"); #include <sys/param.h> #include <sys/dirent.h> @@ -824,12 +824,14 @@ tmpfs_rename(void *v) goto out_unlocked; } + /* + * If the node we were renaming has scarpered, just give up. + */ de = tmpfs_dir_lookup(fdnode, fcnp); - if (de == NULL) { + if (de == NULL || de->td_node != fnode) { error = ENOENT; goto out; } - KASSERT(de->td_node == fnode); /* If source and target are the same file, there is nothing to do. */ if (fvp == tvp) { @@ -837,14 +839,6 @@ tmpfs_rename(void *v) goto out; } - /* Avoid manipulating '.' and '..' entries. */ - if (de == NULL) { - KASSERT(fvp->v_type == VDIR); - error = EINVAL; - goto out; - } - KASSERT(de->td_node == fnode); - /* If replacing an existing entry, ensure we can do the operation. */ if (tvp != NULL) { KASSERT(tnode != NULL); |
