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

2009-09-11 Thread Pavel Roskin
On Sun, 2009-08-23 at 17:40 +0200, Vladimir 'phcoder' Serbinenko wrote: > > I would prefer something simpler, but if that's not possible, this is better > > than hardcoding a number IMO. > > > > Unless Pavel has any objection, I think it's ok. > Any problems with this one? No objections. -- Rega

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

2009-08-28 Thread Vladimir 'phcoder' Serbinenko
Ping? On Sun, Aug 23, 2009 at 5:40 PM, Vladimir 'phcoder' Serbinenko wrote: > On Tue, Jul 28, 2009 at 7:55 PM, Robert Millan wrote: >> On Sun, Jul 26, 2009 at 12:58:59AM +0200, Vladimir 'phcoder' Serbinenko >> wrote: >>> +      /* This is our loop-detection algorithm. It works the following way:

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

2009-08-23 Thread Vladimir 'phcoder' Serbinenko
On Tue, Jul 28, 2009 at 7:55 PM, Robert Millan wrote: > On Sun, Jul 26, 2009 at 12:58:59AM +0200, Vladimir 'phcoder' Serbinenko wrote: >> +      /* This is our loop-detection algorithm. It works the following way: >> +      It saves last position which was a power of two. Then it compares the >> +

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

2009-07-28 Thread Robert Millan
On Sun, Jul 26, 2009 at 12:58:59AM +0200, Vladimir 'phcoder' Serbinenko wrote: > + /* This is our loop-detection algorithm. It works the following way: > + It saves last position which was a power of two. Then it compares the > + saved value with a current one. This way it's guarante

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

2009-07-25 Thread Felix Zielcke
Am Sonntag, den 26.07.2009, 01:20 +0200 schrieb Vladimir 'phcoder' Serbinenko: > On Sun, Jul 26, 2009 at 12:58 AM, Vladimir 'phcoder' > Serbinenko wrote: > > On Sun, Jul 26, 2009 at 12:35 AM, Vladimir 'phcoder' > > Serbinenko wrote: > >>> Links backwards between extended partition entries are more

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

2009-07-25 Thread Vladimir 'phcoder' Serbinenko
On Sun, Jul 26, 2009 at 12:58 AM, Vladimir 'phcoder' Serbinenko wrote: > On Sun, Jul 26, 2009 at 12:35 AM, Vladimir 'phcoder' > Serbinenko wrote: >>> Links backwards between extended partition entries are more likely to be >>> due to data corruption than due to buggy partitoning tools.  OK, if you

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

2009-07-25 Thread Vladimir 'phcoder' Serbinenko
On Sun, Jul 26, 2009 at 12:35 AM, Vladimir 'phcoder' Serbinenko wrote: >> 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

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

2009-07-25 Thread Vladimir 'phcoder' Serbinenko
> 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 remembered a compact algorithm for detecting loops of such kind I will impl

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

2009-07-25 Thread Pavel Roskin
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 < 10) > >> [...] > >> + if (loop == 10) > >> +return

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

2009-07-25 Thread Vladimir 'phcoder' Serbinenko
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 < 10) >> [...] >> +  if (loop == 10) >> +    return grub_error (GRUB_ERR_BAD_PART_TABLE, "Corrupted partition table >> found."); > > What

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

2009-07-25 Thread Robert Millan
On Fri, Jul 24, 2009 at 09:24:31PM +0200, Felix Zielcke wrote: > + loop = 0; > + while (loop < 10) > [...] > + if (loop == 10) > +return grub_error (GRUB_ERR_BAD_PART_TABLE, "Corrupted partition table > found."); What does this 10 represent? It looks like heuristic, but I'm mi

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

2009-07-25 Thread Vladimir 'phcoder' Serbinenko
On Fri, Jul 24, 2009 at 11:03 PM, Pavel Roskin wrote: > On Fri, 2009-07-24 at 22:35 +0200, Vladimir 'phcoder' Serbinenko wrote: > This is still allowed: > > MBR  >  Ext >        Logical  <-/ AFAIK this isn't even possible since e->start is unsigned and references to logical par

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

2009-07-24 Thread Pavel Roskin
On Fri, 2009-07-24 at 22:35 +0200, Vladimir 'phcoder' Serbinenko wrote: > 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 > > process

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

2009-07-24 Thread Vladimir 'phcoder' Serbinenko
>> Here's a new one after comments from Vladimir on IRC >> loop count is increased to 100'000 and partitions with a starting sector >> of 0 are ignored. > > I don't see why it's better.  Do you think the links backwards should be > allowed? I think yes since breaking some configuration will be seen

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

2009-07-24 Thread Vladimir 'phcoder' Serbinenko
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 p

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

2009-07-24 Thread Pavel Roskin
On Fri, 2009-07-24 at 21:24 +0200, Felix Zielcke wrote: > Here's a new one after comments from Vladimir on IRC > loop count is increased to 100'000 and partitions with a starting sector > of 0 are ignored. I don't see why it's better. Do you think the links backwards should be allowed? -- Rega

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

2009-07-24 Thread Pavel Roskin
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 t

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

2009-07-24 Thread Felix Zielcke
Am Freitag, den 24.07.2009, 18:58 +0200 schrieb Felix Zielcke: > > > 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 > partmap/pc.c:142: partition 1: flag 0x0,

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

2009-07-24 Thread Felix Zielcke
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 partmap/pc.c:142: partition 1: flag 0x0, type 0x0, start 0x0, len 0x0 partmap/pc.c:142: partition 2: flag 0x0, type 0x0,