grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] fix an infinite loop with a corrupted pc partition table


From: Vladimir 'phcoder' Serbinenko
Subject: Re: [PATCH] fix an infinite loop with a corrupted pc partition table
Date: Fri, 24 Jul 2009 22:35:46 +0200

Hello
>> 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.
I already thought about this and spoke about it on IRC. Unfortunately
backward pointers do exist. I had it few years ago when I used
diskdrake. It put the logical partition at the end of the chain even
if partition itself was in the middle of the disk. I don't know if it
still has this behaviour but partition schemes have sometimes tendency
to stay a long time. I don't like they idea of user not being able to
boot his mandriva or some partitions not being accessible.
A big problem with pc partitions is that AFAIK there is no normative
standard for it, only descriptive documents
>
> 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
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
>



-- 
Regards
Vladimir 'phcoder' Serbinenko

Personal git repository: http://repo.or.cz/w/grub2/phcoder.git




reply via email to

[Prev in Thread] Current Thread [Next in Thread]