All of lore.kernel.org
 help / color / mirror / Atom feed
From: Faiz Abbas <faiz_abbas@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
Date: Wed, 4 Sep 2019 17:13:36 +0530	[thread overview]
Message-ID: <554e1bc3-f6a1-a0cc-c724-16d00b249b70@ti.com> (raw)
In-Reply-To: <CY4PR1201MB01208F1A32626730B089B193A1B80@CY4PR1201MB0120.namprd12.prod.outlook.com>

Hi Alexey,

On 04/09/19 3:42 PM, Alexey Brodkin wrote:
> Hi Faiz,
> 
>> -----Original Message-----
>> From: Faiz Abbas <faiz_abbas@ti.com>
>> Sent: Wednesday, September 4, 2019 12:22 PM
>> To: u-boot at lists.denx.de
>> Cc: paulemge at forallsecure.com; faiz_abbas at ti.com; Alexey Brodkin <abrodkin@synopsys.com>;
>> trini at konsulko.com
>> Subject: [PATCH] Revert "part: Allocate only one legacy_mbr buffer"
>>
>> This reverts commit 8639e34d2c5e12cc2e45c95b1a2e97c22bf6a711.
>>
>> The blk_dread() call following the allocation will read one block from
>> the device. This will lead to overflow if the blocksize is greater than
>> the size of legacy_mbr. Fix this by allocating one block size.
> 
> Did you read justification of my change that you're reverting now?
> With your change in place we'll allocate a buffer
> of size = (sizeof(legacy_mbr) * dev_desc->blksz).
> 
> Is that something you really want?

Oops. You're right. I thought your patch was changing buffer size from
blksz to legacy_mbr.

> 
> I guess what you really want to do is to allocate buffer for "mbr"
> dynamically of size which is max(sizeof(legacy_mbr), dev_desc->blksz).
>

With the assumption that blksz is always greater than
sizeof(legacy_mbr), this should work:

ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, DIV_ROUND_UP(dev_desc->blksz,
sizeof(legacy_mbr)));

Will send a proper fix.

Thanks,
Faiz

  reply	other threads:[~2019-09-04 11:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04  9:22 [U-Boot] [PATCH] Revert "part: Allocate only one legacy_mbr buffer" Faiz Abbas
2019-09-04 10:12 ` Alexey Brodkin
2019-09-04 11:43   ` Faiz Abbas [this message]
2019-09-04 11:46     ` Alexey Brodkin
2019-09-04 12:49       ` Faiz Abbas
2019-09-04 12:57         ` Alexey Brodkin
2019-09-04 13:09           ` Faiz Abbas
2019-09-04 13:23             ` Alexey Brodkin
2019-09-04 13:46               ` Alexey Brodkin
2019-09-04 13:49                 ` Tom Rini
2019-09-04 14:07                   ` Faiz Abbas
2019-09-04 14:08               ` Faiz Abbas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=554e1bc3-f6a1-a0cc-c724-16d00b249b70@ti.com \
    --to=faiz_abbas@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.