summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYogita Urade <yogita.urade@windriver.com>2025-09-19 13:53:26 +0530
committerSteve Sakoman <steve@sakoman.com>2025-10-03 09:51:17 -0700
commitd2a96dd89c0f0c5da62974439d74b7b351c0dbaf (patch)
tree6c56e6a0fc85ff8a22ceb647774835d972ffa49a
parent9ae3736eb488e5ad694a63d7cd92b9d6d090fabd (diff)
downloadpoky-d2a96dd89c0f0c5da62974439d74b7b351c0dbaf.tar.gz
grub2: fix CVE-2024-56738
Backport an algorithmic change to grub_crypto_memcmp() so that it completes in constant time and thus isn't susceptible to side-channel attacks. reference: https://git.openembedded.org/openembedded-core/commit/?id=30a1cc225a2bd5d044bf608d863a67df3f9c03be Upstream patch: https://cgit.git.savannah.gnu.org/cgit/grub.git/commit/?id=0739d24cd1648531d0708d1079ff6bbfa6140268 (From OE-Core rev: d6572d29892b7da593acafe3af68cf98230acf04) Signed-off-by: Yogita Urade <yogita.urade@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-bsp/grub/files/CVE-2024-56738.patch75
-rw-r--r--meta/recipes-bsp/grub/grub2.inc1
2 files changed, 76 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/CVE-2024-56738.patch b/meta/recipes-bsp/grub/files/CVE-2024-56738.patch
new file mode 100644
index 0000000000..1212b2d3e5
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/CVE-2024-56738.patch
@@ -0,0 +1,75 @@
1From 4cef2fc7308b2132317ad166939994f098b41561 Mon Sep 17 00:00:00 2001
2From: Ross Burton <ross.burton@arm.com>
3Date: Tue, 9 Sep 2025 14:23:14 +0100
4Subject: [PATCH] CVE-2024-56738
5
6Backport an algorithmic change to grub_crypto_memcmp() so that it completes in
7constant time and thus isn't susceptible to side-channel attacks.
8
9This is a partial backport of grub 0739d24cd
10("libgcrypt: Adjust import script, definitions and API users for libgcrypt 1.11")
11
12CVE: CVE-2024-56738
13Upstream-Status: Backport [0739d24cd]
14Signed-off-by: Ross Burton <ross.burton@arm.com>
15Signed-off-by: Yogita Urade <yogita.urade@windriver.com>
16---
17 grub-core/lib/crypto.c | 23 ++++++++++++++++-------
18 include/grub/crypto.h | 2 +-
19 2 files changed, 17 insertions(+), 8 deletions(-)
20
21diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c
22index ca334d5..1bfa922 100644
23--- a/grub-core/lib/crypto.c
24+++ b/grub-core/lib/crypto.c
25@@ -433,19 +433,28 @@ grub_crypto_gcry_error (gcry_err_code_t in)
26 return GRUB_ACCESS_DENIED;
27 }
28
29+/*
30+ * Compare byte arrays of length LEN, return 1 if it's not same,
31+ * 0, otherwise.
32+ */
33 int
34-grub_crypto_memcmp (const void *a, const void *b, grub_size_t n)
35+grub_crypto_memcmp (const void *b1, const void *b2, grub_size_t len)
36 {
37- register grub_size_t counter = 0;
38- const grub_uint8_t *pa, *pb;
39+ const grub_uint8_t *a = b1;
40+ const grub_uint8_t *b = b2;
41+ int ab, ba;
42+ grub_size_t i;
43
44- for (pa = a, pb = b; n; pa++, pb++, n--)
45+ /* Constant-time compare. */
46+ for (i = 0, ab = 0, ba = 0; i < len; i++)
47 {
48- if (*pa != *pb)
49- counter++;
50+ /* If a[i] != b[i], either ab or ba will be negative. */
51+ ab |= a[i] - b[i];
52+ ba |= b[i] - a[i];
53 }
54
55- return !!counter;
56+ /* 'ab | ba' is negative when buffers are not equal, extract sign bit. */
57+ return ((unsigned int)(ab | ba) >> (sizeof(unsigned int) * 8 - 1)) & 1;
58 }
59
60 #ifndef GRUB_UTIL
61diff --git a/include/grub/crypto.h b/include/grub/crypto.h
62index 21cd1f7..432912b 100644
63--- a/include/grub/crypto.h
64+++ b/include/grub/crypto.h
65@@ -393,7 +393,7 @@ grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
66 grub_uint8_t *DK, grub_size_t dkLen);
67
68 int
69-grub_crypto_memcmp (const void *a, const void *b, grub_size_t n);
70+grub_crypto_memcmp (const void *b1, const void *b2, grub_size_t len);
71
72 int
73 grub_password_get (char buf[], unsigned buf_size);
74--
752.40.0
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index cb61080aeb..1b019752b7 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -59,6 +59,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
59 file://CVE-2025-0678_CVE-2025-1125.patch \ 59 file://CVE-2025-0678_CVE-2025-1125.patch \
60 file://CVE-2025-0690.patch \ 60 file://CVE-2025-0690.patch \
61 file://CVE-2025-1118.patch \ 61 file://CVE-2025-1118.patch \
62 file://CVE-2024-56738.patch \
62" 63"
63 64
64SRC_URI[sha256sum] = "23b64b4c741569f9426ed2e3d0e6780796fca081bee4c99f62aa3f53ae803f5f" 65SRC_URI[sha256sum] = "23b64b4c741569f9426ed2e3d0e6780796fca081bee4c99f62aa3f53ae803f5f"