[Bug 258833] corrupt disk image can cause g_label_ntfs_taste to hang the kernel

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 01 Oct 2021 09:49:31 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258833

            Bug ID: 258833
           Summary: corrupt disk image can cause g_label_ntfs_taste to
                    hang the kernel
           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

Created attachment 228310
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=228310&action=edit
disk image that causes g_label_ntfs_taste to hang the kernel

The attached disk image causes g_label_ntfs_taste to freeze
my kernel. To see this:

% gunzip ntx1.img.gz
% sudo mdconfig -f ntx1.img

Or I can write ntx1.img to a USB memory stick with

% dd bs=512 if=ntx1.img of=/dev/da0 conv=sync

and it will hang my system as soon as I insert it. Here's what
I'm running:

FreeBSD xxx 13.0-RELEASE-p4 FreeBSD 13.0-RELEASE-p4 #0: Tue Aug 24 07:33:27 UTC
2021    
root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC 
amd64

The problem is that these lines in g_label_ntfs_taste() can
generate negative values if the disk content is bad, which
g_read_data() &c don't handle well:

    recsize = (mftrecsz > 0) ? (mftrecsz * bf->bf_bps * bf->bf_spc) : (1 <<
-mft

    voloff = bf->bf_mftcn * bf->bf_spc * bf->bf_bps +
        recsize * NTFS_VOLUMEINO;

-- 
You are receiving this mail because:
You are the assignee for the bug.