From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MUpNq-0003BK-RQ for mharc-grub-devel@gnu.org; Sat, 25 Jul 2009 18:06:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MUpNo-00039n-QK for grub-devel@gnu.org; Sat, 25 Jul 2009 18:06:24 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MUpNj-00035P-MY for grub-devel@gnu.org; Sat, 25 Jul 2009 18:06:23 -0400 Received: from [199.232.76.173] (port=57197 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MUpNj-00035C-II for grub-devel@gnu.org; Sat, 25 Jul 2009 18:06:19 -0400 Received: from c60.cesmail.net ([216.154.195.49]:3345) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MUpNi-0007bU-Uj for grub-devel@gnu.org; Sat, 25 Jul 2009 18:06:19 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 25 Jul 2009 18:06:17 -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 C554834C6D for ; Sat, 25 Jul 2009 18:17:18 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 In-Reply-To: References: <1248454704.3510.67.camel@fz.local> <1248463471.3510.77.camel@fz.local> <20090725163636.GL12326@thorin> Content-Type: text/plain Date: Sat, 25 Jul 2009 18:06:16 -0400 Message-Id: <1248559576.11389.33.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: Sat, 25 Jul 2009 22:06:25 -0000 On Sat, 2009-07-25 at 18:56 +0200, Vladimir 'phcoder' Serbinenko wrote: > On Sat, Jul 25, 2009 at 6:36 PM, Robert Millan wrote: > > On Fri, Jul 24, 2009 at 09:24:31PM +0200, Felix Zielcke wrote: > >> + loop = 0; > >> + while (loop < 100000) > >> [...] > >> + if (loop == 100000) > >> + return grub_error (GRUB_ERR_BAD_PART_TABLE, "Corrupted partition table found."); > > > > What does this 100000 represent? It looks like heuristic, but I'm missing > > some context (I'm not familiar with extended partition layout). > It is a heuristic.It's a number bigger than highest number of "sane" > partitions but an amount of iteration which a computer can handle > easily. > I know that it's an arbitrary limit butusing a correct algorithm (e.g. > record all visited extended partitions offsets) would take place > almost uselessly and other solutions risk to have other problems (as > "invisible" partitions) Let's try to see the complete picture. By the time we get 100000 partitions we are already in trouble, especially if running ls on a slow terminal. Reaching 100000 means we were wrong all along. Links backwards between extended partition entries are more likely to be due to data corruption than due to buggy partitoning tools. OK, if you want, let's support up to 10 backward links. That's more than enough. I would hate to get caught in another discussion about minor issues when we have a real problem in that code. GRUB only follows a single chain of extended partitions rather than a tree of links. I think the whole point in having the Linux extended partition type is to allow it to coexist with an MS-DOS extended partition. That's a realistic scenario, unlike backward links. -- Regards, Pavel Roskin