From owner-freebsd-bugs@FreeBSD.ORG Wed Aug 31 16:50:07 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 663841065672 for ; Wed, 31 Aug 2011 16:50:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 3A0C98FC0A for ; Wed, 31 Aug 2011 16:50:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p7VGo7F5048589 for ; Wed, 31 Aug 2011 16:50:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p7VGo75t048588; Wed, 31 Aug 2011 16:50:07 GMT (envelope-from gnats) Resent-Date: Wed, 31 Aug 2011 16:50:07 GMT Resent-Message-Id: <201108311650.p7VGo75t048588@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Eugene Grosbein Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B2EF106567B for ; Wed, 31 Aug 2011 16:45:18 +0000 (UTC) (envelope-from eugen@grosbein.pp.ru) Received: from eg.sd.rdtc.ru (unknown [IPv6:2a03:3100:c:13::5]) by mx1.freebsd.org (Postfix) with ESMTP id 7F6118FC19 for ; Wed, 31 Aug 2011 16:45:17 +0000 (UTC) Received: from grosbein.pp.ru (188-123-32-240.rdtc.ru [188.123.32.240] (may be forged)) by eg.sd.rdtc.ru (8.14.5/8.14.5) with ESMTP id p7VGjGIc046199 for ; Wed, 31 Aug 2011 23:45:16 +0700 (NOVST) (envelope-from eugen@grosbein.pp.ru) Received: from grosbein.pp.ru (localhost [127.0.0.1]) by grosbein.pp.ru (8.14.4/8.14.4) with ESMTP id p7VGjCjY002536 for ; Wed, 31 Aug 2011 23:45:12 +0700 (NOVST) (envelope-from eugen@grosbein.pp.ru) Received: (from eugen@localhost) by grosbein.pp.ru (8.14.4/8.14.4/Submit) id p7VGjCtd002535; Wed, 31 Aug 2011 23:45:12 +0700 (NOVST) (envelope-from eugen) Message-Id: <201108311645.p7VGjCtd002535@grosbein.pp.ru> Date: Wed, 31 Aug 2011 23:45:12 +0700 (NOVST) From: Eugene Grosbein To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: bin/160339: [patch] fsck_ffs needs to check d_namlen for zero X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Eugene Grosbein List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Aug 2011 16:50:07 -0000 >Number: 160339 >Category: bin >Synopsis: [patch] fsck_ffs needs to check d_namlen for zero >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Aug 31 16:50:06 UTC 2011 >Closed-Date: >Last-Modified: >Originator: Eugene Grosbein >Release: FreeBSD 8.2-STABLE amd64 >Organization: RDTC JSC >Environment: System: FreeBSD grosbein.pp.ru 8.2-STABLE FreeBSD 8.2-STABLE #1: Fri Jul 1 18:08:55 NOVST 2011 root@grosbein.pp.ru:/usr/local/obj/usr/local/src/sys/DADV amd64 >Description: fsck_ffs checks for directory entry is incomplete: it does not check if d_namlen is zero. OTOH, it checks if namlen > MAXNAMLEN while MAXNAMLEN is 255 and namlen is 8-bit quantity so this check is always false. This check is commented out in NetBSD's fsck_ffs and does not exists in OpenBSD's. But they both do not check for zero value. >How-To-Repeat: My /usr/local filesystem somehow got corrupted, one of subdirectories has a file with zero name length and fsck -y did not find this error. I was forced to apply the following patch and only then the error was corrected: ** Phase 1 - Check Blocks and Sizes ** Phase 2 - Check Pathnames DIRECTORY CORRUPTED I=1531227 OWNER=root MODE=40755 SIZE=4608 MTIME=Aug 30 01:28 2011 DIR=/obj/usr/local/src/secure/lib/libssh SALVAGE? [yn] ** Phase 3 - Check Connectivity ** Phase 4 - Check Reference Counts LINK COUNT FILE I=24 OWNER=root MODE=100644 SIZE=892 MTIME=Sep 17 11:10 2010 COUNT 2 SHOULD BE 1 ADJUST? [yn] ** Phase 5 - Check Cyl groups 459580 files, 7411823 used, 7819495 free (105503 frags, 964249 blocks, 0.7% fragmentation) ***** FILE SYSTEM IS CLEAN ***** ***** FILE SYSTEM WAS MODIFIED ***** >Fix: --- sbin/fsck_ffs/dir.c.orig 2011-08-31 22:54:23.000000000 +0700 +++ sbin/fsck_ffs/dir.c 2011-08-31 23:38:33.000000000 +0700 @@ -225,7 +225,7 @@ type = dp->d_type; if (dp->d_reclen < size || idesc->id_filesize < size || - namlen > MAXNAMLEN || + namlen == 0 || type > 15) goto bad; for (cp = dp->d_name, size = 0; size < namlen; size++) >Release-Note: >Audit-Trail: >Unformatted: