freebsd kernel with SKQ
Go to file
Bruce Evans 206e5b7e27 Fixed some races and misleading comments in ufs_rename().
1. When a directory is renamed to an existing (empty) directory,
it is possible for the target vnode to become the source vnode
underneath you (because another process may complete the same
rename).  It was assumed that this can't happen, and the bogus
errno EINVAL was returned.  This was fairly harmless.

Fix: return ENOENT instead, as if the source directory was renamed
a little earlier.

2. The same metamorphosis is possible for non-directories.  It was
assumed that this can't happen, and the code for handling "just
removing a link name" happened to be used.  This would have worked
except for fatal bugs in the link name removal - the link name was
assumed to still be there, and a null pointer was followed.

Fix: check the result of relookup().  This fixes PR 1930.

Notes:

(a) POSIX seems to say that removing link names shall have no effect.
BSD (4.4Lite2 at least) does something reasonable instead.

(b) The relookup() may find a file unrelated to the original.
Removing this isn't correct.  Consider 3 existing files A, B and
C, and concurrent renames: AB = rename(A, B), another AB, and
CA = rename("c", "a").  If rename() is atomic, then only the
following results are possible:

	AB, AB (fails), CA: A = original C, B = original A, C = gone
	AB, CA, AB:         A = gone,       B = original C, C = gone
	CA, AB, AB (fails): A = gone,       B = original C, C = gone

but ufs_rename() can give:

	A,AB,CA,B (sorta):  A = gone,       B = original A, C = gone

This usually doesn't matter, since getting into a race is usually
an error.
---

These fixes should be in 2.1.6 and 2.2.
1996-11-04 16:05:51 +00:00
bin Replace collate_range_cmp call with its code 1996-10-31 07:22:48 +00:00
contrib This commit was generated by cvs2svn to compensate for changes in r19370, 1996-11-03 17:03:03 +00:00
eBones First round of moving secure telnet (AKA kerberised telnet) to its new home 1996-10-26 17:20:52 +00:00
etc /dev/vn0b is supposed to be a block device, so don't test(1) whether 1996-11-03 14:41:58 +00:00
games Uncomment static from collate_range_cmp, no more in locale.h 1996-10-31 14:49:40 +00:00
gnu Get rid of bogus #ifdef's. 1996-11-04 04:36:31 +00:00
include Remove collate_range_cmp 1996-10-31 14:41:30 +00:00
lib Compile libtelnet from eBones, not secure. 1996-11-03 16:59:04 +00:00
libexec Compile telnetd from eBones instead of secure. 1996-11-03 17:00:12 +00:00
lkm Prepare kernel to take advantage of "branded" ELF binaries. 1996-10-16 17:51:08 +00:00
release Use macros for package names so it's easier to update them in one 1996-11-04 12:56:33 +00:00
sbin fix usage string 1996-11-04 00:53:12 +00:00
secure Fold sendmail-8.8.2 changes into files that have been touched. 1996-10-24 05:07:25 +00:00
share In one place, bsd.port.mk was not enclosed in <tt></tt>. 1996-11-04 00:27:07 +00:00
sys Fixed some races and misleading comments in ufs_rename(). 1996-11-04 16:05:51 +00:00
tools Back out a little more of the previous changes. No longer change 1996-10-31 15:57:25 +00:00
usr.bin Install message catalog links according to standard naming convention 1996-11-04 02:52:33 +00:00
usr.sbin Use macros for package names so it's easier to update them in one 1996-11-04 12:56:33 +00:00
COPYRIGHT This is the official 4.4 Lite copyright. 1994-09-11 07:53:28 +00:00
Makefile use NOSHARE variable to skip 'share' directory, useful for shared installations 1996-11-01 19:03:33 +00:00