opnsense-src/sys/fs
Stefan Eßer 445d3d227e msdosfs: fix potential inode collision on FAT12 and FAT16
FAT file systems do not use inodes, instead all file meta-information
is stored in directory entries.

FAT12 and FAT16 use a fixed size area for root directories, with
typically 512 entries of 32 bytes each (for a total of 16 KB) on hard
disk formats. The file system data is stored in clusters of typically
512 to 4096 bytes, depending on the size of the file system.

The current code uses the offset of a DOS 8.3 style directory entry as
a pseudo-inode, which leads to inode values of 0 to 16368 for typical
root directories with 512 entries.

Sub-directories use 2 cluster length plus the byte offset of the
directory entry in the data area for the pseudo-inode, which may be
as low as 1024 in case of 512 byte clusters. A sub-directory in
cluster 2 and with 512 byte clusters will therefore lead to a
re-use of inode 1024 when there are at least 32 DOS 8.3 style
filenames in the root directory (or 11 14-character Windows
long file names, each of which takes up 3 directory entries).

FAT32 file systems are not affected by this issue and FAT12/FAT16
file systems with larger cluster sizes are unlikely to have as
many directory entries in the root directory as are required to
cause the collision.

This commit leads to inode numbers that are guaranteed to not collide
for all valid FAT12 and FAT16 file system parameters. It does also
provide a small speed-up due to more efficient use of the vnode cache.

Approved by:	mckusick
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D43978
2024-02-20 13:02:24 +01:00
..
autofs sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
cd9660 cd9660: Add support for mask,dirmask,uid,gid options 2024-01-12 14:51:31 -08:00
cuse sys: Remove $FreeBSD$: one-line .c comment pattern 2023-08-16 11:54:24 -06:00
deadfs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
devfs kcmp(2): implement for devfs files 2024-01-24 07:11:26 +02:00
ext2fs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
fdescfs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
fifofs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
fuse fusefs: only test for incoherency if FN_SIZECHANGE is set 2024-02-08 20:13:24 -07:00
mntfs sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
msdosfs msdosfs: fix potential inode collision on FAT12 and FAT16 2024-02-20 13:02:24 +01:00
nfs nfscl: Only update atime for Copy when noatime is not specified 2024-01-11 16:38:33 -08:00
nfsclient ncl_bioread(): check for vp->v_object before accessing it 2024-01-15 17:19:58 +02:00
nfsserver Add vnode_pager_clean_{a,}sync(9) 2024-01-11 18:44:53 +02:00
nullfs nullfs: do not allow bypass on copy_file_range() 2023-11-28 19:32:53 +02:00
procfs procfs: Add self & exe symlinks like NetBSD does 2024-02-02 18:34:59 -07:00
pseudofs pseudofs: fix off by one in hash iteration in pfs_purge 2023-11-20 05:57:25 +00:00
smbfs Add vnode_pager_clean_{a,}sync(9) 2024-01-11 18:44:53 +02:00
tarfs vfs: use __enum_uint8 for vtype and vstate 2023-07-05 15:06:30 +00:00
tmpfs tmpfs: increase vfs.tmpfs.memory_percent to 100 as workaround 2024-01-23 12:46:31 -06:00
udf sys: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:00 -07:00
unionfs unionfs: work around underlying FS failing to respect cn_namelen 2024-02-18 09:19:23 -06:00