Skip to contentSkip to conversation

fix sun partition overflow over 1T

PATCH Applied Eric Sandeen 3 participants 3 messages Aug 4, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix sun partition overflow over 1T

Although sun partition labels aren't supposed to support > 1T, apparently linux partition editors will allow up to 2T. This can cause problems in the kernel when these larger partitions are read, due to a signed int container.

num_sectors in the sun_disklabel struct is marked as __u32 in 2.4, and as __be32 in 2.6. However, this is assigned to a signed int in sun_partition():

               int num_sectors;

               st_sector = be32_to_cpu(p->start_cylinder) * spc;
               num_sectors = be32_to_cpu(p->num_sectors);

Changing num_sectors to an unsigned int avoids this problem.

Thanks,

-Eric

fs/partitions/sun.c +0 -0
Index: linux-2.6.17/fs/partitions/sun.c
===================================================================
@@ -74,7 +74,7 @@ int sun_partition(struct parsed_partitio
	spc = be16_to_cpu(label->ntrks) * be16_to_cpu(label->nsect);
	for (i = 0; i < 8; i++, p++) {
		unsigned long st_sector;

- int num_sectors;
+ unsigned int num_sectors;

		st_sector = be32_to_cpu(p->start_cylinder) * spc;
		num_sectors = be32_to_cpu(p->num_sectors);
Acked-by on v1 1/1
#1 lore raw

Ar Gwe, 2006-08-04 am 11:22 -0500, ysgrifennodd Eric Sandeen:

Quoted 14 lines

Although sun partition labels aren't supposed to support > 1T, apparently linux partition editors will allow up to 2T. This can cause problems in the kernel when these larger partitions are read, due to a signed int container.

num_sectors in the sun_disklabel struct is marked as __u32 in 2.4, and as __be32 in 2.6. However, this is assigned to a signed int in sun_partition():

                int num_sectors;

                st_sector = be32_to_cpu(p->start_cylinder) * spc;
                num_sectors = be32_to_cpu(p->num_sectors);
Quoted 4 lines

Changing num_sectors to an unsigned int avoids this problem.

Applied
#2 lore raw

From: Alan Cox <[email protected]>
Date: Fri, 04 Aug 2006 17:56:30 +0100

Quoted 15 lines

Ar Gwe, 2006-08-04 am 11:22 -0500, ysgrifennodd Eric Sandeen:

Quoted 14 lines

Although sun partition labels aren't supposed to support > 1T, apparently linux partition editors will allow up to 2T. This can cause problems in the kernel when these larger partitions are read, due to a signed int container.

num_sectors in the sun_disklabel struct is marked as __u32 in 2.4, and as __be32 in 2.6. However, this is assigned to a signed int in sun_partition():

                int num_sectors;

                st_sector = be32_to_cpu(p->start_cylinder) * spc;
                num_sectors = be32_to_cpu(p->num_sectors);
Quoted 6 lines
Quoted 4 lines

Changing num_sectors to an unsigned int avoids this problem.

Applied, thanks a lot.