From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MUO5a-00043c-En for mharc-grub-devel@gnu.org; Fri, 24 Jul 2009 12:57:46 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MUO5Y-00041s-LT for grub-devel@gnu.org; Fri, 24 Jul 2009 12:57:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MUO5T-0003ym-HK for grub-devel@gnu.org; Fri, 24 Jul 2009 12:57:43 -0400 Received: from [199.232.76.173] (port=38637 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MUO5T-0003yf-Cz for grub-devel@gnu.org; Fri, 24 Jul 2009 12:57:39 -0400 Received: from moutng.kundenserver.de ([212.227.17.10]:49878) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MUO5S-0007B8-Qe for grub-devel@gnu.org; Fri, 24 Jul 2009 12:57:39 -0400 Received: from [85.180.4.132] (e180004132.adsl.alicedsl.de [85.180.4.132]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0MKt72-1MUO5R03fr-000A2a; Fri, 24 Jul 2009 18:57:37 +0200 From: Felix Zielcke To: The development of GRUB 2 Content-Type: multipart/mixed; boundary="=-tS0MebXx5oOH9zCf/tn0" Date: Fri, 24 Jul 2009 18:58:24 +0200 Message-Id: <1248454704.3510.67.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.27.4 X-Provags-ID: V01U2FsdGVkX187VUZkaU9kZs5/YTgI2naQXoIPK4Qa4pQ+hx+ UXodEOQmdGoQQBJd9pK6cIsvepkQIsJ6N9jbl+DxUn2crwEE8o 0Xk6Fy3yXcDkn+jWkmYGj++RkKZU2Pe X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] fix an infinite loop with a corrupted pc partition table 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: Fri, 24 Jul 2009 16:57:44 -0000 --=-tS0MebXx5oOH9zCf/tn0 Content-Type: text/plain Content-Transfer-Encoding: 7bit With this [0] partition table grub-probe currently loops forever: kern/disk.c:389: Reading `hd1'... partmap/pc.c:142: partition 0: flag 0x0, type 0x5, start 0x0, len 0x11177330 partmap/pc.c:142: partition 1: flag 0x0, type 0x0, start 0x0, len 0x0 partmap/pc.c:142: partition 2: flag 0x0, type 0x0, start 0x0, len 0x0 partmap/pc.c:142: partition 3: flag 0x0, type 0x0, start 0x0, len 0x0 kern/disk.c:389: Reading `hd1'... partmap/pc.c:142: partition 0: flag 0x0, type 0x5, start 0x0, len 0x11177330 partmap/pc.c:142: partition 1: flag 0x0, type 0x0, start 0x0, len 0x0 partmap/pc.c:142: partition 2: flag 0x0, type 0x0, start 0x0, len 0x0 partmap/pc.c:142: partition 3: flag 0x0, type 0x0, start 0x0, len 0x0 [...] This patch fixes it, but probable there's a better fix. [0] http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=corrupt-table.dat;att=1;bug=519223 -- Felix Zielcke --=-tS0MebXx5oOH9zCf/tn0 Content-Disposition: attachment; filename="corrupted_partmap.diff" Content-Type: text/x-patch; name="corrupted_partmap.diff"; charset="UTF-8" Content-Transfer-Encoding: 7bit 2009-07-24 Felix Zielcke * partmap/pc.c (pc_partition_map_iterate): Don't loop forever in case the partition table is corrupted. diff --git a/partmap/pc.c b/partmap/pc.c index 6f68ecf..0271311 100644 --- a/partmap/pc.c +++ b/partmap/pc.c @@ -97,6 +97,7 @@ pc_partition_map_iterate (grub_disk_t disk, struct grub_pc_partition_mbr mbr; struct grub_pc_partition_disk_label label; struct grub_disk raw; + int loop; /* Enforce raw disk access. */ raw = *disk; @@ -108,11 +109,13 @@ pc_partition_map_iterate (grub_disk_t disk, p.data = &pcdata; p.partmap = &grub_pc_partition_map; - while (1) + loop = 0; + while (loop < 100) { int i; struct grub_pc_partition_entry *e; + loop++; /* Read the MBR. */ if (grub_disk_read (&raw, p.offset, 0, sizeof (mbr), &mbr)) goto finish; @@ -221,6 +224,9 @@ pc_partition_map_iterate (grub_disk_t disk, break; } + if (loop == 100) + return grub_error (GRUB_ERR_BAD_PART_TABLE, "Corrupted partition table found."); + finish: return grub_errno; } --=-tS0MebXx5oOH9zCf/tn0--