From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1K42WN-000089-E1 for mharc-grub-devel@gnu.org; Wed, 04 Jun 2008 19:35:59 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K42WM-000084-2x for grub-devel@gnu.org; Wed, 04 Jun 2008 19:35:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K42WK-00007s-J1 for grub-devel@gnu.org; Wed, 04 Jun 2008 19:35:57 -0400 Received: from [199.232.76.173] (port=58728 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K42WK-00007p-Cz for grub-devel@gnu.org; Wed, 04 Jun 2008 19:35:56 -0400 Received: from aybabtu.com ([69.60.117.155]:57527) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K42WK-0006iq-3D for grub-devel@gnu.org; Wed, 04 Jun 2008 19:35:56 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1K42VH-0002S6-Rj for grub-devel@gnu.org; Thu, 05 Jun 2008 01:34:52 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1K42W0-0005gK-Ns for grub-devel@gnu.org; Thu, 05 Jun 2008 01:35:36 +0200 Date: Thu, 5 Jun 2008 01:35:36 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080604233536.GA21711@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tKW2IUtsqtDRztdT" Content-Disposition: inline Content-Transfer-Encoding: 8bit Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] biosdisk / open_device() messing up offsets X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jun 2008 23:35:58 -0000 --tKW2IUtsqtDRztdT Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit It seems that open_device() in biosdisk is messing up offsets when accessing partitions. For example if you try: grub> hexdump (hd0,1) in grub-emu, you'll get a message saying lseek failed. The problem is that it substracts to the sector offset, so all accesses get to wrong data and accessing sector 0 results in underflow. I would think those lines (see patch) are plainly wrong, but they appear to be very old, and it is strange that this wasn't noticed earlier. Maybe we have changed behaviour around partition/disk offsets, causing this breakage without noticing? -- Robert Millan I know my rights; I want my phone call! What good is a phone call… if you are unable to speak? (as seen on /.) --tKW2IUtsqtDRztdT Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="partition.diff" diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/util/biosdisk.c ./util/biosdisk.c --- ../grub2/util/biosdisk.c 2008-06-04 16:00:30.000000000 +0200 +++ ./util/biosdisk.c 2008-06-05 01:17:00.000000000 +0200 @@ -298,9 +298,6 @@ open_device (const grub_disk_t disk, gru /* Make the buffer cache consistent with the physical disk. */ ioctl (fd, BLKFLSBUF, 0); - - if (is_partition) - sector -= disk->partition->start; } #else /* ! __linux__ */ fd = open (map[disk->id].device, flags); --tKW2IUtsqtDRztdT--