Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966740AbbBDQGa (ORCPT ); Wed, 4 Feb 2015 11:06:30 -0500 Received: from fester.cwi.nl ([192.16.191.27]:33651 "EHLO fester.cwi.nl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965247AbbBDQG2 (ORCPT ); Wed, 4 Feb 2015 11:06:28 -0500 X-Greylist: delayed 769 seconds by postgrey-1.27 at vger.kernel.org; Wed, 04 Feb 2015 11:06:28 EST Date: Wed, 4 Feb 2015 16:53:36 +0100 From: "Andries E. Brouwer" To: Alexandr Kotov Cc: Andries Brouwer , linux-kernel@vger.kernel.org Subject: Re: [PATCH] partitions: Avoid recursion in extended partition scanning Message-ID: <20150204155336.GA1797@jp> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2018 Lines: 52 On Wed, Feb 04, 2015 at 06:24:36PM +0400, Alexandr Kotov wrote: > If externded partition record points to itself there will be recursion in > partition scanning > until we reach partition limit of 255 per disk. > There is no big deal to have so many partition, but then udev takes place > in handing this things > it may run out off memory, especialy on systems with 1G and lower RAM on > board. So you could neither boot with such disk inside nor erase it. > I reported such error for Arch Linux some time ago > https://bugs.archlinux.org/task/36532 > At the link above there is steps to reproduce bug. > > Signed-off-by: Alexandr Kotov > --- > block/partitions/msdos.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/block/partitions/msdos.c b/block/partitions/msdos.c > index 93e7c1b..3f03768 100644 > --- a/block/partitions/msdos.c > +++ b/block/partitions/msdos.c > @@ -196,7 +196,8 @@ static void parse_extended(struct parsed_partitions > *state, > */ > p -= 4; > for (i = 0; i < 4; i++, p++) > - if (nr_sects(p) && is_extended_partition(p)) > + if (nr_sects(p) && is_extended_partition(p) > + && start_sect(p) != 0) > break; > if (i == 4) > goto done; /* nothing left to do */ > -- > 2.1.0 Yes, one might do that. This cannot be very urgent since this code is twenty years old. This patch does not necessarily help, since there are more ways recursion might happen. Perhaps it would be better to settle this potential problem completely. For example, ignore partitions that are known already (in the "process data partitions" part), and let the loop terminate via the loopct test that is already there. Andries -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/