Page MenuHomeFreeBSD

msdosfs: do not deget unlinked denodes
ClosedPublic

Authored by kevans on Sep 20 2019, 5:46 PM.
Tags
None
Referenced Files
F106232925: D21731.diff
Fri, Dec 27, 3:22 PM
Unknown Object (File)
Mon, Dec 9, 9:58 PM
Unknown Object (File)
Nov 25 2024, 1:17 AM
Unknown Object (File)
Nov 24 2024, 2:24 AM
Unknown Object (File)
Sep 19 2024, 2:39 PM
Unknown Object (File)
Sep 19 2024, 2:39 PM
Unknown Object (File)
Sep 19 2024, 2:39 PM
Unknown Object (File)
Sep 19 2024, 2:17 PM
Subscribers

Details

Summary

When a file is unlinked, the denode is not reclaimed until the last reference is dropped, but the directory entry is immediately up for reuse. This is a problem later when createde goes to grab a denode for the newly created entry -- we search the hash and find a dead denode, then return that without even bumping the reference count and the data later gets truncated when the the last reference to the unlinked file is dropped.

This manifested itself as a broken in-place strip(1) on msdosfs. elfcopy will do a sequence incredibly roughly like this:

open("/mnt/foo", ...) => fd 3
mmap()
unlink("/mnt/foo")
open("/mnt/foo", ...) => fd 4
write(4, ...)
close(4)
close(3)

and the resulting file would be truncated, but the write succeeded.

I think we may need to go a step further in msdosfs_inactive and make sure that we do not attempt to detrunc/deupdat if the denode was unlinked and another one has taken its place, but I'm unsure.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I think the answer to my question is no, we do not watch to touch msdosfs_inactive because we still want the clusters associated with the old entry to be freed up. It looks like deupdat won't clobber the directory entry if de_refcnt <= 0, so all that happens is the cluster freeing.

This revision is now accepted and ready to land.Sep 20 2019, 8:02 PM
This revision was automatically updated to reflect the committed changes.