From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] disk: efi: correct the allocation size for mbr header in stack
Date: Fri, 17 Nov 2017 10:08:18 +0100 [thread overview]
Message-ID: <1510909699-27818-1-git-send-email-patrick.delaunay@st.com> (raw)
use ALLOC_CACHE_ALIGN_BUFFER_PAD for mbr header allocation
in stack to fix alloc issue in is_gpt_valid()
this patch fix also issue for GPT partition handling
with blocksize != 512 in set_protective_mbr()
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---
in is_gpt_valid(), the line before the patch:
ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz)
cause to an over-sized allocation in stack :
size = sizeof(legacy_mbr) * dev_desc->blksz + alignment
that crash with v2017.11 in my board SPL configuration
size > 512 * 512 = 256 kB
it is a regression introduced by commit
ff98cb90514d9b787ddc097c203ac8db2941efe1
part: extract MBR signature from partitions
disk/part_efi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/disk/part_efi.c b/disk/part_efi.c
index f6f5bee..bea8b20 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -350,7 +350,7 @@ static int part_test_efi(struct blk_desc *dev_desc)
static int set_protective_mbr(struct blk_desc *dev_desc)
{
/* Setup the Protective MBR */
- ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, p_mbr, 1);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, p_mbr, 1, dev_desc->blksz);
memset(p_mbr, 0, sizeof(*p_mbr));
if (p_mbr == NULL) {
@@ -931,7 +931,7 @@ static int is_gpt_valid(struct blk_desc *dev_desc, u64 lba,
return 0;
}
- ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, dev_desc->blksz);
+ ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, mbr, 1, dev_desc->blksz);
/* Read MBR Header from device */
if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) {
--
2.7.4
next reply other threads:[~2017-11-17 9:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 9:08 Patrick Delaunay [this message]
2017-11-30 15:35 ` [U-Boot] disk: efi: correct the allocation size for mbr header in stack Tom Rini
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=1510909699-27818-1-git-send-email-patrick.delaunay@st.com \
--to=patrick.delaunay@st.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox