diff mbox series

[U-Boot,v2,3/5] disk: efi: correct the overlap check on GPT header and PTE

Message ID 1508170655-17707-4-git-send-email-patrick.delaunay@st.com
State Superseded
Delegated to: Tom Rini
Headers show
Series solve issues in gpt management | expand

Commit Message

Patrick DELAUNAY Oct. 16, 2017, 4:17 p.m. UTC
the partition starting at 0x4400 is refused with overlap error:
  $> gpt write mmc 0 "name=test,start=0x4400,size=0"
  Writing GPT: Partition overlap
  error!

even if the 0x4400 is the first available offset for LBA35 with default
value:
- MBR=LBA1
- GPT header=LBA2
- PTE= 32 LBAs (128 entry), 3 to 34

And the command to have one partition for all the disk failed also :
  $> gpt write mmc 0 "name=test,size=0"

After the patch :

  $> gpt write mmc 0 "name=test,size=0"
  Writing GPT: success!
  $> part list mmc 0

  Partition Map for MMC device 0  --   Partition Type: EFI

  Part	Start LBA	End LBA		Name
	Attributes
	Type GUID
	Partition GUID
  1	0x00000022	0x01ce9fde	"test"
	attrs:	0x0000000000000000
	type:	ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
	type:	data
	guid:	b4b84b8a-04e3-4000-0036-aff5c9c495b1

And 0x22 = 34 LBA => offset = 0x4400 is accepted as expected

Reviewed-by: Łukasz Majewski <lukma@denx.de>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
gpt test are now OK
./test/py/test.py -k gpt --build

test/py/tests/test_gpt.py .......
=> 7 passed, 228 deselected in 1.11 seconds

Changes in v2: None

 disk/part_efi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Glass Oct. 22, 2017, 2:34 p.m. UTC | #1
On 16 October 2017 at 18:17, Patrick Delaunay <patrick.delaunay@st.com> wrote:
> the partition starting at 0x4400 is refused with overlap error:
>   $> gpt write mmc 0 "name=test,start=0x4400,size=0"
>   Writing GPT: Partition overlap
>   error!
>
> even if the 0x4400 is the first available offset for LBA35 with default
> value:
> - MBR=LBA1
> - GPT header=LBA2
> - PTE= 32 LBAs (128 entry), 3 to 34
>
> And the command to have one partition for all the disk failed also :
>   $> gpt write mmc 0 "name=test,size=0"
>
> After the patch :
>
>   $> gpt write mmc 0 "name=test,size=0"
>   Writing GPT: success!
>   $> part list mmc 0
>
>   Partition Map for MMC device 0  --   Partition Type: EFI
>
>   Part  Start LBA       End LBA         Name
>         Attributes
>         Type GUID
>         Partition GUID
>   1     0x00000022      0x01ce9fde      "test"
>         attrs:  0x0000000000000000
>         type:   ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
>         type:   data
>         guid:   b4b84b8a-04e3-4000-0036-aff5c9c495b1
>
> And 0x22 = 34 LBA => offset = 0x4400 is accepted as expected
>
> Reviewed-by: Łukasz Majewski <lukma@denx.de>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
> ---
> gpt test are now OK
> ./test/py/test.py -k gpt --build
>
> test/py/tests/test_gpt.py .......
> => 7 passed, 228 deselected in 1.11 seconds
>
> Changes in v2: None
>
>  disk/part_efi.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 0abf487..2992d9e 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -469,8 +469,8 @@  int gpt_fill_pte(struct blk_desc *dev_desc,
 		 * If our partition overlaps with either the GPT
 		 * header, or the partition entry, reject it.
 		 */
-		if (((start <= hdr_end && hdr_start <= (start + size)) ||
-		     (start <= pte_end && pte_start <= (start + size)))) {
+		if (((start < hdr_end && hdr_start < (start + size)) ||
+		     (start < pte_end && pte_start < (start + size)))) {
 			printf("Partition overlap\n");
 			return -1;
 		}