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

  • From: "pdziepak" <trac@xxxxxxxxxxxx>
  • Date: Mon, 26 Jan 2015 11:49:58 -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:13 kushalsingh007]:
 > Replying to [comment:12 pdziepak]:
 > >
 > > > 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?
 >
 > Yes , while testing I found the blocksize to be 2048 when sector size
 was 512. It depends on the value that has been initialized by you.

 What is this "block size" then? The only "blocks" at this abstraction
 level are 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`.
 > >
 > But then again BlockSize() returns the size of the block (512/2048/4096
 etc) not the size of the sector. Had it returned the size of the sector ,
 your assumption would have been true.

 Commit 5f1b31debdf97da331be6e97a6c2bc5899e2423a suggests that my
 assumption is indeed true and `BlockSize()` should always return the size
 of a sector. If it doesn't then we probably have another bug.

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

Other related posts: