boot/grub2: backport fixes for numerous CVEs
PATCH 1/1 boot/grub2: backport fixes for numerous CVEs
Grub 2.06 is affected by a number of CVEs, which have been fixed in the master branch of Grub, but are not yet part of any release (there is a 2.12-rc1 release, but nothing else between 2.06 and 2.12-rc1).
So this patch backports the relevant fixes for CVE-2022-28736, CVE-2022-28735, CVE-2021-3695, CVE-2021-3696, CVE-2021-3697, CVE-2022-28733, CVE-2022-28734, CVE-2022-2601 and CVE-2022-3775.
It should be noted that CVE-2021-3695, CVE-2021-3696, CVE-2021-3697 are not reported as affecting Grub by our CVE matching logic because the NVD database uses an incorrect CPE ID in those CVEs: it uses "grub" as the product instead of "grub2" like all other CVEs for grub. This issue has been reported to the NVD maintainers.
This requires backporting a lot of patches, but jumping from 2.06 to 2.12-rc1 implies getting 592 commits, which is quite a lot.
All Grub test cases are working fine:
https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500585
https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500679
--- ...onfig-Restore-umask-for-the-grub.cfg.patch | 4 +- ...hainloader-Simplify-the-loader-state.patch | 126 ++++ ...ot-Add-API-to-pass-context-to-loader.patch | 165 +++++ ...i-chainloader-Use-grub_loader_set_ex.patch | 80 ++ ...ct-non-kernel-files-in-the-shim_lock.patch | 105 +++ ...07-video-Remove-trailing-whitespaces.patch | 689 ++++++++++++++++++ ...g-Abort-sooner-if-a-read-operation-f.patch | 204 ++++++ ...g-Refuse-to-handle-multiple-image-he.patch | 34 + ...g-Drop-greyscale-support-to-fix-heap.patch | 173 +++++ ...g-Avoid-heap-OOB-R-W-inserting-huff-.patch | 44 ++ ...eg-Block-int-underflow-wild-pointer-.patch | 78 ++ ...3-net-ip-Do-IP-fragment-maths-safely.patch | 56 ++ ...Fix-OOB-write-for-split-http-headers.patch | 50 ++ ...or-out-on-headers-with-LF-without-CR.patch | 52 ++ ...erflow-in-grub_font_get_glyph_intern.patch | 116 +++ ...-integer-overflows-in-grub_font_cons.patch | 83 +++ ...ix-an-integer-underflow-in-blit_comb.patch | 93 +++ boot/grub2/grub2.mk | 19 + 18 files changed, 2169 insertions(+), 2 deletions(-) create mode 100644 boot/grub2/0003-loader-efi-chainloader-Simplify-the-loader-state.patch create mode 100644 boot/grub2/0004-commands-boot-Add-API-to-pass-context-to-loader.patch create mode 100644 boot/grub2/0005-loader-efi-chainloader-Use-grub_loader_set_ex.patch create mode 100644 boot/grub2/0006-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch create mode 100644 boot/grub2/0007-video-Remove-trailing-whitespaces.patch create mode 100644 boot/grub2/0008-video-readers-png-Abort-sooner-if-a-read-operation-f.patch create mode 100644 boot/grub2/0009-video-readers-png-Refuse-to-handle-multiple-image-he.patch create mode 100644 boot/grub2/0010-video-readers-png-Drop-greyscale-support-to-fix-heap.patch create mode 100644 boot/grub2/0011-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch create mode 100644 boot/grub2/0012-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch create mode 100644 boot/grub2/0013-net-ip-Do-IP-fragment-maths-safely.patch create mode 100644 boot/grub2/0014-net-http-Fix-OOB-write-for-split-http-headers.patch create mode 100644 boot/grub2/0015-net-http-Error-out-on-headers-with-LF-without-CR.patch create mode 100644 boot/grub2/0016-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patch create mode 100644 boot/grub2/0017-font-Fix-several-integer-overflows-in-grub_font_cons.patch create mode 100644 boot/grub2/0018-font-Fix-an-integer-underflow-in-blit_comb.patch
boot/grub2/0002-grub-mkconfig-Restore-umask-for-the-grub.cfg.patch +2 -2
@@ -1,4 +1,4 @@ -From 8418defaf0902bdd8af188221ae54c5a3d6ad05d Mon Sep 17 00:00:00 2001 +From 4c1ad500e73d46c83dec369da85db39ae2fe62dd Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Fri, 3 Dec 2021 16:13:28 +0800 Subject: [PATCH] grub-mkconfig: Restore umask for the grub.cfg
@@ -39,5 +39,5 @@ index f8cbb8d7a..84f356ea4 100644 fi fi -- -2.37.2 +2.41.0
boot/grub2/0003-loader-efi-chainloader-Simplify-the-loader-state.patch new file +126 -0
126 lines not on this page · raw message
boot/grub2/0004-commands-boot-Add-API-to-pass-context-to-loader.patch new file +165 -0
165 lines not on this page · raw message
boot/grub2/0005-loader-efi-chainloader-Use-grub_loader_set_ex.patch new file +80 -0
80 lines not on this page · raw message
boot/grub2/0006-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch new file +105 -0
105 lines not on this page · raw message
boot/grub2/0007-video-Remove-trailing-whitespaces.patch new file +689 -0
689 lines not on this page · raw message
boot/grub2/0008-video-readers-png-Abort-sooner-if-a-read-operation-f.patch new file +204 -0
204 lines not on this page · raw message
boot/grub2/0009-video-readers-png-Refuse-to-handle-multiple-image-he.patch new file +34 -0
@@ -0,0 +1,34 @@ +From e170edd18fcfdd9e6f91ba750fd022cef8d43cd4 Mon Sep 17 00:00:00 2001 +From: Daniel Axtens <[email protected]> +Date: Tue, 6 Jul 2021 14:13:40 +1000 +Subject: [PATCH] video/readers/png: Refuse to handle multiple image headers + +This causes the bitmap to be leaked. Do not permit multiple image headers. + +Signed-off-by: Daniel Axtens <[email protected]> +Reviewed-by: Daniel Kiper <[email protected]> +Upstream: 166a4d61448f74745afe1dac2f2cfb85d04909bf +[Thomas: needed to cherry-pick +e623866d9286410156e8b9d2c82d6253a1b22d08, which fixes CVE-2021-3695] +Signed-off-by: Thomas Petazzoni <[email protected]> +--- + grub-core/video/readers/png.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c +index d715c4629..35ae553c8 100644 +--- a/grub-core/video/readers/png.c ++++ b/grub-core/video/readers/png.c +@@ -258,6 +258,9 @@ grub_png_decode_image_header (struct grub_png_data *data) + int color_bits; + enum grub_video_blit_format blt; + ++ if (data->image_width || data->image_height) ++ return grub_error (GRUB_ERR_BAD_FILE_TYPE, "png: two image headers found"); ++ + data->image_width = grub_png_get_dword (data); + data->image_height = grub_png_get_dword (data); + +-- +2.41.0 +
boot/grub2/0010-video-readers-png-Drop-greyscale-support-to-fix-heap.patch new file +173 -0
173 lines not on this page · raw message
boot/grub2/0011-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch new file +44 -0
44 lines not on this page · raw message
boot/grub2/0012-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch new file +78 -0
78 lines not on this page · raw message
boot/grub2/0013-net-ip-Do-IP-fragment-maths-safely.patch new file +56 -0
56 lines not on this page · raw message
boot/grub2/0014-net-http-Fix-OOB-write-for-split-http-headers.patch new file +50 -0
50 lines not on this page · raw message
boot/grub2/0015-net-http-Error-out-on-headers-with-LF-without-CR.patch new file +52 -0
52 lines not on this page · raw message
boot/grub2/0016-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patch new file +116 -0
116 lines not on this page · raw message
boot/grub2/0017-font-Fix-several-integer-overflows-in-grub_font_cons.patch new file +83 -0
83 lines not on this page · raw message
boot/grub2/0018-font-Fix-an-integer-underflow-in-blit_comb.patch new file +93 -0
93 lines not on this page · raw message
boot/grub2/grub2.mk +19 -0
@@ -34,6 +34,25 @@ GRUB2_IGNORE_CVES += CVE-2020-15705 GRUB2_IGNORE_CVES += CVE-2021-3981 # vulnerability is specific to the SUSE distribution GRUB2_IGNORE_CVES += CVE-2021-46705 +# 0004-loader-efi-chainloader-Use-grub_loader_set_ex.patch +GRUB2_IGNORE_CVES += CVE-2022-28736 +# 0005-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch +GRUB2_IGNORE_CVES += CVE-2022-28735 +# 0009-video-readers-png-Drop-greyscale-support-to-fix-heap.patch +GRUB2_IGNORE_CVES += CVE-2021-3695 +# 0010-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch +GRUB2_IGNORE_CVES += CVE-2021-3696 +# 0011-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch +GRUB2_IGNORE_CVES += CVE-2021-3697 +# 0012-net-ip-Do-IP-fragment-maths-safely.patch +GRUB2_IGNORE_CVES += CVE-2022-28733 +# 0013-net-http-Fix-OOB-write-for-split-http-headers.patch +# 0014-net-http-Error-out-on-headers-with-LF-without-CR.patch +GRUB2_IGNORE_CVES += CVE-2022-28734 +# 0015-font-Fix-several-integer-overflows-in-grub_font_cons.patch +GRUB2_IGNORE_CVES += CVE-2022-2601 +# 0016-font-Fix-an-integer-underflow-in-blit_comb.patch +GRUB2_IGNORE_CVES += CVE-2022-3775 ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y) GRUB2_INSTALL_TARGET = YES
Signature · 6 lines
2.41.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 65 lines · Thomas Petazzoni via buildroot
Grub 2.06 is affected by a number of CVEs, which have been fixed in the master branch of Grub, but are not yet part of any release (there is a 2.12-rc1 release, but nothing else between 2.06 and 2.12-rc1).
So this patch backports the relevant fixes for CVE-2022-28736, CVE-2022-28735, CVE-2021-3695, CVE-2021-3696, CVE-2021-3697, CVE-2022-28733, CVE-2022-28734, CVE-2022-2601 and CVE-2022-3775.
It should be noted that CVE-2021-3695, CVE-2021-3696, CVE-2021-3697 are not reported as affecting Grub by our CVE matching logic because the NVD database uses an incorrect CPE ID in those CVEs: it uses "grub" as the product instead of "grub2" like all other CVEs for grub. This issue has been reported to the NVD maintainers.
This requires backporting a lot of patches, but jumping from 2.06 to 2.12-rc1 implies getting 592 commits, which is quite a lot.
All Grub test cases are working fine:
https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500585 https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500679Signed-off-by Thomas Petazzoni <[email protected]>--- ...onfig-Restore-umask-for-the-grub.cfg.patch | 4 +- ...hainloader-Simplify-the-loader-state.patch | 126 ++++ ...ot-Add-API-to-pass-context-to-loader.patch | 165 +++++ ...i-chainloader-Use-grub_loader_set_ex.patch | 80 ++ ...ct-non-kernel-files-in-the-shim_lock.patch | 105 +++ ...07-video-Remove-trailing-whitespaces.patch | 689 ++++++++++++++++++ ...g-Abort-sooner-if-a-read-operation-f.patch | 204 ++++++ ...g-Refuse-to-handle-multiple-image-he.patch | 34 + ...g-Drop-greyscale-support-to-fix-heap.patch | 173 +++++ ...g-Avoid-heap-OOB-R-W-inserting-huff-.patch | 44 ++ ...eg-Block-int-underflow-wild-pointer-.patch | 78 ++ ...3-net-ip-Do-IP-fragment-maths-safely.patch | 56 ++ ...Fix-OOB-write-for-split-http-headers.patch | 50 ++ ...or-out-on-headers-with-LF-without-CR.patch | 52 ++ ...erflow-in-grub_font_get_glyph_intern.patch | 116 +++ ...-integer-overflows-in-grub_font_cons.patch | 83 +++ ...ix-an-integer-underflow-in-blit_comb.patch | 93 +++ boot/grub2/grub2.mk | 19 + 18 files changed, 2169 insertions(+), 2 deletions(-)create mode 100644
boot/grub2/0003-loader-efi-chainloader-Simplify-the-loader-state.patchcreate mode 100644boot/grub2/0004-commands-boot-Add-API-to-pass-context-to-loader.patchcreate mode 100644boot/grub2/0005-loader-efi-chainloader-Use-grub_loader_set_ex.patchcreate mode 100644boot/grub2/0006-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patchcreate mode 100644boot/grub2/0007-video-Remove-trailing-whitespaces.patchcreate mode 100644boot/grub2/0008-video-readers-png-Abort-sooner-if-a-read-operation-f.patchcreate mode 100644boot/grub2/0009-video-readers-png-Refuse-to-handle-multiple-image-he.patchcreate mode 100644boot/grub2/0010-video-readers-png-Drop-greyscale-support-to-fix-heap.patchcreate mode 100644boot/grub2/0011-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patchcreate mode 100644boot/grub2/0012-video-readers-jpeg-Block-int-underflow-wild-pointer-.patchcreate mode 100644boot/grub2/0013-net-ip-Do-IP-fragment-maths-safely.patchcreate mode 100644boot/grub2/0014-net-http-Fix-OOB-write-for-split-http-headers.patchcreate mode 100644boot/grub2/0015-net-http-Error-out-on-headers-with-LF-without-CR.patchcreate mode 100644boot/grub2/0016-font-Fix-size-overflow-in-grub_font_get_glyph_intern.patchcreate mode 100644boot/grub2/0017-font-Fix-several-integer-overflows-in-grub_font_cons.patchcreate mode 100644boot/grub2/0018-font-Fix-an-integer-underflow-in-blit_comb.patchboot/grub2/0002-grub-mkconfig-Restore-umask-for-the-grub.cfg.patch +0
-0
boot/grub2/0002-grub-mkconfig-Restore-umask-for-the-grub.cfg.patch line 4
Quoted 5 lines
boot/grub2/0002-grub-mkconfig-Restore-umask-for-the-grub.cfg.patch +1
-1@@ -1,4 +1,4 @@ -From 8418defaf0902bdd8af188221ae54c5a3d6ad05d Mon Sep 17 00:00:00 2001 +From 4c1ad500e73d46c83dec369da85db39ae2fe62dd Mon Sep 17 00:00:00 2001 From: Michael Chang <[email protected]> Date: Fri, 3 Dec 2021 16:13:28 +0800 Subject: [PATCH] grub-mkconfig: Restore umask for the grub.cfg
Since this file is modified, my pre-commit hook unconditionally runs
check-package on it. I therefore fixed the incorrectly formatted Upstream tag in it and removed the .checkpackageignore line.
[snip]
boot/grub2/grub2.mk GRUB2_IGNORE_CVES += CVE-2020-15705 · line 37
Quoted 9 lines
boot/grub2/grub2.mk +1
-0@@ -34,6 +34,25 @@ GRUB2_IGNORE_CVES += CVE-2020-15705 GRUB2_IGNORE_CVES += CVE-2021-3981 # vulnerability is specific to the SUSE distribution GRUB2_IGNORE_CVES += CVE-2021-46705 +# 0004-loader-efi-chainloader-Use-grub_loader_set_ex.patch
All the numbers here were one or two off, i.e. this is actually patch 0005...
I corrected all that and applied to master, thanks.
Regards,
Arnout
Quoted 11 lines
boot/grub2/grub2.mk +11
-0+GRUB2_IGNORE_CVES += CVE-2022-28736 +# 0005-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch +GRUB2_IGNORE_CVES += CVE-2022-28735 +# 0009-video-readers-png-Drop-greyscale-support-to-fix-heap.patch +GRUB2_IGNORE_CVES += CVE-2021-3695 +# 0010-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch +GRUB2_IGNORE_CVES += CVE-2021-3696 +# 0011-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch +GRUB2_IGNORE_CVES += CVE-2021-3697 +# 0012-net-ip-Do-IP-fragment-maths-safely.patch +GRUB2_IGNORE_CVES += CVE-2022-28733
boot/grub2/grub2.mk GRUB2_IGNORE_CVES += CVE-2020-15705 · line 58
Quoted 10 lines
boot/grub2/grub2.mk +7
-0+# 0013-net-http-Fix-OOB-write-for-split-http-headers.patch +# 0014-net-http-Error-out-on-headers-with-LF-without-CR.patch +GRUB2_IGNORE_CVES += CVE-2022-28734 +# 0015-font-Fix-several-integer-overflows-in-grub_font_cons.patch +GRUB2_IGNORE_CVES += CVE-2022-2601 +# 0016-font-Fix-an-integer-underflow-in-blit_comb.patch +GRUB2_IGNORE_CVES += CVE-2022-3775 ifeq ($(BR2_TARGET_GRUB2_INSTALL_TOOLS),y) GRUB2_INSTALL_TARGET = YES
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 5 lines · On Wed, 30 Aug 2023 22:01:21 +0200 Arnout Vandecappelle <[email protected]> wrote:
Quoted 1 line
+# 0004-loader-efi-chainloader-Use-grub_loader_set_ex.patch
All the numbers here were one or two off, i.e. this is actually patch 0005...
I corrected all that and applied to master, thanks.
Dammit, sorry about this. Indeed, now I remember that after facing a build issue, I had to backport one more patch, which I have added in the logical order of the patch series, and it was towards the beginning, shifting everything by 1. Thanks for catching and fixing this.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 19 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Thomas" == Thomas Petazzoni via buildroot <[email protected]> writes:
Grub 2.06 is affected by a number of CVEs, which have been fixed in the master branch of Grub, but are not yet part of any release (there is a 2.12-rc1 release, but nothing else between 2.06 and 2.12-rc1).
So this patch backports the relevant fixes for CVE-2022-28736, CVE-2022-28735, CVE-2021-3695, CVE-2021-3696, CVE-2021-3697, CVE-2022-28733, CVE-2022-28734, CVE-2022-2601 and CVE-2022-3775.
It should be noted that CVE-2021-3695, CVE-2021-3696, CVE-2021-3697 are not reported as affecting Grub by our CVE matching logic because the NVD database uses an incorrect CPE ID in those CVEs: it uses "grub" as the product instead of "grub2" like all other CVEs for grub. This issue has been reported to the NVD maintainers.
This requires backporting a lot of patches, but jumping from 2.06 to 2.12-rc1 implies getting 592 commits, which is quite a lot.
Quoted 6 lines
All Grub test cases are working fine:
https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500585
https://gitlab.com/tpetazzoni/buildroot/-/pipelines/984500679Signed-off-by Thomas Petazzoni <[email protected]>
Committed to 2023.02.x and 2023.05.x, thanks.
Signature · 5 lines
Bye, Peter Korsgaard _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot