Skip to content

Commit 2665eaf

Browse files
[AUTO-CHERRYPICK] [High] patch grub2 for CVE-2025-0624 - branch main (#13990)
Co-authored-by: jykanase <[email protected]>
1 parent ffa7d55 commit 2665eaf

File tree

3 files changed

+132
-2
lines changed

3 files changed

+132
-2
lines changed

SPECS-SIGNED/grub2-efi-binary-signed/grub2-efi-binary-signed.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Summary: Signed GRand Unified Bootloader for %{buildarch} systems
1313
Name: grub2-efi-binary-signed-%{buildarch}
1414
Version: 2.06
15-
Release: 13%{?dist}
15+
Release: 14%{?dist}
1616
License: GPLv3+
1717
Vendor: Microsoft Corporation
1818
Distribution: Mariner
@@ -77,6 +77,9 @@ cp %{SOURCE3} %{buildroot}/boot/efi/EFI/BOOT/%{grubpxeefiname}
7777
/boot/efi/EFI/BOOT/%{grubpxeefiname}
7878

7979
%changelog
80+
* Mon Jun 02 2025 Jyoti Kanase <[email protected]> - 2.06-14
81+
- Bump release number to match grub release
82+
8083
* Thu Feb 15 2024 Dan Streetman <[email protected]> - 2.06-13
8184
- match grub2 version
8285

SPECS/grub2/CVE-2025-0624.patch

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
From 8ab67bb3b37cec634490294560d082bafda7cc66 Mon Sep 17 00:00:00 2001
2+
From: jykanase <[email protected]>
3+
Date: Mon, 2 Jun 2025 07:47:48 +0000
4+
Subject: [PATCH] CVE-2025-0624
5+
Upstream Reference Patch: https://lists.gnu.org/archive/html/grub-devel/2025-02/msg00052.html
6+
https://lists.gnu.org/archive/html/grub-devel/2025-02/msg00027.html
7+
---
8+
grub-core/net/net.c | 7 ++++---
9+
grub-core/normal/main.c | 2 +-
10+
include/grub/misc.h | 39 +++++++++++++++++++++++++++++++++++++++
11+
include/grub/net.h | 2 +-
12+
4 files changed, 45 insertions(+), 5 deletions(-)
13+
14+
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
15+
index 4d3eb5c..ec7f01c 100644
16+
--- a/grub-core/net/net.c
17+
+++ b/grub-core/net/net.c
18+
@@ -1773,14 +1773,15 @@ grub_config_search_through (char *config, char *suffix,
19+
}
20+
21+
grub_err_t
22+
-grub_net_search_config_file (char *config)
23+
+grub_net_search_config_file (char *config, grub_size_t config_buf_len)
24+
{
25+
- grub_size_t config_len;
26+
+ grub_size_t config_len, suffix_len;
27+
char *suffix;
28+
29+
config_len = grub_strlen (config);
30+
config[config_len] = '-';
31+
suffix = config + config_len + 1;
32+
+ suffix_len = config_buf_len - (config_len + 1);
33+
34+
struct grub_net_network_level_interface *inf;
35+
FOR_NET_NETWORK_LEVEL_INTERFACES (inf)
36+
@@ -1806,7 +1807,7 @@ grub_net_search_config_file (char *config)
37+
38+
if (client_uuid)
39+
{
40+
- grub_strcpy (suffix, client_uuid);
41+
+ grub_strlcpy (suffix, client_uuid, suffix_len);
42+
if (grub_config_search_through (config, suffix, 1, 0) == 0)
43+
return GRUB_ERR_NONE;
44+
}
45+
diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c
46+
index c4ebe9e..68ef09c 100644
47+
--- a/grub-core/normal/main.c
48+
+++ b/grub-core/normal/main.c
49+
@@ -344,7 +344,7 @@ grub_cmd_normal (struct grub_command *cmd __attribute__ ((unused)),
50+
51+
if (grub_strncmp (prefix + 1, "tftp", sizeof ("tftp") - 1) == 0 &&
52+
!disable_net_search)
53+
- grub_net_search_config_file (config);
54+
+ grub_net_search_config_file (config, config_len);
55+
56+
grub_enter_normal_mode (config);
57+
grub_free (config);
58+
diff --git a/include/grub/misc.h b/include/grub/misc.h
59+
index 7d2b551..0507567 100644
60+
--- a/include/grub/misc.h
61+
+++ b/include/grub/misc.h
62+
@@ -64,6 +64,45 @@ grub_stpcpy (char *dest, const char *src)
63+
return d - 1;
64+
}
65+
66+
+static inline grub_size_t
67+
+grub_strlcpy (char *dest, const char *src, grub_size_t size)
68+
+{
69+
+ char *d = dest;
70+
+ grub_size_t res = 0;
71+
+ /*
72+
+ * We do not subtract one from size here to avoid dealing with underflowing
73+
+ * the value, which is why to_copy is always checked to be greater than one
74+
+ * throughout this function.
75+
+ */
76+
+ grub_size_t to_copy = size;
77+
+
78+
+ /* Copy size - 1 bytes to dest. */
79+
+ if (to_copy > 1)
80+
+ while ((*d++ = *src++) != '\0' && ++res && --to_copy > 1)
81+
+ ;
82+
+
83+
+ /*
84+
+ * NUL terminate if size != 0. The previous step may have copied a NUL byte
85+
+ * if it reached the end of the string, but we know dest[size - 1] must always
86+
+ * be a NUL byte.
87+
+ */
88+
+ if (size != 0)
89+
+ dest[size - 1] = '\0';
90+
+
91+
+ /* If there is still space in dest, but are here, we reached the end of src. */
92+
+ if (to_copy > 1)
93+
+ return res;
94+
+
95+
+ /*
96+
+ * If we haven't reached the end of the string, iterate through to determine
97+
+ * the strings total length.
98+
+ */
99+
+ while (*src++ != '\0' && ++res)
100+
+ ;
101+
+
102+
+ return res;
103+
+}
104+
+
105+
/* XXX: If grub_memmove is too slow, we must implement grub_memcpy. */
106+
static inline void *
107+
grub_memcpy (void *dest, const void *src, grub_size_t n)
108+
diff --git a/include/grub/net.h b/include/grub/net.h
109+
index 7ae4b6b..d6ba8b1 100644
110+
--- a/include/grub/net.h
111+
+++ b/include/grub/net.h
112+
@@ -570,7 +570,7 @@ void
113+
grub_net_remove_dns_server (const struct grub_net_network_level_address *s);
114+
115+
grub_err_t
116+
-grub_net_search_config_file (char *config);
117+
+grub_net_search_config_file (char *config, grub_size_t config_buf_len);
118+
119+
extern char *grub_net_default_server;
120+
121+
--
122+
2.45.2
123+

SPECS/grub2/grub2.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Summary: GRand Unified Bootloader
77
Name: grub2
88
Version: 2.06
9-
Release: 13%{?dist}
9+
Release: 14%{?dist}
1010
License: GPLv3+
1111
Vendor: Microsoft Corporation
1212
Distribution: Mariner
@@ -103,6 +103,7 @@ Patch: sbat-4-0003-fs-ntfs-Fix-an-OOB-read-when-parsing-directory-entri
103103
Patch: sbat-4-0004-fs-ntfs-Fix-an-OOB-read-when-parsing-bitmaps-for-ind.patch
104104
Patch: sbat-4-0005-fs-ntfs-Fix-an-OOB-read-when-parsing-a-volume-label.patch
105105
Patch: sbat-4-0006-fs-ntfs-Make-code-more-readable.patch
106+
Patch: CVE-2025-0624.patch
106107
BuildRequires: autoconf
107108
BuildRequires: device-mapper-devel
108109
BuildRequires: python3
@@ -405,6 +406,9 @@ cp $GRUB_PXE_MODULE_SOURCE $EFI_BOOT_DIR/$GRUB_PXE_MODULE_NAME
405406
%{_sysconfdir}/default/grub.d
406407

407408
%changelog
409+
* Mon Jun 02 2025 Jyoti Kanase <[email protected]> - 2.06-14
410+
- Patch CVE-2025-0624
411+
408412
* Thu Feb 15 2024 Dan Streetman <[email protected]> - 2.06-13
409413
- update grub to sbat 4
410414

0 commit comments

Comments
 (0)