From: "Andries E. Brouwer" <Andries.Brouwer@cwi.nl>
To: Alexandr Kotov <kot@ya.ru>
Cc: Andries Brouwer <Andries.Brouwer@cwi.nl>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] partitions: Avoid recursion in extended partition scanning
Date: Wed, 4 Feb 2015 16:53:36 +0100 [thread overview]
Message-ID: <20150204155336.GA1797@jp> (raw)
In-Reply-To: <CADPRHm+tWJx-4ao46p-+Jm7KkeFhrKTBp9hr9cNcw+2zSKg-dQ@mail.gmail.com>
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 <kot@ya.ru>
> ---
> 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
parent reply other threads:[~2015-02-04 16:06 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CADPRHm+tWJx-4ao46p-+Jm7KkeFhrKTBp9hr9cNcw+2zSKg-dQ@mail.gmail.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150204155336.GA1797@jp \
--to=andries.brouwer@cwi.nl \
--cc=kot@ya.ru \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox