Skip to contentSkip to conversation

disk: part_dos: Allocate at least one block size for mbr

PATCH New Faiz Abbas 3 participants 3 messages Sep 4, 2019 – Sep 20, 2019

lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

PATCH 1/1 disk: part_dos: Allocate at least one block size for mbr

The blk_dread() following the mbr allocation reads one block from the device. This will lead to overflow if block size is greater than the size of legacy_mbr. Fix this by allocating at least one block size.

---
 disk/part_dos.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
disk/part_dos.c +2 -1
index aae9d95906..8ddc13b50c 100644
@@ -93,7 +93,8 @@ static int test_block_type(unsigned char *buffer)
 static int part_test_dos(struct blk_desc *dev_desc)
 {
 #ifndef CONFIG_SPL_BUILD
-	ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, 1);
+	ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr,
+			DIV_ROUND_UP(dev_desc->blksz, sizeof(legacy_mbr)));
 
 	if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1)
 		return -1;
Signature · 1 line
2.19.2
#1 lore raw

PATCH 1/1 disk: part_dos: Allocate at least one block size for mbr

Hi Faiz,

Quoted 8 lines

-----Original Message-----
From: Faiz Abbas <[email protected]>
Sent: Wednesday, September 4, 2019 5:40 PM
To: u-boot at lists.denx.de
Cc: trini at konsulko.com; Alexey Brodkin <[email protected]>; paulemge at forallsecure.com; faiz_abbas at ti.com
Subject: [PATCH] disk: part_dos: Allocate at least one block size for mbr

Quoted 5 lines

The blk_dread() following the mbr allocation reads one block from the device. This will lead to overflow if block size is greater than the size of legacy_mbr. Fix this by allocating at least one block size.

#2 lore raw

PATCH 1/1 disk: part_dos: Allocate at least one block size for mbr

In reply to Faiz Abbas
Quoted 6 lines · Faiz Abbas

The blk_dread() following the mbr allocation reads one block from the device. This will lead to overflow if block size is greater than the size of legacy_mbr. Fix this by allocating at least one block size.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190920/d8eb3a7c/attachment.sig>