Bug 85494 - fsck_ffs: unchecked use of cg_inosused macro etc.
Summary: fsck_ffs: unchecked use of cg_inosused macro etc.
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 5.4-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-30 19:30 UTC by Nate Eldredge
Modified: 2017-12-31 22:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nate Eldredge 2005-08-30 19:30:21 UTC
When fsck_ffs is checking a file system, one of the passes is to check the
cylinder groups and see if the various bitmaps are correct.  For example, on
line 325 of pass5.c it looks at cg_inosused(cg).  cg has been read from the
disk, and cg_inosused is a pointer to cg->cg_iusedoff bytes past cg.  (Defined
in <ufs/ffs/fs.h>.)  Presumably the inosused bitmap is supposed to be in the
same block as the cg structure.  However, if the cylinder group header is
corrupt, cg->cg_iusedoff could be anything and thus cg_inosused(cg) will be a
bogus pointer, and fsck_ffs will crash.  Possibly there is no reasonable way for
fsck_ffs to handle such corruption, but it still shouldn't segfault IMHO. 

Other uses of the cg_* macros are also suspect, and there may be other errors of
the same sort throughout fsck.  dumpfs has similar bugs.

Fix: 

Check cg->iusedoff for sanity before trying to use it.  For instance, make sure
it points within the block that's been read from the disk.
How-To-Repeat: 
I have a filesystem image which crashes fsck_ffs because of this bug.  However,
the image is 1G and may contain some sensitive data (it's a corrupt /var) so I
would rather not make it available.  I can try to explain the problem further if
necessary.
Comment 1 Bruce Cran freebsd_committer freebsd_triage 2010-09-24 21:49:57 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:44 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped