From nobody Wed Oct 06 15:11:57 2021 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 0941D17EF00F for ; Wed, 6 Oct 2021 15:11:58 +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 4HPdGP6fn6z3pKq for ; Wed, 6 Oct 2021 15:11:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) 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 BA4552235E for ; Wed, 6 Oct 2021 15:11:57 +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 196FBvlV004528 for ; Wed, 6 Oct 2021 15:11:57 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 196FBvsc004527 for bugs@FreeBSD.org; Wed, 6 Oct 2021 15:11:57 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 258964] Mounting a corrupt FAT32 disk can cause a kernel page fault. Date: Wed, 06 Oct 2021 15:11:57 +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: 13.0-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: rtm@lcs.mit.edu 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 attachments.mimetype attachments.created 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 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D258964 Bug ID: 258964 Summary: Mounting a corrupt FAT32 disk can cause a kernel page fault. Product: Base System Version: 13.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu Attachment #228483 text/plain mime type: Created attachment 228483 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D228483&action= =3Dedit A program to produce a corrupt FAT32 disk image. I've attached a program that produces a corrupt FAT32 image that causes a "fault on nofault entry" panic. The immediate cause is that fillinusemap() calls bread() with size=3D0. The size=3D0 arises because the FAT32 disk image specifies 16384 bytes per sector and 134217728 sectors per FAT; mountmsdosfs() multiplies these to produce pm_FATsecs, which is 0x20000000000. fatblock() produces a minimum size to read of pm_FATsecs, and fillinusemap() passes that size to bread(). However, bread()'s size argument is an int, so the 0x20000000000 is truncated to zero. You can see the image and crash: % cc fat325.c % ./a.out % sudo mdconfig -f fat325.img % sudo mount_msdosfs /dev/md0 /mnt vm_fault_lookup: fault on nofault entry, addr: 0xfffffe0009f58000 cpuid =3D 0 time =3D 1633532887 KDB: stack backtrace: #0 0xffffffff80c574c5 at kdb_backtrace+0x65 #1 0xffffffff80c09ea1 at vpanic+0x181 #2 0xffffffff80c09d13 at panic+0x43 #3 0xffffffff80f2898b at vm_fault+0x144b #4 0xffffffff80f27461 at vm_fault_trap+0xb1 #5 0xffffffff8108b3b8 at trap_pfault+0x1f8 #6 0xffffffff8108a86d at trap+0x27d #7 0xffffffff81061958 at calltrap+0x8 #8 0xffffffff80ab0e9b at msdosfs_mount+0xdeb #9 0xffffffff80cda9b9 at vfs_domount+0x5e9 #10 0xffffffff80cd9bd7 at vfs_donmount+0x8e7 #11 0xffffffff80cd92b9 at sys_nmount+0x69 #12 0xffffffff8108babc at amd64_syscall+0x10c #13 0xffffffff8106227e at fast_syscall_common+0xf8 My machine runs FreeBSD xxx 13.0-RELEASE-p4 FreeBSD 13.0-RELEASE-p4 #0: Tue= Aug 24 07:33:27 UTC 2021=20=20=20=20 root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC= =20 amd64 --=20 You are receiving this mail because: You are the assignee for the bug.=