From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MUQsk-0001pG-QB for mharc-grub-devel@gnu.org; Fri, 24 Jul 2009 15:56:42 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MUQsj-0001oq-Pi for grub-devel@gnu.org; Fri, 24 Jul 2009 15:56:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MUQsf-0001mg-C2 for grub-devel@gnu.org; Fri, 24 Jul 2009 15:56:41 -0400 Received: from [199.232.76.173] (port=43158 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MUQse-0001mZ-Us for grub-devel@gnu.org; Fri, 24 Jul 2009 15:56:37 -0400 Received: from c60.cesmail.net ([216.154.195.49]:13181) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MUQse-0007I0-AQ for grub-devel@gnu.org; Fri, 24 Jul 2009 15:56:36 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 24 Jul 2009 15:56:34 -0400 Received: from [192.168.0.22] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id 80D5A34C6D for ; Fri, 24 Jul 2009 16:07:25 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 In-Reply-To: <1248454704.3510.67.camel@fz.local> References: <1248454704.3510.67.camel@fz.local> Content-Type: text/plain Date: Fri, 24 Jul 2009 15:56:32 -0400 Message-Id: <1248465392.6620.10.camel@mj> Mime-Version: 1.0 X-Mailer: Evolution 2.26.3 (2.26.3-1.fc11) Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [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 19:56:42 -0000 On Fri, 2009-07-24 at 18:58 +0200, Felix Zielcke wrote: > 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 That's so evil! > This patch fixes it, but probable there's a better fix. We could require that all references to extended partitions are only considered if they lead to a sector after the one currently being processed. Actually, no partition table should point to any partition (extended or not) in an earlier sector, but it's enough to exclude backward links between extended partitions to break the loop. ChangeLog: * partmap/pc.c (pc_partition_map_iterate): Only allow references to subsequent sectors in extended partition entries. --- partmap/pc.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/partmap/pc.c b/partmap/pc.c index 6f68ecf..cd119c0 100644 --- a/partmap/pc.c +++ b/partmap/pc.c @@ -208,7 +208,13 @@ pc_partition_map_iterate (grub_disk_t disk, if (grub_pc_partition_is_extended (e->type)) { - p.offset = pcdata.ext_offset + grub_le_to_cpu32 (e->start); + grub_disk_addr_t new_offset; + + /* Only allow references subsequent sectors */ + new_offset = pcdata.ext_offset + grub_le_to_cpu32 (e->start); + if (new_offset <= p.offset) + continue; + if (! pcdata.ext_offset) pcdata.ext_offset = p.offset; -- Regards, Pavel Roskin