- Resolves: CVE-2024-45779 CVE-2024-45778 CVE-2025-1118 - Resolves: CVE-2025-0677 CVE-2024-45782 CVE-2025-0690 - Resolves: CVE-2024-45783 CVE-2025-0624 CVE-2024-45776 - Resolves: CVE-2025-0622 CVE-2024-45774 CVE-2024-45775 - Resolves: CVE-2024-45781 CVE-2024-45780 - Resolves: #RHEL-79700 - Resolves: #RHEL-79341 - Resolves: #RHEL-79875 - Resolves: #RHEL-79849 - Resolves: #RHEL-79707 - Resolves: #RHEL-79857 - Resolves: #RHEL-79709 - Resolves: #RHEL-79846 - Resolves: #RHEL-75737 - Resolves: #RHEL-79713 - Resolves: #RHEL-73785 - Resolves: #RHEL-73787 - Resolves: #RHEL-79704 - Resolves: #RHEL-79702 Signed-off-by: Nicolas Frayer <nfrayer@redhat.com>
45 lines
1.6 KiB
Diff
45 lines
1.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: B Horn <b@horn.uk>
|
|
Date: Sat, 16 Nov 2024 21:24:19 +0000
|
|
Subject: [PATCH] kern/partition: Limit recursion in part_iterate()
|
|
|
|
The part_iterate() is used by grub_partition_iterate() as a callback in
|
|
the partition iterate functions. However, part_iterate() may also call
|
|
the partition iterate functions which may lead to recursion. Fix potential
|
|
issue by limiting the recursion depth.
|
|
|
|
Signed-off-by: B Horn <b@horn.uk>
|
|
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
---
|
|
grub-core/kern/partition.c | 10 +++++++++-
|
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/grub-core/kern/partition.c b/grub-core/kern/partition.c
|
|
index 3068c4dca..f3f125e75 100644
|
|
--- a/grub-core/kern/partition.c
|
|
+++ b/grub-core/kern/partition.c
|
|
@@ -28,6 +28,9 @@
|
|
|
|
grub_partition_map_t grub_partition_map_list;
|
|
|
|
+#define MAX_RECURSION_DEPTH 32
|
|
+static unsigned int recursion_depth = 0;
|
|
+
|
|
/*
|
|
* Checks that disk->partition contains part. This function assumes that the
|
|
* start of part is relative to the start of disk->partition. Returns 1 if
|
|
@@ -208,7 +211,12 @@ part_iterate (grub_disk_t dsk, const grub_partition_t partition, void *data)
|
|
FOR_PARTITION_MAPS(partmap)
|
|
{
|
|
grub_err_t err;
|
|
- err = partmap->iterate (dsk, part_iterate, ctx);
|
|
+ recursion_depth++;
|
|
+ if (recursion_depth <= MAX_RECURSION_DEPTH)
|
|
+ err = partmap->iterate (dsk, part_iterate, ctx);
|
|
+ else
|
|
+ err = grub_error (GRUB_ERR_RECURSION_DEPTH, "maximum recursion depth exceeded");
|
|
+ recursion_depth--;
|
|
if (err)
|
|
grub_errno = GRUB_ERR_NONE;
|
|
if (ctx->ret)
|