mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-08-01 21:23:51 -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>
134 lines
5.3 KiB
Diff
134 lines
5.3 KiB
Diff
From 978c4c79935a375cb16d94e8114d96fee013c288 Mon Sep 17 00:00:00 2001
|
||
From: Lidong Chen <lidong.chen@oracle.com>
|
||
Date: Mon, 16 Dec 2024 20:22:39 +0000
|
||
Subject: [PATCH] fs/jfs: Use full 40 bits offset and address for a data extent
|
||
|
||
An extent's logical offset and address are represented as a 40-bit value
|
||
split into two parts: the most significant 8 bits and the least
|
||
significant 32 bits. Currently the JFS code uses only the least
|
||
significant 32 bits value for offsets and addresses assuming the data
|
||
size will never exceed the 32-bit range. This approach ignores the most
|
||
significant 8 bits potentially leading to incorrect offsets and
|
||
addresses for larger values. The patch fixes it by incorporating the
|
||
most significant 8 bits into the calculation to get the full 40-bits
|
||
value for offsets and addresses.
|
||
|
||
https://jfs.sourceforge.net/project/pub/jfslayout.pdf
|
||
|
||
"off1,off2 is a 40-bit field, containing the logical offset of the first
|
||
block in the extent.
|
||
...
|
||
addr1,addr2 is a 40-bit field, containing the address of the extent."
|
||
|
||
Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
|
||
Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
|
||
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
|
||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||
Upstream: bd999310fe67f35a66de3bfa2836da91589d04ef
|
||
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
|
||
---
|
||
grub-core/fs/jfs.c | 41 +++++++++++++++++++++++++++++------------
|
||
1 file changed, 29 insertions(+), 12 deletions(-)
|
||
|
||
diff --git a/grub-core/fs/jfs.c b/grub-core/fs/jfs.c
|
||
index 88fb884df..2bde48d45 100644
|
||
--- a/grub-core/fs/jfs.c
|
||
+++ b/grub-core/fs/jfs.c
|
||
@@ -265,6 +265,20 @@ static grub_dl_t my_mod;
|
||
|
||
static grub_err_t grub_jfs_lookup_symlink (struct grub_jfs_data *data, grub_uint32_t ino);
|
||
|
||
+/*
|
||
+ * An extent's offset, physical and logical, is represented as a 40-bit value.
|
||
+ * This 40-bit value is split into two parts:
|
||
+ * - offset1: the most signficant 8 bits of the offset,
|
||
+ * - offset2: the least significant 32 bits of the offset.
|
||
+ *
|
||
+ * This function calculates and returns the 64-bit offset of an extent.
|
||
+ */
|
||
+static grub_uint64_t
|
||
+get_ext_offset (grub_uint8_t offset1, grub_uint32_t offset2)
|
||
+{
|
||
+ return (((grub_uint64_t) offset1 << 32) | grub_le_to_cpu32 (offset2));
|
||
+}
|
||
+
|
||
static grub_int64_t
|
||
getblk (struct grub_jfs_treehead *treehead,
|
||
struct grub_jfs_tree_extent *extents,
|
||
@@ -274,22 +288,25 @@ getblk (struct grub_jfs_treehead *treehead,
|
||
{
|
||
int found = -1;
|
||
int i;
|
||
+ grub_uint64_t ext_offset, ext_blk;
|
||
|
||
for (i = 0; i < grub_le_to_cpu16 (treehead->count) - 2 &&
|
||
i < max_extents; i++)
|
||
{
|
||
+ ext_offset = get_ext_offset (extents[i].offset1, extents[i].offset2);
|
||
+ ext_blk = get_ext_offset (extents[i].extent.blk1, extents[i].extent.blk2);
|
||
+
|
||
if (treehead->flags & GRUB_JFS_TREE_LEAF)
|
||
{
|
||
/* Read the leafnode. */
|
||
- if (grub_le_to_cpu32 (extents[i].offset2) <= blk
|
||
+ if (ext_offset <= blk
|
||
&& ((grub_le_to_cpu16 (extents[i].extent.length))
|
||
+ (extents[i].extent.length2 << 16)
|
||
- + grub_le_to_cpu32 (extents[i].offset2)) > blk)
|
||
- return (blk - grub_le_to_cpu32 (extents[i].offset2)
|
||
- + grub_le_to_cpu32 (extents[i].extent.blk2));
|
||
+ + ext_offset) > blk)
|
||
+ return (blk - ext_offset + ext_blk);
|
||
}
|
||
else
|
||
- if (blk >= grub_le_to_cpu32 (extents[i].offset2))
|
||
+ if (blk >= ext_offset)
|
||
found = i;
|
||
}
|
||
|
||
@@ -307,10 +324,9 @@ getblk (struct grub_jfs_treehead *treehead,
|
||
return -1;
|
||
|
||
if (!grub_disk_read (data->disk,
|
||
- ((grub_disk_addr_t) grub_le_to_cpu32 (extents[found].extent.blk2))
|
||
- << (grub_le_to_cpu16 (data->sblock.log2_blksz)
|
||
- - GRUB_DISK_SECTOR_BITS), 0,
|
||
- sizeof (*tree), (char *) tree))
|
||
+ (grub_disk_addr_t) ext_blk
|
||
+ << (grub_le_to_cpu16 (data->sblock.log2_blksz) - GRUB_DISK_SECTOR_BITS),
|
||
+ 0, sizeof (*tree), (char *) tree))
|
||
{
|
||
if (grub_memcmp (&tree->treehead, treehead, sizeof (struct grub_jfs_treehead)) ||
|
||
grub_memcmp (&tree->extents, extents, 254 * sizeof (struct grub_jfs_tree_extent)))
|
||
@@ -361,7 +377,7 @@ grub_jfs_read_inode (struct grub_jfs_data *data, grub_uint32_t ino,
|
||
sizeof (iag_inodes), &iag_inodes))
|
||
return grub_errno;
|
||
|
||
- inoblk = grub_le_to_cpu32 (iag_inodes[inoext].blk2);
|
||
+ inoblk = get_ext_offset (iag_inodes[inoext].blk1, iag_inodes[inoext].blk2);
|
||
inoblk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz)
|
||
- GRUB_DISK_SECTOR_BITS);
|
||
inoblk += inonum;
|
||
@@ -490,7 +506,8 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode)
|
||
return 0;
|
||
}
|
||
|
||
- blk = grub_le_to_cpu32 (de[inode->dir.header.sorted[0]].ex.blk2);
|
||
+ blk = get_ext_offset (de[inode->dir.header.sorted[0]].ex.blk1,
|
||
+ de[inode->dir.header.sorted[0]].ex.blk2);
|
||
blk <<= (grub_le_to_cpu16 (data->sblock.log2_blksz) - GRUB_DISK_SECTOR_BITS);
|
||
|
||
/* Read in the nodes until we are on the leaf node level. */
|
||
@@ -508,7 +525,7 @@ grub_jfs_opendir (struct grub_jfs_data *data, struct grub_jfs_inode *inode)
|
||
|
||
de = (struct grub_jfs_internal_dirent *) diro->dirpage->dirent;
|
||
index = diro->dirpage->sorted[diro->dirpage->header.sindex * 32];
|
||
- blk = (grub_le_to_cpu32 (de[index].ex.blk2)
|
||
+ blk = (get_ext_offset (de[index].ex.blk1, de[index].ex.blk2)
|
||
<< (grub_le_to_cpu16 (data->sblock.log2_blksz)
|
||
- GRUB_DISK_SECTOR_BITS));
|
||
} while (!(diro->dirpage->header.flags & GRUB_JFS_TREE_LEAF));
|
||
--
|
||
2.50.1
|
||
|