diff options
author | Praveen Kumar <praveen.kumar@windriver.com> | 2025-05-16 17:14:21 +0530 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2025-05-27 09:38:57 -0700 |
commit | 4ff1ba9c72b2a73f792cb706711e8596f5f2657b (patch) | |
tree | 51a5f3ecec0f3d52350175f31400df4f51ff111a | |
parent | f80b122315a3a8168152c0cee5a004761c602073 (diff) | |
download | poky-4ff1ba9c72b2a73f792cb706711e8596f5f2657b.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: 02e2f5211962394ec3d66882daab240cb465ef85)
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.patch | 120 | ||||
-rw-r--r-- | meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-02.patch | 29 | ||||
-rw-r--r-- | meta/recipes-core/glib-2.0/glib-2.0_2.78.6.bb | 2 |
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..f99c4de7e1 --- /dev/null +++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-01.patch | |||
@@ -0,0 +1,120 @@ | |||
1 | From cc647f9e46d55509a93498af19659baf9c80f2e3 Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Catanzaro <mcatanzaro@redhat.com> | ||
3 | Date: Thu, 10 Apr 2025 10:57:20 -0500 | ||
4 | Subject: [PATCH 1/2] gstring: carefully handle gssize parameters | ||
5 | |||
6 | Wherever we use gssize to allow passing -1, we need to ensure we don't | ||
7 | overflow the value by assigning a gsize to it without checking if the | ||
8 | size exceeds the maximum gssize. The safest way to do this is to just | ||
9 | use normal gsize everywhere instead and use gssize only for the | ||
10 | parameter. | ||
11 | |||
12 | Our computers don't have enough RAM to write tests for this. I tried | ||
13 | forcing string->len to high values for test purposes, but this isn't | ||
14 | valid and will just cause out of bounds reads/writes due to | ||
15 | string->allocated_len being unexpectedly small, so I don't think we can | ||
16 | test this easily. | ||
17 | |||
18 | CVE: CVE-2025-4373 | ||
19 | |||
20 | Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/cc647f9e46d55509a93498af19659baf9c80f2e3] | ||
21 | |||
22 | Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com> | ||
23 | --- | ||
24 | glib/gstring.c | 36 +++++++++++++++++++++++------------- | ||
25 | 1 file changed, 23 insertions(+), 13 deletions(-) | ||
26 | |||
27 | diff --git a/glib/gstring.c b/glib/gstring.c | ||
28 | index 9f04144..d016b65 100644 | ||
29 | --- a/glib/gstring.c | ||
30 | +++ b/glib/gstring.c | ||
31 | @@ -490,8 +490,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 | @@ -788,10 +789,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 | @@ -824,6 +827,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 | @@ -865,15 +869,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 | @@ -931,6 +938,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 | @@ -942,14 +950,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 | -- | ||
120 | 2.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..ea586c90dc --- /dev/null +++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-4373-02.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From 4d435bb4809793c445846db8fb87e3c9184c4703 Mon Sep 17 00:00:00 2001 | ||
2 | From: Peter Bloomfield <peterbloomfield@bellsouth.net> | ||
3 | Date: Fri, 11 Apr 2025 05:52:33 +0000 | ||
4 | Subject: [PATCH 2/2] gstring: Make len_unsigned unsigned | ||
5 | |||
6 | CVE: CVE-2025-4373 | ||
7 | |||
8 | Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/4d435bb4809793c445846db8fb87e3c9184c4703] | ||
9 | |||
10 | Signed-off-by: Praveen Kumar <praveen.kumar@windriver.com> | ||
11 | --- | ||
12 | glib/gstring.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/glib/gstring.c b/glib/gstring.c | ||
16 | index d016b65..d9ad0c3 100644 | ||
17 | --- a/glib/gstring.c | ||
18 | +++ b/glib/gstring.c | ||
19 | @@ -938,7 +938,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 | -- | ||
29 | 2.40.0 | ||
diff --git a/meta/recipes-core/glib-2.0/glib-2.0_2.78.6.bb b/meta/recipes-core/glib-2.0/glib-2.0_2.78.6.bb index 1a65f48399..e1a3b57270 100644 --- a/meta/recipes-core/glib-2.0/glib-2.0_2.78.6.bb +++ b/meta/recipes-core/glib-2.0/glib-2.0_2.78.6.bb | |||
@@ -27,6 +27,8 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \ | |||
27 | file://CVE-2025-3360-04.patch \ | 27 | file://CVE-2025-3360-04.patch \ |
28 | file://CVE-2025-3360-05.patch \ | 28 | file://CVE-2025-3360-05.patch \ |
29 | file://CVE-2025-3360-06.patch \ | 29 | file://CVE-2025-3360-06.patch \ |
30 | file://CVE-2025-4373-01.patch \ | ||
31 | file://CVE-2025-4373-02.patch \ | ||
30 | " | 32 | " |
31 | SRC_URI:append:class-native = " file://relocate-modules.patch \ | 33 | SRC_URI:append:class-native = " file://relocate-modules.patch \ |
32 | file://0001-meson.build-do-not-enable-pidfd-features-on-native-g.patch \ | 34 | file://0001-meson.build-do-not-enable-pidfd-features-on-native-g.patch \ |