Bug 19426 - fsck(8) allows non-zero di_size on device inodes
Summary: fsck(8) allows non-zero di_size on device inodes
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 3.4-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: dwmalone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2000-06-21 23:30 UTC by iedowse
Modified: 2000-07-12 07:21 UTC (History)
0 users

See Also:


Attachments
file.diff (418 bytes, patch)
2000-06-21 23:30 UTC, iedowse
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description iedowse 2000-06-21 23:30:00 UTC
	
	The FreeBSD ffs code assumes that the di_size field of a device
	special file's inode will always be zero. However fsck(8) does
	not ensure that this is the case. 

	This is only a problem if part of a filesystem's inode tables
	should become corrupted. In this case it is possible for fsck
	to consider the filesystem as 'clean' when it is not; attempts
	to delete these corrupted device special files wil result in
	system panics.

	(After a relatively minor case of disk corruption on a machine
	I was working on, deleting the affected device file appeared to
	make ffs_truncate go wild. The resulting corruption was much
	worse than the original problem.)

Fix: Apply the following patch in src/sbin/fsck. Someone might like
	to comment on whether checking for types IFIFO and IFSOCK is
	sensible here?
How-To-Repeat: 
	The following commands demonstrate the problem by specifically
	writing junk into the di_size field of a special file's inode. 

	dd if=/dev/zero bs=1k of=/tmp/fdimage count=1440
	vnconfig -e /dev/vn0 /tmp/fdimage
	newfs -T fd1440 /dev/vn0c
	mount /dev/vn0c /mnt
	mknod /mnt/chardev c 1 1
	umount /mnt

	# some magic to corrupt the di_size field of 'chardev'
	dd if=/dev/vn0c skip=56 count=1 > /tmp/x
	(head -c 395 /tmp/x; echo -n x; tail -c 116 /tmp/x) > /tmp/x1
	dd if=/tmp/x1 of=/dev/vn0c seek=56 count=1

	# Perform a full check, note how no errors are found
	fsck /dev/vn0

	mount /dev/vn0c /mnt
	rm /mnt/chardev		 # *Boom*
Comment 1 dwmalone freebsd_committer freebsd_triage 2000-07-11 12:39:12 UTC
Responsible Changed
From-To: freebsd-bugs->dwmalone

Local PR.
Comment 2 dwmalone freebsd_committer freebsd_triage 2000-07-11 12:39:12 UTC
Responsible Changed
From-To: freebsd-bugs->dwmalone

Local PR.
Comment 3 Kirk McKusick freebsd_committer freebsd_triage 2000-07-12 07:19:54 UTC
State Changed
From-To: open->closed

The submitted patch was accepted verbatim as delta 1.18 
to fsck/pass1.c. The patch resolved the problem.