From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JMtxE-0001Sa-2t for mharc-grub-devel@gnu.org; Wed, 06 Feb 2008 18:45:24 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JMtxB-0001Qn-Rn for grub-devel@gnu.org; Wed, 06 Feb 2008 18:45:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JMtxA-0001PE-Ev for grub-devel@gnu.org; Wed, 06 Feb 2008 18:45:21 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JMtxA-0001P3-4a for grub-devel@gnu.org; Wed, 06 Feb 2008 18:45:20 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JMtx9-0002i9-Nl for grub-devel@gnu.org; Wed, 06 Feb 2008 18:45:19 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JMtwy-00039F-73; Thu, 07 Feb 2008 00:45:12 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JMtv2-0006mZ-Ex; Thu, 07 Feb 2008 00:43:08 +0100 Date: Thu, 7 Feb 2008 00:43:08 +0100 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080206234308.GA25944@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" 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. Cc: Jeroen Dekkers Subject: [PATCH] sanity checks for RAID 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, 06 Feb 2008 23:45:22 -0000 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit A pair of sanity checks for RAID. Jeroen, I'd appreciate if you could have a quick look. The second case I haven't run into, but the first I have (in a single-disk RAID0 I setup for testing). I wonder if I'm fixing the symptoms of a bug rather than the bug, but I really don't see what could be wrong in our superblock read routine, plus even if there's a bug somewhere else this check makes sense to me as a general safeguard. -- Robert Millan I know my rights; I want my phone call! What use is a phone call… if you are unable to speak? (as seen on /.) --3V7upXqbjpZ4EhLz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="sanity_checks.diff" diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/disk/raid.c ./disk/raid.c --- ../grub2/disk/raid.c 2007-12-30 09:52:03.000000000 +0100 +++ ./disk/raid.c 2008-02-06 23:22:46.000000000 +0100 @@ -493,6 +493,28 @@ grub_raid_scan_device (const char *name) /* Add the device to the array. */ array->device[sb.this_disk.number].name = grub_strdup (name); array->device[sb.this_disk.number].disk = grub_disk_open (name); + + if (array->disk_size != array->device[sb.this_disk.number]->total_sectors) + { + if (array->total_devs == 1) + { + grub_dprintf ("raid", "Array contains only one disk, but its size (0x%llx) " + "doesn't match with size indicated by superblock (0x%llx). " + "Assuming superblock is wrong.\n", + array->device[sb.this_disk.number]->total_sectors, array->disk_size); + array->disk_size = array->device[sb.this_disk.number]->total_sectors; + } + else if (array->level == 1) + { + grub_dprintf ("raid", "Array is RAID level 1, but the size of disk %d (0x%llx) " + "doesn't match with size indicated by superblock (0x%llx). " + "Assuming superblock is wrong.\n", + sb.this_disk.number, + array->device[sb.this_disk.number]->total_sectors, array->disk_size); + array->disk_size = array->device[sb.this_disk.number]->total_sectors; + } + } + if (! array->device[sb.this_disk.number].name || ! array->device[sb.this_disk.number].disk) --3V7upXqbjpZ4EhLz--