From: Abdelrahman Youssef <abdelrahmanyossef12@gmail.com>
To: s.hauer@pengutronix.de
Cc: barebox@lists.infradead.org,
Abdelrahman Youssef <abdelrahmanyossef12@gmail.com>
Subject: [PATCH] partitions: efi: fix GPT header size exceeding allocation size
Date: Tue, 22 Oct 2024 19:27:26 +0300 [thread overview]
Message-ID: <20241022162726.166093-1-abdelrahmanyossef12@gmail.com> (raw)
The buffer gets allocated with the block device of size SECTOR_SIZE, but an
ill-formed GPT header_size may exceed it resulting in heap-overflow.
Signed-off-by: Abdelrahman Youssef <abdelrahmanyossef12@gmail.com>
---
common/partitions/efi.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/common/partitions/efi.c b/common/partitions/efi.c
index 829360da6e..9a04b7014d 100644
--- a/common/partitions/efi.c
+++ b/common/partitions/efi.c
@@ -173,6 +173,9 @@ static int is_gpt_valid(struct block_device *blk, u64 lba,
goto fail;
}
+ if (le32_to_cpu((*gpt)->header_size) > bdev_logical_block_size(blk))
+ goto fail;
+
/* Check the GUID Partition Table CRC */
origcrc = le32_to_cpu((*gpt)->header_crc32);
(*gpt)->header_crc32 = 0;
--
2.43.0
next reply other threads:[~2024-10-22 16:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-22 16:27 Abdelrahman Youssef [this message]
2024-10-22 17:06 ` Ahmad Fatoum
2024-10-23 12:43 ` Sascha Hauer
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=20241022162726.166093-1-abdelrahmanyossef12@gmail.com \
--to=abdelrahmanyossef12@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.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