From owner-freebsd-bugs Sat Jun 30 5:40:14 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 6BF3537B403 for ; Sat, 30 Jun 2001 05:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f5UCe1q05377; Sat, 30 Jun 2001 05:40:01 -0700 (PDT) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 27E9E37B401 for ; Sat, 30 Jun 2001 05:30:20 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.3/8.11.3) id f5UCUKS04942; Sat, 30 Jun 2001 05:30:20 -0700 (PDT) (envelope-from nobody) Message-Id: <200106301230.f5UCUKS04942@freefall.freebsd.org> Date: Sat, 30 Jun 2001 05:30:20 -0700 (PDT) From: Jiangyi Liu To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: i386/28536: writing to corrupted msdosfs causes kernel panic Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 28536 >Category: i386 >Synopsis: writing to corrupted msdosfs causes kernel panic >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jun 30 05:40:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Jiangyi Liu >Release: 4.3-STABLE >Organization: >Environment: FreeBSD fatcow.home 4.3-STABLE FreeBSD 4.3-STABLE #0: Sat Jun 30 14:52:22 CST 2001 jyliu@fatcow.home:/usr/src/sys/compile/FATCOW i386 >Description: In -current and -stable, mountmsdosfs()@ msdosfs_vfsops.c doesn't not check if pm_nxtfree exceeds the max cluster in the file system. So if a corrupted msdos filesystem(which is not uncommon) is written, the following code in updatefats()@msdosfs_fat.c will generate a panic. u_long cn = pmp->pm_nxtfree; if (pmp->pm_freeclustercount && (pmp->pm_inusemap[cn / N_INUSEBITS] & (1 << (cn % N_INUSEBITS)))) { .... } >How-To-Repeat: Mount a corrupted msdos filesystem(e.g. not probably shutdown) and write to it. >Fix: Apply the following patch to test if next free cluster exceeds the max cluster in mountmsdosfs(). *** msdosfs_vfsops.c.orig Sat Jun 30 14:21:15 2001 --- msdosfs_vfsops.c Sat Jun 30 14:30:25 2001 *************** *** 681,686 **** --- 681,692 ---- /* * Check and validate (or perhaps invalidate?) the fsinfo structure? XXX */ + if (pmp->pm_fsinfo && pmp->pm_nxtfree > pmp->pm_maxcluster) { + printf ("Next free cluster in FSInfo (%u) exceeds maxcluster (%u)\n", + pmp->pm_nxtfree, pmp->pm_maxcluster); + error = EINVAL; + goto error_exit; + } /* * Allocate memory for the bitmap of allocated clusters, and then >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message