Page MenuHomeFreeBSD

fstyp: search for file systems labels by largest offset first
ClosedPublic

Authored by rew on Dec 1 2024, 9:07 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 26, 12:24 PM
Unknown Object (File)
Tue, Jan 21, 4:49 PM
Unknown Object (File)
Dec 26 2024, 1:13 PM
Unknown Object (File)
Dec 26 2024, 12:31 PM
Unknown Object (File)
Dec 26 2024, 10:40 AM
Unknown Object (File)
Dec 26 2024, 8:04 AM
Unknown Object (File)
Dec 4 2024, 2:43 PM
Unknown Object (File)
Dec 4 2024, 8:51 AM
Subscribers

Details

Summary

fstyp can misidentify a UFS file system as MSDOS when the partition was
originally created as MSDOS.

The misidentification happens for the following reasons:

  • initial signature header for an MSDOS file system is read from offset 0 plus 512 bytes
  • the superblock for UFS is read from offset 64k, 8k, 0k, or 256k plus 8192 bytes
  • newfs does not clear the area before writing UFS's superblock
  • fstyp searches for file systems labels alphabetically

Given the above, the false positive happens because fstyp detects the
MSDOS file system because newfs leaves the MSDOS label intact and MSDOS
is checked before UFS in fstyp's ordering list.

To avoid this false positive, reorder fstyp's label search list by
largest offset instead of alphabetically.

The implemented fix was suggested by reporter, Richard M. Kreuter.

PR: 252787

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rew requested review of this revision.Dec 1 2024, 9:07 AM
This revision is now accepted and ready to land.Dec 1 2024, 11:23 PM

It's worth adding a comment in the src explaining the ordering

It's worth adding a comment in the src explaining the ordering

sounds good, I added the comment on commit