From nobody Fri Feb 23 10:43:44 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Th67N53G8z5CDCx for ; Fri, 23 Feb 2024 10:43:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Th67N40W3z4YHM for ; Fri, 23 Feb 2024 10:43:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708685024; a=rsa-sha256; cv=none; b=ZfepSqn71EhQnxWtC7OA3+ev2D9gUbsArLjv3pFiNaIRqghI7BdafScNR/ZHiC6xeniByQ 7CVlLfLCmKMnyirO5XUqJg96frHryROQA/8e2An7UJrC0BT4r/rPcO3rbQW3/gO/MeMp8H BPgwttxmVmoTVlgHoE/1Vjm+3zEt2xZUj08K52Tvv6CPFS8IOsgUkcktAzWOeA7tO9HE7I MFgisaslaNduatGNfXEt7/oHwxPq8+GaAxkeRA5JFBNjbBJyqwUtZlAisnDnTUKh4/gq+n xLP/TCYP+E7PAkIvJ6JZb0PEuENe65b5V3sVoqbxGw7XkNIwuWCkU1Kgn/JbuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708685024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RIg4Zj/IWmy6kVOoHueM4Zag2fvwnJCvQGRZ0v2yEI4=; b=dLW1V05GZBaje6/MsIj1qrXllreB6ZhYta405EjZZz2WJdUmg1L99EAdOjkRvHIRVMFwMQ tOPqCd25CFCP3oo3ODghC91fTn7Z+tV/zRGdSoaizu9OjjGIvgbPkV/gZIhhCz2xJ4RT7k tr4U3IcePw8kVoXNscAUS5c9pGQ4BXBnpz8ebRLgTJomRmBQUsE1D15XCsl2nryppvAhk9 tarB+2k4eIcVXWbMsVUm0YkX62sMqtGI43np/liLOHpvzeLFS+mp9AcfFjudDkAUKV7tWs xWiTQMLAi8d3/90vEb07OE3EBBft4jm0mdtPvOjztZF03z5j+nl75WymAdIPkw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Th67N34Tmz1Bq6 for ; Fri, 23 Feb 2024 10:43:44 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 41NAhi1N065605 for ; Fri, 23 Feb 2024 10:43:44 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 41NAhiLJ065600 for bugs@FreeBSD.org; Fri, 23 Feb 2024 10:43:44 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 277239] Potential inode collision on FAT12 and FAT16 causes directory corruption Date: Fri, 23 Feb 2024 10:43:44 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: Unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: se@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277239 Bug ID: 277239 Summary: Potential inode collision on FAT12 and FAT16 causes directory corruption Product: Base System Version: Unspecified Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: se@FreeBSD.org FAT file systems do not use inodes, instead all file meta-information is st= ored in directory entries. FAT12 and FAT16 use a fixed size area for root directories, with typically = 512 entries of 32 bytes each (for a total of 16 KB) on hard disk formats. The file system data is stored in clusters of typically 512 to 4096 bytes (= max. supported is 32 KB) The current code uses the offset of a DOS 8.3 style directory entry as a pseudo-inode, which leads to inode values of 0 to 16368 for typical root directory entries. Sub-directories use 2 cluster length plus the byte offset of the directory entry in the data area for the pseudo-inode, which may be as low as 1024 in case of 512 byte clusters, 8192 in case of 4 KB clusters. This issue is demonstrated by the following test script: #!/bin/sh FS=3D/mnt/MSDOSFS-TEST MDUNIT=3D0 cleanup () { cd / umount /dev/md$MDUNIT rm -rf $FS fsck_msdosfs -n /dev/md$MDUNIT mdconfig -u $MDUNIT -d } mdconfig -u $MDUNIT -t malloc -s 4m newfs_msdos -F 16 -c 1 /dev/md$MDUNIT mkdir -p $FS mount -t msdos /dev/md$MDUNIT $FS trap "cleanup" EXIT cd $FS mkdir TESTDIR touch TESTDIR/TEST for i in $(jot 33) do touch TEST.$i done This script reports an error when writing the 32nd entry and the file system will have been remounted r/o when the 33rd file is to be written: touch: TEST.32: Bad file descriptor touch: TEST.33: Read-only file system The 32th file gets a pseudo-inode value of 1024, the same value already assigned to TESTDIR, leading to a directory and a file with identical inode numbers. The patch in review D43978 changes the calculation of pseudo-inodes to acco= unt for the actual number of directory entries in the root file system and avoi= ds the collision for all supported file-system parameters. --=20 You are receiving this mail because: You are the assignee for the bug.=