Date: Tue, 22 Sep 1998 18:16:52 -0700 (PDT) From: Don Lewis <Don.Lewis@tsc.tdk.com> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/8030: [PATCH] fsck -p corrupts filesystem and marks it clean Message-ID: <199809230116.SAA07599@w3.gv.tsc.tdk.com>
next in thread | raw e-mail | index | archive | help
>Number: 8030 >Category: bin >Synopsis: when fsck reconnects an orphaned directory it mucks up the ref count of the previous .. directory >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Sep 22 18:20:00 PDT 1998 >Last-Modified: >Originator: Don Lewis >Organization: TDK Semiconductor Corp. >Release: FreeBSD 3.0-BETA i386 >Environment: FreeBSD 3.0 only. This problem does not seem to be present in 2.2.x or 2.1.x. >Description: Two patches were made to the linkup() function in fsck to cause it to reduce the reference count of a directory if an orphaned directory is reconnected under lost+found and the orphaned directory had a .. link pointing to the first directory. The first patch was made by Terry Lambert and the second patch was introduced by the Lite2 merge. The combination of the two patches causes fsck to decrement the reference count twice. A situation where the reference count on a file or directory is *bad*. What's worse is that the preen operation of fsck can take a slightly inconsistent filesystem, corrupt it in this manner, then set the clean flag so that fsck won't check the filesystem again in the future. I believe that Terry's patch is more desirable, since it only adjusts the reference count if the ophaned directory is actually reconnected and its .. link changed. >How-To-Repeat: Start with an ordinary formatted floppy and ... # newfs -t 2 -u 18 -l 1 fd0 # mount /dev/fd0 /mnt # mount /dev/fd0 /mnt # umount /dev/fd0 # fsck /dev/fd0 # fsdb /dev/rfd0 fsdb (inum: 256)> cd /a fsdb (inum: 128)> rm b fsdb (inum: 256)> quit fsdb (inum: 256)> quit fsdb (inum: 256)> quit # fsck -p /dev/rfd0 # corrupts filesystem and sets clean flag # fsck -p /dev/rfd0 # ignores corrupted filesystem # fsck /dev/rfd0 # repairs filesystem damage >Fix: Back out patch from Lite2. --- fsck/dir.c.orig Sun Jun 28 12:23:02 1998 +++ fsck/dir.c Tue Sep 22 16:56:10 1998 @@ -417,8 +417,6 @@ else if (reply("RECONNECT") == 0) return (0); - if (parentdir != 0) - lncntp[parentdir]++; if (lfdir == 0) { dp = ginode(ROOTINO); idesc.id_name = lfname; >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809230116.SAA07599>