mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 13:18:36 -09:00
This patch brings the entire stack of Debian patches on grub2 titled "cve-2025-jan" and available at: https://salsa.debian.org/grub-team/grub/-/tree/debian/2.12-9/debian/patches/cve-2025-jan?ref_type=tags As of this exact Debian grub2 version 2.12-9. Some minor conflicts had to be fixed. All patches are in upstream Grub master, but mixed with hundreds of other changes, which is why Debian's effort to backport them has been leveraged here. In addition to those patches, 2 extra patches are added: 0073-net-drivers-ieee1275-ofnet-Add-missing-grub_malloc.patch 0074-Constant-time-grub_crypto_memcmp.patch The first one fixes an issue in one of the earlier patches. The fix is not in Debian, but is in upstream Grub. The second one fixes another CVE, not fixed in Debian, but fixed in OpenSUSE. This fix is not upstream as upstream has decided to move to libgcrypt instead to avoid the problem, but that's a fairly large change. Overall, this patch fixes all CVEs currently reported by pkg-stats against our grub2 package, namely: CVE-2024-45777 CVE-2024-45778 CVE-2024-45779 CVE-2024-45780 CVE-2024-45782 CVE-2024-56737 CVE-2024-56738 CVE-2025-0678 CVE-2025-0684 CVE-2025-0685 CVE-2025-0686 CVE-2025-0689 CVE-2025-1125 With the previous fixes on runtime tests added (to use glibc toolchains to build grub2 tests), this commit successfully passes all tests: - The ISO9660 tests that use grub2: https://gitlab.com/tpetazzoni/buildroot/-/pipelines/1985234563 - The grub2 tests: https://gitlab.com/tpetazzoni/buildroot/-/pipelines/1985234685 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> [Julien: also tested by building and booting - qemu_aarch64_sbsa_defconfig - qemu_arm_ebbr_defconfig - qemu_loongarch64_virt_efi_defconfig - qemu_riscv64_virt_efi_defconfig - pc_x86_64_bios_defconfig - pc_x86_64_efi_defconfig ] Tested-by: Julien Olivain <ju.o@free.fr> [Julien: - fix patch #72 upstream link to point to the initial patch sumbission rather than a reply - merge two _IGNORE_CVES blocks for patch #50 into a single one - order _IGNORE_CVES blocks by numerical patch order - order numerically the CVE list in commit log - add a "Fixes:" tag in patch #74 since its commit log does not mention the CVE. ] Signed-off-by: Julien Olivain <ju.o@free.fr>
62 lines
2.1 KiB
Diff
62 lines
2.1 KiB
Diff
From 02a0365799f5ca3d70c4e28b5d11ade56c4c1652 Mon Sep 17 00:00:00 2001
|
|
From: Alec Brown <alec.r.brown@oracle.com>
|
|
Date: Wed, 5 Feb 2025 22:04:08 +0000
|
|
Subject: [PATCH] loader/i386/bsd: Use safe math to avoid underflow
|
|
|
|
The operation kern_end - kern_start may underflow when we input it into
|
|
grub_relocator_alloc_chunk_addr() call. To avoid this we can use safe
|
|
math for this subtraction.
|
|
|
|
Fixes: CID 73845
|
|
|
|
Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
Upstream: 4dc6166571645780c459dde2cdc1b001a5ec844c
|
|
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
|
---
|
|
grub-core/loader/i386/bsd.c | 14 ++++++++++----
|
|
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
|
|
index 1f9128f6f..578433402 100644
|
|
--- a/grub-core/loader/i386/bsd.c
|
|
+++ b/grub-core/loader/i386/bsd.c
|
|
@@ -1340,6 +1340,7 @@ static grub_err_t
|
|
grub_bsd_load_elf (grub_elf_t elf, const char *filename)
|
|
{
|
|
grub_err_t err;
|
|
+ grub_size_t sz;
|
|
|
|
kern_end = 0;
|
|
kern_start = ~0;
|
|
@@ -1370,8 +1371,11 @@ grub_bsd_load_elf (grub_elf_t elf, const char *filename)
|
|
|
|
if (grub_errno)
|
|
return grub_errno;
|
|
- err = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
|
- kern_start, kern_end - kern_start);
|
|
+
|
|
+ if (grub_sub (kern_end, kern_start, &sz))
|
|
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "underflow detected while determining size of kernel for relocator");
|
|
+
|
|
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_start, sz);
|
|
if (err)
|
|
return err;
|
|
|
|
@@ -1431,8 +1435,10 @@ grub_bsd_load_elf (grub_elf_t elf, const char *filename)
|
|
{
|
|
grub_relocator_chunk_t ch;
|
|
|
|
- err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_start,
|
|
- kern_end - kern_start);
|
|
+ if (grub_sub (kern_end, kern_start, &sz))
|
|
+ return grub_error (GRUB_ERR_OUT_OF_RANGE, "underflow detected while determining size of kernel for relocator");
|
|
+
|
|
+ err = grub_relocator_alloc_chunk_addr (relocator, &ch, kern_start, sz);
|
|
if (err)
|
|
return err;
|
|
kern_chunk_src = get_virtual_current_address (ch);
|
|
--
|
|
2.50.1
|
|
|