freebsd-dev/sys/fs
Stefan Eßer 0728695c63 fs/msdosfs: Fix potential panic and size calculations
Some combinations of FAT12 file system parameters could cause a kernel
panic due to an unmapped access if the size of the FAT was larger than
the CPU page size. The reason is that FAT12 uses 3 bytes to store
2 FAT pointers, leading to partial FAT pointers at the end of buffers
of a size that is not a multiple of 3.

With a typical page size of 4 KB, this caused the FAT entry at byte
offsets 4095 and 4096 to cross the page boundary, with only the first
page mapped. This was fixed by adjusting the mapping to always cover
both bytes of each FAT entry.

Testing revealed 2 other inconsistencies that are fixed by this commit:

1) The calculation of the size of the data area did not take into
   account the fact that the first two data block numbers are reserved
   and that the data area starts with block 2. This could cause a
   FAT12 file system created with the maximum supported number of
   blocks to be incorrectly identified as FAT16.

2) The root directory does not take up space in the data area of a
   FAT12 or FAT16 file system, since it is placed into a reserved
   area outside of that data area. This commits makes stat() report
   the logical size of the root directory, but with 0 blocks allocated
   from the data area.

PR:		270587
Reviewed by:	mckusick
Differential Revision:	https://reviews.freebsd.org/D39386
2023-04-25 09:58:29 +02:00
..
autofs vfs: add the concept of vnode state transitions 2022-12-26 17:35:12 +00:00
cd9660 fs/cd9660: add header include guards 2023-03-30 19:20:54 -04:00
cuse cuse(3): Cosmetic change about testing boolean values. 2022-10-04 13:51:06 +02:00
deadfs deadfs: consistently return EOPNOTSUPP for fplookup vops 2023-04-06 15:20:41 +00:00
devfs vfs: add the concept of vnode state transitions 2022-12-26 17:35:12 +00:00
ext2fs ext2fs: extract crc16 into sys/crc16.h 2023-04-24 12:41:52 +03:00
fdescfs fdesc_lookup(): drop fdropped 2023-03-24 19:47:22 +02:00
fifofs fifofs: ansify 2023-02-07 23:18:51 +00:00
fuse fuse: Remove set but unused cr_gid variable. 2023-03-31 10:57:13 -07:00
mntfs vfs: add the concept of vnode state transitions 2022-12-26 17:35:12 +00:00
msdosfs fs/msdosfs: Fix potential panic and size calculations 2023-04-25 09:58:29 +02:00
nfs nfscl: Fix support for doing Null RPCs 2023-04-07 12:57:26 -07:00
nfsclient nfscl: Make coverity happy 2023-03-28 17:08:45 -07:00
nfsserver nfsd: Add support for the SP4_MACH_CRED case in ExchangeID 2023-04-07 12:49:23 -07:00
nullfs nullfs: ansify 2023-02-07 23:22:27 +00:00
procfs procfs: Sync a documentation comment with the code. 2023-04-10 17:58:46 +00:00
pseudofs pseudofs: Simplify pfs_visible_proc 2023-04-02 11:24:10 +03:00
smbfs smbfs: ansify 2023-02-07 23:35:11 +00:00
tarfs tarfs: Use the existing CTLFLAG_RWTUN flag definition 2023-04-12 12:20:38 +08:00
tmpfs tmpfs: add missing vop_fplookup ops to tmpfs_fifoop_entries 2023-04-18 18:06:30 +00:00
udf udf: Remove set but unused variable from udf_getattr. 2023-04-10 10:31:45 -07:00
unionfs unionfs_mkdir(): handle dvp reclamation 2023-04-17 20:31:40 -05:00