d10d6fb187
Porting patches from grub2_2.06-3~deb11u4 to fix CVE-2022-2601/CVE-2022-3775. The source code of grub2_2.06-3~deb11u4 is from: https://snapshot.debian.org/archive/debian/20221124T030451Z/ pool/main/g/grub2/grub2_2.06-3~deb11u4.debian.tar.xz Refer to above source code and this link for the fix: https://lists.gnu.org/archive/html/grub-devel/2022-11/msg00059.html The 1st patch in the list is for making proper context for the 14 patches of the 2 CVEs. No content changes for all the patches from debian release. We do this because grub2/grub-efi is ported from wrlinux for secure boot bringing up. Test plan: - PASS: build grub2/grub-efi. - PASS: build-image and install and boot up on lab/qemu. - PASS: check that the "stx.N" version number is right for both bios(grub2 ver) and uefi(grub-efi ver) boot. Closes-bug: 2020730 Signed-off-by: Li Zhou <li.zhou@windriver.com> Change-Id: Ia6c58a2021a786ef92f760b3cfe035fbccedacf7
56 lines
2.0 KiB
Diff
56 lines
2.0 KiB
Diff
From da90d62316a3b105d2fbd7334d6521936bd6dcf6 Mon Sep 17 00:00:00 2001
|
|
From: Zhang Boyang <zhangboyang.id@gmail.com>
|
|
Date: Fri, 28 Oct 2022 21:31:39 +0800
|
|
Subject: [PATCH 14/14] normal/charset: Fix an integer overflow in
|
|
grub_unicode_aglomerate_comb()
|
|
|
|
The out->ncomb is a bit-field of 8 bits. So, the max possible value is 255.
|
|
However, code in grub_unicode_aglomerate_comb() doesn't check for an
|
|
overflow when incrementing out->ncomb. If out->ncomb is already 255,
|
|
after incrementing it will get 0 instead of 256, and cause illegal
|
|
memory access in subsequent processing.
|
|
|
|
This patch introduces GRUB_UNICODE_NCOMB_MAX to represent the max
|
|
acceptable value of ncomb. The code now checks for this limit and
|
|
ignores additional combining characters when limit is reached.
|
|
|
|
Reported-by: Daniel Axtens <dja@axtens.net>
|
|
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/normal/charset.c | 3 +++
|
|
include/grub/unicode.h | 2 ++
|
|
2 files changed, 5 insertions(+)
|
|
|
|
diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
|
|
index 000e687bd..4f6647116 100644
|
|
--- a/grub-core/normal/charset.c
|
|
+++ b/grub-core/normal/charset.c
|
|
@@ -472,6 +472,9 @@ grub_unicode_aglomerate_comb (const grub_uint32_t *in, grub_size_t inlen,
|
|
if (!haveout)
|
|
continue;
|
|
|
|
+ if (out->ncomb == GRUB_UNICODE_NCOMB_MAX)
|
|
+ continue;
|
|
+
|
|
if (comb_type == GRUB_UNICODE_COMB_MC
|
|
|| comb_type == GRUB_UNICODE_COMB_ME
|
|
|| comb_type == GRUB_UNICODE_COMB_MN)
|
|
diff --git a/include/grub/unicode.h b/include/grub/unicode.h
|
|
index 71a4d1a54..9360b0b97 100644
|
|
--- a/include/grub/unicode.h
|
|
+++ b/include/grub/unicode.h
|
|
@@ -147,7 +147,9 @@ struct grub_unicode_glyph
|
|
grub_uint8_t bidi_level:6; /* minimum: 6 */
|
|
enum grub_bidi_type bidi_type:5; /* minimum: :5 */
|
|
|
|
+#define GRUB_UNICODE_NCOMB_MAX ((1 << 8) - 1)
|
|
unsigned ncomb:8;
|
|
+
|
|
/* Hint by unicode subsystem how wide this character usually is.
|
|
Real width is determined by font. Set only in UTF-8 stream. */
|
|
int estimated_width:8;
|
|
--
|
|
2.30.2
|
|
|