summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPraveen Kumar <praveen.kumar@windriver.com>2025-05-23 12:06:39 +0530
committerSteve Sakoman <steve@sakoman.com>2025-05-28 08:46:32 -0700
commit097732e0574126222472eeabda9417072b5ac3f8 (patch)
tree51db615babc41936708345dd97de75fb812012c5
parentef632f46930cd5e8a455fdefad18b921c5ef6625 (diff)
downloadpoky-097732e0574126222472eeabda9417072b5ac3f8.tar.gz
glib-2.0: fix CVE-2025-4373
A flaw was found in GLib, which is vulnerable to an integer overflow in the g_string_insert_unichar() function. When the position at which to insert the character is large, the position will overflow, leading to a buffer underwrite. References: https://nvd.nist.gov/vuln/detail/CVE-2025-4373 https://security-tracker.debian.org/tracker/CVE-2025-4373 Upstream-patches: https://gitlab.gnome.org/GNOME/glib/-/commit/cc647f9e46d55509a93498af19659baf9c80f2e3 https://gitlab.gnome.org/GNOME/glib/-/commit/4d435bb4809793c445846db8fb87e3c9184c4703 (From OE-Core rev: 7a7319745637d4b681935ae71706dcc467df3040) Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-01.patch120
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-02.patch29
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0_2.72.3.bb2
3 files changed, 151 insertions, 0 deletions
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-01.patch b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-01.patch
new file mode 100644
index 0000000000..5b43850c53
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-01.patch
@@ -0,0 +1,120 @@
1From cc647f9e46d55509a93498af19659baf9c80f2e3 Mon Sep 17 00:00:00 2001
2From: Michael Catanzaro <mcatanzaro@redhat.com>
3Date: Thu, 10 Apr 2025 10:57:20 -0500
4Subject: [PATCH 1/2] gstring: carefully handle gssize parameters
5
6Wherever we use gssize to allow passing -1, we need to ensure we don't
7overflow the value by assigning a gsize to it without checking if the
8size exceeds the maximum gssize. The safest way to do this is to just
9use normal gsize everywhere instead and use gssize only for the
10parameter.
11
12Our computers don't have enough RAM to write tests for this. I tried
13forcing string->len to high values for test purposes, but this isn't
14valid and will just cause out of bounds reads/writes due to
15string->allocated_len being unexpectedly small, so I don't think we can
16test this easily.
17
18CVE: CVE-2025-4373
19
20Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/cc647f9e46d55509a93498af19659baf9c80f2e3]
21
22Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com>
23---
24 glib/gstring.c | 36 +++++++++++++++++++++++-------------
25 1 file changed, 23 insertions(+), 13 deletions(-)
26
27diff --git a/glib/gstring.c b/glib/gstring.c
28index 0a509e5..d6f8735 100644
29--- a/glib/gstring.c
30+++ b/glib/gstring.c
31@@ -424,8 +424,9 @@ g_string_insert_len (GString *string,
32 return string;
33
34 if (len < 0)
35- len = strlen (val);
36- len_unsigned = len;
37+ len_unsigned = strlen (val);
38+ else
39+ len_unsigned = len;
40
41 if (pos < 0)
42 pos_unsigned = string->len;
43@@ -723,10 +724,12 @@ g_string_insert_c (GString *string,
44 g_string_maybe_expand (string, 1);
45
46 if (pos < 0)
47- pos = string->len;
48+ pos_unsigned = string->len;
49 else
50- g_return_val_if_fail ((gsize) pos <= string->len, string);
51- pos_unsigned = pos;
52+ {
53+ pos_unsigned = pos;
54+ g_return_val_if_fail (pos_unsigned <= string->len, string);
55+ }
56
57 /* If not just an append, move the old stuff */
58 if (pos_unsigned < string->len)
59@@ -759,6 +762,7 @@ g_string_insert_unichar (GString *string,
60 gssize pos,
61 gunichar wc)
62 {
63+ gsize pos_unsigned;
64 gint charlen, first, i;
65 gchar *dest;
66
67@@ -800,15 +804,18 @@ g_string_insert_unichar (GString *string,
68 g_string_maybe_expand (string, charlen);
69
70 if (pos < 0)
71- pos = string->len;
72+ pos_unsigned = string->len;
73 else
74- g_return_val_if_fail ((gsize) pos <= string->len, string);
75+ {
76+ pos_unsigned = pos;
77+ g_return_val_if_fail (pos_unsigned <= string->len, string);
78+ }
79
80 /* If not just an append, move the old stuff */
81- if ((gsize) pos < string->len)
82- memmove (string->str + pos + charlen, string->str + pos, string->len - pos);
83+ if (pos_unsigned < string->len)
84+ memmove (string->str + pos_unsigned + charlen, string->str + pos_unsigned, string->len - pos_unsigned);
85
86- dest = string->str + pos;
87+ dest = string->str + pos_unsigned;
88 /* Code copied from g_unichar_to_utf() */
89 for (i = charlen - 1; i > 0; --i)
90 {
91@@ -866,6 +873,7 @@ g_string_overwrite_len (GString *string,
92 const gchar *val,
93 gssize len)
94 {
95+ gssize len_unsigned;
96 gsize end;
97
98 g_return_val_if_fail (string != NULL, NULL);
99@@ -877,14 +885,16 @@ g_string_overwrite_len (GString *string,
100 g_return_val_if_fail (pos <= string->len, string);
101
102 if (len < 0)
103- len = strlen (val);
104+ len_unsigned = strlen (val);
105+ else
106+ len_unsigned = len;
107
108- end = pos + len;
109+ end = pos + len_unsigned;
110
111 if (end > string->len)
112 g_string_maybe_expand (string, end - string->len);
113
114- memcpy (string->str + pos, val, len);
115+ memcpy (string->str + pos, val, len_unsigned);
116
117 if (end > string->len)
118 {
119--
1202.40.0
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-02.patch b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-02.patch
new file mode 100644
index 0000000000..d5a4d8dacd
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-02.patch
@@ -0,0 +1,29 @@
1From 4d435bb4809793c445846db8fb87e3c9184c4703 Mon Sep 17 00:00:00 2001
2From: Peter Bloomfield <peterbloomfield@bellsouth.net>
3Date: Fri, 11 Apr 2025 05:52:33 +0000
4Subject: [PATCH 2/2] gstring: Make len_unsigned unsigned
5
6CVE: CVE-2025-4373
7
8Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/4d435bb4809793c445846db8fb87e3c9184c4703]
9
10Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com>
11---
12 glib/gstring.c | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/glib/gstring.c b/glib/gstring.c
16index d6f8735..d097e2f 100644
17--- a/glib/gstring.c
18+++ b/glib/gstring.c
19@@ -873,7 +873,7 @@ g_string_overwrite_len (GString *string,
20 const gchar *val,
21 gssize len)
22 {
23- gssize len_unsigned;
24+ gsize len_unsigned;
25 gsize end;
26
27 g_return_val_if_fail (string != NULL, NULL);
28--
292.40.0
diff --git a/meta/recipes-core/glib-2.0/glib-2.0_2.72.3.bb b/meta/recipes-core/glib-2.0/glib-2.0_2.72.3.bb
index cebd84dd50..8d2c452088 100644
--- a/meta/recipes-core/glib-2.0/glib-2.0_2.72.3.bb
+++ b/meta/recipes-core/glib-2.0/glib-2.0_2.72.3.bb
@@ -60,6 +60,8 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
60 file://CVE-2025-3360-04.patch \ 60 file://CVE-2025-3360-04.patch \
61 file://CVE-2025-3360-05.patch \ 61 file://CVE-2025-3360-05.patch \
62 file://CVE-2025-3360-06.patch \ 62 file://CVE-2025-3360-06.patch \
63 file://CVE-2025-4373-01.patch \
64 file://CVE-2025-4373-02.patch \
63 " 65 "
64SRC_URI:append:class-native = " file://relocate-modules.patch" 66SRC_URI:append:class-native = " file://relocate-modules.patch"
65 67