opnsense-src/sys
Kyle Evans 5fdac75222 msdosfs: do not deget unlinked denodes
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, as long
as a reference to the unlinked file had not been closed.

Some archaeology indicates that this bug has likely existed since msdosfs
was converted to use vfs_hash instead of a home rolled hash implementation
in r143570. Prior to that point, the hashget implementation would do a
refcnt check while searching and explicitly only return a denode with
de_refcnt != 0. vfs_hash did not yet have the callback that it does today,
so this slipped away and did not come back when it later grew that
functionality.

The comment indicating that we want to skip these denodes has been updated
to reflect where this is actually done. My repo-diving session seems to
indicate that the refcnt check was likely never actually below the comment,
to be pedantic, but instead a detail wrapped up in the hashget
implementation since the beginning of its inclusion into FreeBSD.

This bug was the cause behind the issue addressed in r352557.

Reported by:	jhibbits
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D21731
2019-09-20 20:47:10 +00:00
..
amd64 Fix a couple of nits in r352110. 2019-09-16 15:06:19 +00:00
arm Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
arm64 Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
bsm Create new EINTEGRITY error with message "Integrity check failed". 2019-01-17 06:35:45 +00:00
cam Fix assumptions of only one device per SES slot. 2019-09-11 03:25:30 +00:00
cddl fix dsl_scan_ds_clone_swapped logic 2019-09-19 09:43:56 +00:00
compat linux: add trivial renameat2 implementation 2019-09-11 13:01:59 +00:00
conf Add support for BERI statcounters. 2019-09-18 16:13:50 +00:00
contrib Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
crypto Stop using des_cblock * for arguments to DES functions. 2019-08-26 17:25:07 +00:00
ddb ddb(4): Add some support for lexing IPv6 addresses 2019-09-09 16:32:23 +00:00
dev Add quirk for XHCI(4) controllers to support USB control transfers 2019-09-20 11:28:45 +00:00
dts dtso: allwinner: Add an overlay for H3 thermal node 2019-08-24 13:26:34 +00:00
fs msdosfs: do not deget unlinked denodes 2019-09-20 20:47:10 +00:00
gdb gdb(4): Root a sysctl tree at 'debug.gdb.' 2019-09-08 22:52:47 +00:00
geom Add a "count_until_fail" option to gnop, which says to start failing 2019-09-13 23:03:56 +00:00
gnu arm: dts: am33xx: Fix the region for uart0 2019-08-07 13:11:53 +00:00
i386 Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
isa
kern remove redundant "ktls" in KTLS thr name 2019-09-20 09:36:07 +00:00
kgssapi Stop using des_cblock * for arguments to DES functions. 2019-08-26 17:25:07 +00:00
libkern Remove zlib 1.0.4 from kernel. 2019-08-25 17:13:00 +00:00
mips mips: move support for temporary mappings above KSEG0 to per-CPU data 2019-09-17 03:39:31 +00:00
modules powerpc64/powernv: Add opal NVRAM driver for PowerNV systems 2019-09-14 03:30:34 +00:00
net Add SIOCGIFDOWNREASON. 2019-09-17 18:49:13 +00:00
net80211 Enhance the comment ieee80211_add_channel() to avoid a 2019-06-10 14:31:18 +00:00
netgraph avoid holding PCB mutex during copyin/copyout() 2019-08-30 16:35:31 +00:00
netinet Fix the handling of invalid parameters in ASCONF chunks. 2019-09-20 08:20:20 +00:00
netinet6 When processing an incoming IPv6 packet over the loopback interface which 2019-09-19 10:22:29 +00:00
netipsec Fix broken window replay check that will allow old packet to be accepted. 2019-09-06 14:30:23 +00:00
netpfil Drivers may pass runt packets to filter. This is okay. 2019-09-13 22:36:04 +00:00
netsmb Stop using des_cblock * for arguments to DES functions. 2019-08-26 17:25:07 +00:00
nfs
nfsclient
nfsserver
nlm
ofed OFED: Fix accidental double-copy of rdma_sdp.h in r351176 2019-08-18 04:19:41 +00:00
opencrypto Adjust the deprecated warnings for /dev/crypto to be less noisy. 2019-08-27 21:29:37 +00:00
powerpc Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
riscv RISC-V: Support EARLY_AP_STARTUP 2019-09-16 22:17:16 +00:00
rpc Avoid relying on header pollution from sys/refcount.h. 2019-07-29 20:26:01 +00:00
security vm_map_simplify_entry considers merging an entry with its two 2019-08-25 07:06:51 +00:00
sparc64 Revert r352406, which contained changes I didn't intend to commit. 2019-09-16 15:04:45 +00:00
sys elf_common: add ELF note names 2019-09-20 09:04:52 +00:00
teken Adjust teken to allow build as part of loader 2019-09-05 18:07:40 +00:00
tests Regularize the Netflix copyright 2019-02-04 21:28:25 +00:00
tools fw_stub.awk: use @generated tag in generated files 2019-09-11 13:35:22 +00:00
ufs vfs: convert struct mount counters to per-cpu 2019-09-16 21:37:47 +00:00
vm sys/vm/vm_glue.c: Incorrect function name in panic string 2019-09-19 07:28:24 +00:00
x86 Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
xdr
xen xen: introduce a new way to setup event channel upcall 2019-01-30 11:34:52 +00:00
Makefile