Skip to content

Commit d3dd71c

Browse files
kgodara912Kshitiz Godara
andauthored
Addressed multiple grub2 CVEs (microsoft#14018)
Co-authored-by: Kshitiz Godara <[email protected]>
1 parent 7f51cf5 commit d3dd71c

25 files changed

+1216
-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: 14%{?dist}
15+
Release: 15%{?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+
* Tue Jun 17 2025 Kshitiz Godara <[email protected]> - 2.06-15
81+
- Bump release number to match grub release
82+
8083
* Mon Jun 02 2025 Jyoti Kanase <[email protected]> - 2.06-14
8184
- Bump release number to match grub release
8285

SPECS/grub2/CVE-2014-3591.patch

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
From 25e4ae28da960baec315e0c10e9f70cd46a89a2e Mon Sep 17 00:00:00 2001
2+
From: Kshitiz Godara <[email protected]>
3+
Date: Mon, 16 Jun 2025 13:30:22 +0000
4+
Subject: [PATCH] Fix for CVE-2014-3591
5+
6+
Upstream reference:
7+
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=patch;h=ff53cf06e966dce0daba5f2c84e03ab9db2c3c8b
8+
---
9+
grub-core/lib/libgcrypt/cipher/elgamal.c | 45 +++++++++++++++++++++---
10+
1 file changed, 41 insertions(+), 4 deletions(-)
11+
12+
diff --git a/grub-core/lib/libgcrypt/cipher/elgamal.c b/grub-core/lib/libgcrypt/cipher/elgamal.c
13+
index ce4be85..47ba882 100644
14+
--- a/grub-core/lib/libgcrypt/cipher/elgamal.c
15+
+++ b/grub-core/lib/libgcrypt/cipher/elgamal.c
16+
@@ -29,6 +29,11 @@
17+
#include "g10lib.h"
18+
#include "mpi.h"
19+
#include "cipher.h"
20+
+/* Blinding is used to mitigate side-channel attacks. You may undef
21+
+ this to speed up the operation in case the system is secured
22+
+ against physical and network mounted side-channel attacks. */
23+
+#define USE_BLINDING 1
24+
+
25+
26+
typedef struct
27+
{
28+
@@ -486,12 +491,44 @@ do_encrypt(gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t input, ELG_public_key *pkey )
29+
static void
30+
decrypt(gcry_mpi_t output, gcry_mpi_t a, gcry_mpi_t b, ELG_secret_key *skey )
31+
{
32+
- gcry_mpi_t t1 = mpi_alloc_secure( mpi_get_nlimbs( skey->p ) );
33+
+ MPI t1, t2, r;
34+
+ unsigned int nbits = mpi_get_nbits (skey->p);
35+
+
36+
+ mpi_normalize (a);
37+
+ mpi_normalize (b);
38+
+
39+
+ t1 = mpi_alloc_secure (mpi_nlimb_hint_from_nbits (nbits));
40+
+#ifdef USE_BLINDING
41+
+
42+
+ t2 = mpi_alloc_secure (mpi_nlimb_hint_from_nbits (nbits));
43+
+ r = mpi_alloc (mpi_nlimb_hint_from_nbits (nbits));
44+
+
45+
+ /* We need a random number of about the prime size. The random
46+
+ number merely needs to be unpredictable; thus we use level 0. */
47+
+ randomize_mpi (r, nbits, 0);
48+
+
49+
+ /* t1 = r^x mod p */
50+
+ mpi_powm (t1, r, skey->x, skey->p);
51+
+ /* t2 = (a * r)^-x mod p */
52+
+ mpi_mulm (t2, a, r, skey->p);
53+
+ mpi_powm (t2, t2, skey->x, skey->p);
54+
+ mpi_invm (t2, t2, skey->p);
55+
+ /* t1 = (t1 * t2) mod p*/
56+
+ mpi_mulm (t1, t1, t2, skey->p);
57+
+
58+
+ mpi_free (r);
59+
+ mpi_free (t2);
60+
+
61+
+#else /*!USE_BLINDING*/
62+
63+
/* output = b/(a^x) mod p */
64+
- gcry_mpi_powm( t1, a, skey->x, skey->p );
65+
- mpi_invm( t1, t1, skey->p );
66+
- mpi_mulm( output, b, t1, skey->p );
67+
+ mpi_powm (t1, a, skey->x, skey->p);
68+
+ mpi_invm (t1, t1, skey->p);
69+
+
70+
+#endif /*!USE_BLINDING*/
71+
+
72+
+ mpi_mulm (output, b, t1, skey->p);
73+
+
74+
#if 0
75+
if( DBG_CIPHER )
76+
{
77+
--
78+
2.45.3
79+

SPECS/grub2/CVE-2017-7526.patch

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
From 352e78a73c6b92155038f341095ab06753f965ea Mon Sep 17 00:00:00 2001
2+
From: Kshitiz Godara <[email protected]>
3+
Date: Mon, 16 Jun 2025 14:38:07 +0000
4+
Subject: [PATCH] Fix for CVE-2017-7526
5+
6+
Upstream reference:
7+
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=patch;h=e6a3dc9900433bbc8ad362a595a3837318c28fa9
8+
---
9+
grub-core/lib/libgcrypt/cipher/rsa.c | 85 ++++++++++++++++++----------
10+
1 file changed, 54 insertions(+), 31 deletions(-)
11+
12+
diff --git a/grub-core/lib/libgcrypt/cipher/rsa.c b/grub-core/lib/libgcrypt/cipher/rsa.c
13+
index ccc9f96..43309f4 100644
14+
--- a/grub-core/lib/libgcrypt/cipher/rsa.c
15+
+++ b/grub-core/lib/libgcrypt/cipher/rsa.c
16+
@@ -685,53 +685,75 @@ stronger_key_check ( RSA_secret_key *skey )
17+
18+
19+
20+
-/****************
21+
- * Secret key operation. Encrypt INPUT with SKEY and put result into OUTPUT.
22+
+/* Secret key operation - standard version.
23+
*
24+
* m = c^d mod n
25+
- *
26+
- * Or faster:
27+
+ */
28+
+static void
29+
+secret_core_std (gcry_mpi_t M, gcry_mpi_t C,
30+
+ gcry_mpi_t D, gcry_mpi_t N)
31+
+{
32+
+ mpi_powm (M, C, D, N);
33+
+}
34+
+
35+
+
36+
+/* Secret key operation - using the CRT.
37+
*
38+
* m1 = c ^ (d mod (p-1)) mod p
39+
* m2 = c ^ (d mod (q-1)) mod q
40+
* h = u * (m2 - m1) mod q
41+
* m = m1 + h * p
42+
- *
43+
- * Where m is OUTPUT, c is INPUT and d,n,p,q,u are elements of SKEY.
44+
+ */
45+
+static void
46+
+secret_core_crt (gcry_mpi_t M, gcry_mpi_t C,
47+
+ gcry_mpi_t D, unsigned int Nlimbs,
48+
+ gcry_mpi_t P, gcry_mpi_t Q, gcry_mpi_t U)
49+
+{
50+
+ gcry_mpi_t m1 = mpi_alloc_secure ( Nlimbs + 1 );
51+
+ gcry_mpi_t m2 = mpi_alloc_secure ( Nlimbs + 1 );
52+
+ gcry_mpi_t h = mpi_alloc_secure ( Nlimbs + 1 );
53+
+
54+
+ /* m1 = c ^ (d mod (p-1)) mod p */
55+
+ mpi_sub_ui ( h, P, 1 );
56+
+ mpi_fdiv_r ( h, D, h );
57+
+ mpi_powm ( m1, C, h, P );
58+
+
59+
+ /* m2 = c ^ (d mod (q-1)) mod q */
60+
+ mpi_sub_ui ( h, Q, 1 );
61+
+ mpi_fdiv_r ( h, D, h );
62+
+ mpi_powm ( m2, C, h, Q );
63+
+
64+
+ /* h = u * ( m2 - m1 ) mod q */
65+
+ mpi_sub ( h, m2, m1 );
66+
+ if ( mpi_has_sign ( h ) )
67+
+ mpi_add ( h, h, Q );
68+
+ mpi_mulm ( h, U, h, Q );
69+
+
70+
+ /* m = m1 + h * p */
71+
+ mpi_mul ( h, h, P );
72+
+ mpi_add ( M, m1, h );
73+
+
74+
+ mpi_free ( h );
75+
+ mpi_free ( m1 );
76+
+ mpi_free ( m2 );
77+
+}
78+
+
79+
+
80+
+/* Secret key operation.
81+
+ * Encrypt INPUT with SKEY and put result into
82+
+ * OUTPUT. SKEY has the secret key parameters.
83+
*/
84+
static void
85+
secret(gcry_mpi_t output, gcry_mpi_t input, RSA_secret_key *skey )
86+
{
87+
if (!skey->p || !skey->q || !skey->u)
88+
{
89+
- mpi_powm (output, input, skey->d, skey->n);
90+
+ secret_core_std (output, input, skey->d, skey->n);
91+
}
92+
else
93+
{
94+
- gcry_mpi_t m1 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
95+
- gcry_mpi_t m2 = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
96+
- gcry_mpi_t h = mpi_alloc_secure( mpi_get_nlimbs(skey->n)+1 );
97+
-
98+
- /* m1 = c ^ (d mod (p-1)) mod p */
99+
- mpi_sub_ui( h, skey->p, 1 );
100+
- mpi_fdiv_r( h, skey->d, h );
101+
- mpi_powm( m1, input, h, skey->p );
102+
- /* m2 = c ^ (d mod (q-1)) mod q */
103+
- mpi_sub_ui( h, skey->q, 1 );
104+
- mpi_fdiv_r( h, skey->d, h );
105+
- mpi_powm( m2, input, h, skey->q );
106+
- /* h = u * ( m2 - m1 ) mod q */
107+
- mpi_sub( h, m2, m1 );
108+
- if ( mpi_is_neg( h ) )
109+
- mpi_add ( h, h, skey->q );
110+
- mpi_mulm( h, skey->u, h, skey->q );
111+
- /* m = m2 + h * p */
112+
- mpi_mul ( h, h, skey->p );
113+
- mpi_add ( output, m1, h );
114+
-
115+
- mpi_free ( h );
116+
- mpi_free ( m1 );
117+
- mpi_free ( m2 );
118+
+ secret_core_crt (output, input, skey->d, mpi_get_nlimbs (skey->n),
119+
+ skey->p, skey->q, skey->u);
120+
}
121+
}
122+
123+
@@ -778,6 +800,7 @@ rsa_unblind (gcry_mpi_t x, gcry_mpi_t ri, gcry_mpi_t n)
124+
return y;
125+
}
126+
127+
+
128+
/*********************************************
129+
************** interface ******************
130+
*********************************************/
131+
--
132+
2.45.3
133+

SPECS/grub2/CVE-2019-13627.patch

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
From ec78ea01c197d46ed44c226613536490a6b0c87f Mon Sep 17 00:00:00 2001
2+
From: Kshitiz Godara <[email protected]>
3+
Date: Mon, 16 Jun 2025 14:01:28 +0000
4+
Subject: [PATCH] Fix for CVE-2019-13627
5+
6+
Upstream reference:
7+
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commit;h=db4e9976cc31b314aafad6626b2894e86ee44d60
8+
---
9+
grub-core/lib/libgcrypt/cipher/dsa.c | 14 ++++++++++++--
10+
grub-core/lib/libgcrypt/mpi/ec.c | 6 +++++-
11+
2 files changed, 17 insertions(+), 3 deletions(-)
12+
13+
diff --git a/grub-core/lib/libgcrypt/cipher/dsa.c b/grub-core/lib/libgcrypt/cipher/dsa.c
14+
index 883a815..1d77305 100644
15+
--- a/grub-core/lib/libgcrypt/cipher/dsa.c
16+
+++ b/grub-core/lib/libgcrypt/cipher/dsa.c
17+
@@ -600,8 +600,6 @@ check_secret_key( DSA_secret_key *sk )
18+
return rc;
19+
}
20+
21+
-
22+
-
23+
/*
24+
Make a DSA signature from HASH and put it into r and s.
25+
*/
26+
@@ -611,10 +609,22 @@ sign(gcry_mpi_t r, gcry_mpi_t s, gcry_mpi_t hash, DSA_secret_key *skey )
27+
gcry_mpi_t k;
28+
gcry_mpi_t kinv;
29+
gcry_mpi_t tmp;
30+
+ unsigned int qbits = mpi_get_nbits (skey->q);
31+
32+
/* Select a random k with 0 < k < q */
33+
k = gen_k( skey->q );
34+
35+
+ /* Originally, ECDSA computation requires k where 0 < k < n.
36+
+ * Here, we add n (the order of curve), to keep k in a
37+
+ * range: n < k < 2*n, or, addming more n, keep k in a range:
38+
+ * 2*n < k < 3*n, so that timing difference of the EC
39+
+ * multiply operation can be small. The result is same.
40+
+ */
41+
+ mpi_add (k, k, skey->E.n);
42+
+ if (!mpi_test_bit (k, qbits))
43+
+ mpi_add (k, k, skey->E.n);
44+
+
45+
+
46+
/* r = (a^k mod p) mod q */
47+
gcry_mpi_powm( r, skey->g, k, skey->p );
48+
mpi_fdiv_r( r, r, skey->q );
49+
diff --git a/grub-core/lib/libgcrypt/mpi/ec.c b/grub-core/lib/libgcrypt/mpi/ec.c
50+
index fa00818..0089347 100644
51+
--- a/grub-core/lib/libgcrypt/mpi/ec.c
52+
+++ b/grub-core/lib/libgcrypt/mpi/ec.c
53+
@@ -617,7 +617,11 @@ _gcry_mpi_ec_mul_point (mpi_point_t *result,
54+
unsigned int nbits;
55+
int i;
56+
57+
- nbits = mpi_get_nbits (scalar);
58+
+ if (mpi_cmp (scalar, ctx->p) >= 0)
59+
+ nbits = mpi_get_nbits (scalar);
60+
+ else
61+
+ nbits = mpi_get_nbits (ctx->p);
62+
+
63+
mpi_set_ui (result->x, 1);
64+
mpi_set_ui (result->y, 1);
65+
mpi_set_ui (result->z, 0);
66+
--
67+
2.45.3
68+

SPECS/grub2/CVE-2024-45774.patch

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From 78297135895384a0653a6748f1af4b9f50609fec Mon Sep 17 00:00:00 2001
2+
From: Kshitiz Godara <[email protected]>
3+
Date: Mon, 16 Jun 2025 14:53:20 +0000
4+
Subject: [PATCH] Fix for CVE-2024-45774
5+
6+
Upstream reference:
7+
https://cgit.git.savannah.gnu.org/cgit/grub.git/patch/?id=2c34af908ebf4856051ed29e46d88abd2b20387f
8+
---
9+
grub-core/video/readers/jpeg.c | 4 ++++
10+
1 file changed, 4 insertions(+)
11+
12+
diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
13+
index 97a533b..80c5bd7 100644
14+
--- a/grub-core/video/readers/jpeg.c
15+
+++ b/grub-core/video/readers/jpeg.c
16+
@@ -333,6 +333,10 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data)
17+
if (grub_errno != GRUB_ERR_NONE)
18+
return grub_errno;
19+
20+
+ if (data->image_height != 0 || data->image_width != 0)
21+
+ return grub_error (GRUB_ERR_BAD_FILE_TYPE,
22+
+ "jpeg: cannot have duplicate SOF0 markers");
23+
+
24+
if (grub_jpeg_get_byte (data) != 8)
25+
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
26+
"jpeg: only 8-bit precision is supported");
27+
--
28+
2.45.3
29+

SPECS/grub2/CVE-2024-45775.patch

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 3451d40564b03136222abd225d2408794c98e57a Mon Sep 17 00:00:00 2001
2+
From: Kshitiz Godara <[email protected]>
3+
Date: Mon, 16 Jun 2025 15:51:34 +0000
4+
Subject: [PATCH] Fix for CVE-2024-45775
5+
6+
Upstream reference:
7+
https://cgit.git.savannah.gnu.org/cgit/grub.git/patch/?id=05be856a8c3aae41f5df90cab7796ab7ee34b872
8+
---
9+
grub-core/commands/extcmd.c | 3 +++
10+
1 file changed, 3 insertions(+)
11+
12+
diff --git a/grub-core/commands/extcmd.c b/grub-core/commands/extcmd.c
13+
index 90a5ca2..c236be1 100644
14+
--- a/grub-core/commands/extcmd.c
15+
+++ b/grub-core/commands/extcmd.c
16+
@@ -49,6 +49,9 @@ grub_extcmd_dispatcher (struct grub_command *cmd, int argc, char **args,
17+
}
18+
19+
state = grub_arg_list_alloc (ext, argc, args);
20+
+ if (state == NULL)
21+
+ return grub_errno;
22+
+
23+
if (grub_arg_parse (ext, argc, args, state, &new_args, &new_argc))
24+
{
25+
context.state = state;
26+
--
27+
2.45.3
28+

SPECS/grub2/CVE-2024-45776.patch

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
From cba3d3966de27f3de803205de897df407603441a Mon Sep 17 00:00:00 2001
2+
From: Kshitiz Godara <[email protected]>
3+
Date: Mon, 16 Jun 2025 16:43:45 +0000
4+
Subject: [PATCH] Fix for CVE-2024-45776
5+
6+
Upstream reference:
7+
https://cgit.git.savannah.gnu.org/cgit/grub.git/patch/?id=09bd6eb58b0f71ec273916070fa1e2de16897a91
8+
---
9+
grub-core/gettext/gettext.c | 4 ++--
10+
1 file changed, 2 insertions(+), 2 deletions(-)
11+
12+
diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
13+
index 16ebc20..85ea44a 100644
14+
--- a/grub-core/gettext/gettext.c
15+
+++ b/grub-core/gettext/gettext.c
16+
@@ -328,8 +328,8 @@ grub_mofile_open (struct grub_gettext_context *ctx,
17+
for (ctx->grub_gettext_max_log = 0; ctx->grub_gettext_max >> ctx->grub_gettext_max_log;
18+
ctx->grub_gettext_max_log++);
19+
20+
- ctx->grub_gettext_msg_list = grub_zalloc (ctx->grub_gettext_max
21+
- * sizeof (ctx->grub_gettext_msg_list[0]));
22+
+ ctx->grub_gettext_msg_list = grub_calloc (ctx->grub_gettext_max,
23+
+ sizeof (ctx->grub_gettext_msg_list[0]));
24+
if (!ctx->grub_gettext_msg_list)
25+
{
26+
grub_file_close (fd);
27+
--
28+
2.45.3
29+

0 commit comments

Comments
 (0)