[haiku-bugs] Re: [Haiku] #8990: intel partiton addon allows creating partitions > 2TB (easy)

  • From: "pdziepak" <trac@xxxxxxxxxxxx>
  • Date: Mon, 26 Jan 2015 11:13:33 -0000

#8990: intel partiton addon allows creating partitions > 2TB (easy)
------------------------------------------+----------------------------
   Reporter:  luroh                       |      Owner:  bonefish
       Type:  bug                         |     Status:  new
   Priority:  normal                      |  Milestone:  R1
  Component:  Partitioning Systems/Intel  |    Version:  R1/Development
 Resolution:                              |   Keywords:
 Blocked By:                              |   Blocking:
Has a Patch:  1                           |   Platform:  All
------------------------------------------+----------------------------

Comment (by pdziepak):

 Replying to [comment:8 kushalsingh007]:
 > 1.Using {{{partition->Size() / partition->BlockSize() < UINT32_MAX}}}
 causes the condition to fail.
 >   For instance, If BlockSize = 2048 ={{{2^11}}}.Then partition->Size() <
 {{{2^32}}}*{{{2^11}}} or {{{2^43}}} which is 8TB.
 > Thus clearly the condition fails. Also there can be overflow error using
 the previous    condition. Moreover the offset wasn't been checked
 anywhere.

 Well, I am getting a bit confused here. When reading the MBR add-on code I
 got the impression that `BlockSize()` is supposed to return the sector
 size (apparently the original author of the check in question assumed the
 same). In such case there is nothing wrong in the scenario you presented.
 2TB partition size limit applies only when sector size 512 because that
 limit originates from the 32 bit size of "partition size in sectors"
 value. If the sector size is 2kB nothing prevents MBR from supporting 8TB
 partitions. Have you actually seen `BlockSize()` returning something else
 than 512 on a disk with 512 byte sectors?

 >
 > 2.Yeah I assumed the sector size to be 512 , the max limit is
 {{{UINT32_MAX * SECTOR_SIZE}}}, but then since MBR assumes 512 bytes
 sectors , so I think that's fine.

 If I understand the MBR code correctly `BlockSize()` returns size of the
 sector. So the only change required is checking whether the offset is `<
 BlockSize() * UINT32_MAX`.

--
Ticket URL: <https://dev.haiku-os.org/ticket/8990#comment:12>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: