From owner-freebsd-bugs@FreeBSD.ORG Fri Mar 8 13:40:02 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id C860A2A6 for ; Fri, 8 Mar 2013 13:40:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 9918A1A2 for ; Fri, 8 Mar 2013 13:40:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r28De27b063912 for ; Fri, 8 Mar 2013 13:40:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r28De2i6063911; Fri, 8 Mar 2013 13:40:02 GMT (envelope-from gnats) Resent-Date: Fri, 8 Mar 2013 13:40:02 GMT Resent-Message-Id: <201303081340.r28De2i6063911@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, Arrigo Marchiori Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 76F9DF6 for ; Fri, 8 Mar 2013 13:30:39 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 4D68E150 for ; Fri, 8 Mar 2013 13:30:39 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r28DUbi4077712 for ; Fri, 8 Mar 2013 13:30:37 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r28DUba1077711; Fri, 8 Mar 2013 13:30:37 GMT (envelope-from nobody) Message-Id: <201303081330.r28DUba1077711@red.freebsd.org> Date: Fri, 8 Mar 2013 13:30:37 GMT From: Arrigo Marchiori To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/176748: BTX Loader i386 incorrectly probes EDD, possibly resulting division by zero X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Mar 2013 13:40:02 -0000 >Number: 176748 >Category: kern >Synopsis: BTX Loader i386 incorrectly probes EDD, possibly resulting division by zero >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Mar 08 13:40:01 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Arrigo Marchiori >Release: 9-STABLE >Organization: >Environment: FreeBSD myhost 9.1-STABLE FreeBSD 9.1-STABLE #19 r247772: Mon Mar 4 10:47:30 CET 2013 root@myhost:/usr/obj/usr/src/sys/GENERIC i386 >Description: BTX probes for disk drives using interrupt 0x13. The "EDD" information is parsed incorrectly: the loader may incorrectly assume that the EDD information is present, and therefore overwrite the number of sectors and their size with incorrect values. The error is in file /usr/src/sys/boot/i386/libi386/biosdisk.c, inside function bd_int13probe(). The call to interrupt 0x13, AH=0x41 returns values in the bits of the CX register. The bit EDD_INTERFACE_EDD is not checked, while it should be. The effect on my configuration was that bd_int13probe() incorrectly assumed that EDD information was present; it requested for it with int 0x13, AH=0x48 and overwrote the number and size of sectors with invalid values (zero, in my case). This resulted in a zero by zero division in file /usr/src/sys/boot/i386/common/disk.c, function disk_open(). My setup had some buildworld/buildkernel tunings through src.conf(5). For instance, ZFS support was not compiled in. I believe such customization should not influence this particular problem. >How-To-Repeat: Find a system with a mass memory that does not provide EDD information. This problem was detected on a AMD Geode GX CPU, using a USB drive for boot. Please let me know if you need any more information about this. >Fix: The attached patch adds the check for the EDD_INTERFACE_EDD bit inside the data returned by the call to interrupt 0x13, AH=0x41. It solves the problem on my hardware configuration. Patch attached with submission follows: Index: biosdisk.c =================================================================== --- biosdisk.c (revisione 247767) +++ biosdisk.c (copia locale) @@ -231,7 +231,8 @@ v86int(); if (V86_CY(v86.efl) || /* carry set */ (v86.ebx & 0xffff) != 0xaa55 || /* signature */ - (v86.ecx & EDD_INTERFACE_FIXED_DISK) == 0) + (v86.ecx & EDD_INTERFACE_FIXED_DISK) == 0 || + (v86.ecx & EDD_INTERFACE_EDD) == 0) return (1); /* EDD supported */ bd->bd_flags |= BD_MODEEDD1; >Release-Note: >Audit-Trail: >Unformatted: