forked from pool/grub2
e016790fe1
- Security fixes and hardenings for boothole 3 / boothole 2022 (bsc#1198581) * 0001-video-Remove-trailing-whitespaces.patch * 0002-loader-efi-chainloader-Simplify-the-loader-state.patch * 0003-commands-boot-Add-API-to-pass-context-to-loader.patch - Fix CVE-2022-28736 (bsc#1198496) * 0004-loader-efi-chainloader-Use-grub_loader_set_ex.patch - Fix CVE-2022-28735 (bsc#1198495) * 0005-kern-efi-sb-Reject-non-kernel-files-in-the-shim_lock.patch * 0006-kern-file-Do-not-leak-device_name-on-error-in-grub_f.patch * 0007-video-readers-png-Abort-sooner-if-a-read-operation-f.patch * 0008-video-readers-png-Refuse-to-handle-multiple-image-he.patch - Fix CVE-2021-3695 (bsc#1191184) * 0009-video-readers-png-Drop-greyscale-support-to-fix-heap.patch - Fix CVE-2021-3696 (bsc#1191185) * 0010-video-readers-png-Avoid-heap-OOB-R-W-inserting-huff-.patch * 0011-video-readers-png-Sanity-check-some-huffman-codes.patch * 0012-video-readers-jpeg-Abort-sooner-if-a-read-operation-.patch * 0013-video-readers-jpeg-Do-not-reallocate-a-given-huff-ta.patch * 0014-video-readers-jpeg-Refuse-to-handle-multiple-start-o.patch - Fix CVE-2021-3697 (bsc#1191186) * 0015-video-readers-jpeg-Block-int-underflow-wild-pointer-.patch * 0016-normal-charset-Fix-array-out-of-bounds-formatting-un.patch - Fix CVE-2022-28733 (bsc#1198460) * 0017-net-ip-Do-IP-fragment-maths-safely.patch * 0018-net-netbuff-Block-overly-large-netbuff-allocs.patch * 0019-net-dns-Fix-double-free-addresses-on-corrupt-DNS-res.patch * 0020-net-dns-Don-t-read-past-the-end-of-the-string-we-re-.patch * 0021-net-tftp-Prevent-a-UAF-and-double-free-from-a-failed.patch * 0022-net-tftp-Avoid-a-trivial-UAF.patch * 0023-net-http-Do-not-tear-down-socket-if-it-s-already-bee.patch OBS-URL: https://build.opensuse.org/request/show/981228 OBS-URL: https://build.opensuse.org/package/show/Base:System/grub2?expand=0&rev=416
79 lines
2.8 KiB
Diff
79 lines
2.8 KiB
Diff
From 480019e546386b8e25a26d03408897a7752b98b6 Mon Sep 17 00:00:00 2001
|
|
From: Darren Kenny <darren.kenny@oracle.com>
|
|
Date: Thu, 7 Apr 2022 15:18:12 +0000
|
|
Subject: [PATCH 31/32] fs/btrfs: Fix more fuzz issues related to chunks
|
|
|
|
The corpus was generating issues in grub_btrfs_read_logical() when
|
|
attempting to iterate over stripe entries in the superblock's
|
|
bootmapping.
|
|
|
|
In most cases the reason for the failure was that the number of stripes
|
|
in chunk->nstripes exceeded the possible space statically allocated in
|
|
superblock bootmapping space. Each stripe entry in the bootmapping block
|
|
consists of a grub_btrfs_key followed by a grub_btrfs_chunk_stripe.
|
|
|
|
Another issue that came up was that while calculating the chunk size,
|
|
in an earlier piece of code in that function, depending on the data
|
|
provided in the btrfs file system, it would end up calculating a size
|
|
that was too small to contain even 1 grub_btrfs_chunk_item, which is
|
|
obviously invalid too.
|
|
|
|
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/fs/btrfs.c | 24 ++++++++++++++++++++++++
|
|
1 file changed, 24 insertions(+)
|
|
|
|
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
|
|
index 62fe5e6a69..7007463c6e 100644
|
|
--- a/grub-core/fs/btrfs.c
|
|
+++ b/grub-core/fs/btrfs.c
|
|
@@ -944,6 +944,17 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
|
|
return grub_error (GRUB_ERR_BAD_FS,
|
|
"got an invalid zero-size chunk");
|
|
}
|
|
+
|
|
+ /*
|
|
+ * The space being allocated for a chunk should at least be able to
|
|
+ * contain one chunk item.
|
|
+ */
|
|
+ if (chsize < sizeof (struct grub_btrfs_chunk_item))
|
|
+ {
|
|
+ grub_dprintf ("btrfs", "chunk-size too small\n");
|
|
+ return grub_error (GRUB_ERR_BAD_FS,
|
|
+ "got an invalid chunk size");
|
|
+ }
|
|
chunk = grub_malloc (chsize);
|
|
if (!chunk)
|
|
return grub_errno;
|
|
@@ -1191,6 +1202,13 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
|
|
if (csize > (grub_uint64_t) size)
|
|
csize = size;
|
|
|
|
+ /*
|
|
+ * The space for a chunk stripe is limited to the space provide in the super-block's
|
|
+ * bootstrap mapping with an initial btrfs key at the start of each chunk.
|
|
+ */
|
|
+ grub_size_t avail_stripes = sizeof (data->sblock.bootstrap_mapping) /
|
|
+ (sizeof (struct grub_btrfs_key) + sizeof (struct grub_btrfs_chunk_stripe));
|
|
+
|
|
for (j = 0; j < 2; j++)
|
|
{
|
|
grub_size_t est_chunk_alloc = 0;
|
|
@@ -1217,6 +1235,12 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr,
|
|
break;
|
|
}
|
|
|
|
+ if (grub_le_to_cpu16 (chunk->nstripes) > avail_stripes)
|
|
+ {
|
|
+ err = GRUB_ERR_BAD_FS;
|
|
+ break;
|
|
+ }
|
|
+
|
|
if (is_raid56)
|
|
{
|
|
err = btrfs_read_from_chunk (data, chunk, stripen,
|
|
--
|
|
2.34.1
|
|
|