44f318a38d
Porting patches from grub2_2.06-3~deb11u1 to fix below CVEs: CVE-2021-3695 CVE-2021-3696 CVE-2021-3697 CVE-2022-28733 CVE-2022-28734 The source code of grub2_2.06-3~deb11u1 is from: https://snapshot.debian.org/archive/debian/20220807T030023Z/pool /main/g/grub2/grub2_2.06-3~deb11u1.debian.tar.xz The relationship between commits and CVEs is as below: (1)CVE-2021-3695 commit <video/readers/png: Drop greyscale support to fix heap out-of-bounds write> (2)CVE-2021-3696 commit <video/readers/png: Avoid heap OOB R/W inserting huff table items> (3)CVE-2021-3697 commit <video/readers/jpeg: Block int underflow -> wild pointer write> (4)CVE-2022-28733 commit <net/ip: Do IP fragment maths safely> (5)CVE-2022-28734 commit <net/http: Fix OOB write for split http headers> commit <net/http: Error out on headers with LF without CR> 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. Partial-Bug: #2034119 Signed-off-by: Li Zhou <li.zhou@windriver.com> Change-Id: Ia27b1ee225f13e9c4ad08a0828f93ea37f8d3dfb
43 lines
1.3 KiB
Diff
43 lines
1.3 KiB
Diff
From b54f7505732ad5c6237a133c0a1cf00774f13508 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Axtens <dja@axtens.net>
|
|
Date: Tue, 6 Jul 2021 23:25:07 +1000
|
|
Subject: [PATCH 2/6] video/readers/png: Avoid heap OOB R/W inserting huff
|
|
table items
|
|
|
|
In fuzzing we observed crashes where a code would attempt to be inserted
|
|
into a huffman table before the start, leading to a set of heap OOB reads
|
|
and writes as table entries with negative indices were shifted around and
|
|
the new code written in.
|
|
|
|
Catch the case where we would underflow the array and bail.
|
|
|
|
Fixes: CVE-2021-3696
|
|
|
|
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/video/readers/png.c | 7 +++++++
|
|
1 file changed, 7 insertions(+)
|
|
|
|
diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c
|
|
index 1e35eae..0356f91 100644
|
|
--- a/grub-core/video/readers/png.c
|
|
+++ b/grub-core/video/readers/png.c
|
|
@@ -420,6 +420,13 @@ grub_png_insert_huff_item (struct huff_table *ht, int code, int len)
|
|
for (i = len; i < ht->max_length; i++)
|
|
n += ht->maxval[i];
|
|
|
|
+ if (n > ht->num_values)
|
|
+ {
|
|
+ grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
|
+ "png: out of range inserting huffman table item");
|
|
+ return;
|
|
+ }
|
|
+
|
|
for (i = 0; i < n; i++)
|
|
ht->values[ht->num_values - i] = ht->values[ht->num_values - i - 1];
|
|
|
|
--
|
|
2.17.1
|
|
|