Subject: kern/1436: msdosfs overwrites "." entries in directories
To: None <>
From: John F. Woods <>
List: netbsd-bugs
Date: 09/05/1995 08:22:46
>Number:         1436
>Category:       kern
>Synopsis:       msdosfs overwrites "." entries in directories
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep  5 10:50:08 1995
>Originator:     John F. Woods
>Release:        9/1/95
System: NetBSD 1.0A NetBSD 1.0A (JFW) #14: Wed Aug 9 21:35:57 EDT 1995 i386

	Whenever the msdosfs code wants to alter a directory's properties,
	that directory's "." entry gets smashed with the new copy of the
	directory's entry (which should have gone in the parent directory).

	It turns out that this is because the msdosfs code stores a copy of
	the location of each denode's directory entry -- except that for
	directories it regularizes the location to be the first entry in
	the directory; i.e. the "." entry.  If the denode for the directory
	is modified, the entry gets written back in the wrong place.

	Take a blank MSDOS filesystem, mount it, create two directories, "one"
	and "two".  cd to the mounted filesystem.

	$ chmod 777 one ; ls -l ; ls -l one
	$ mv two twenty ; ls -l ; ls -l two
	If there are any other operations possible that alter a directory's
	denode, they'll do exactly the same thing.
	I have been unable to devote enough time to preparing a patch.  I
	was able to fix the first partial problem (chmod) by adding extra
	pointers that preserved the original location and having the vnode
	update code use that, but it turns out the rename code goes around
	that code (of course, since it's structured like every other filesystem
	and believes that names and identities are separate, sort of).  Fixing
	that, too, probably wouldn't be much time, but I don't have that time.
	If you need a starting point, I can forward the changes I did make.