summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2025-12-31 10:55:43 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2026-01-26 09:49:25 +0000
commit32417b8ef75d4a464d9da746fddc80561641333c (patch)
tree1cb94bbefb298c0477bc0564198a192d58299624
parent0092f97678b3e36d408df37abf1ecdfad60ac1c8 (diff)
downloadpoky-32417b8ef75d4a464d9da746fddc80561641333c.tar.gz
glib-2.0: patch CVE-2025-14087
Pick commits from [1] linked from [2]. [1] https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4933 [2] https://gitlab.gnome.org/GNOME/glib/-/issues/3834 (From OE-Core rev: 6e1ce2de818d647d69f652ab67c0c2d13860e77b) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Yoann Congal <yoann.congal@smile.fr> Signed-off-by: Paul Barker <paul@pbarker.dev> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-01.patch69
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-02.patch240
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-03.patch150
-rw-r--r--meta/recipes-core/glib-2.0/glib-2.0_2.72.3.bb3
4 files changed, 462 insertions, 0 deletions
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-01.patch b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-01.patch
new file mode 100644
index 0000000000..ec7b1fecaa
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-01.patch
@@ -0,0 +1,69 @@
1From 31f82e22e21bae520b7228f7f57d357fb20df8a4 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@gnome.org>
3Date: Tue, 25 Nov 2025 19:02:56 +0000
4Subject: [PATCH] gvariant-parser: Fix potential integer overflow parsing
5 (byte)strings
6
7The termination condition for parsing string and bytestring literals in
8GVariant text format input was subject to an integer overflow for input
9string (or bytestring) literals longer than `INT_MAX`.
10
11Fix that by counting as a `size_t` rather than as an `int`. The counter
12can never correctly be negative.
13
14Spotted by treeplus. Thanks to the Sovereign Tech Resilience programme
15from the Sovereign Tech Agency. ID: #YWH-PGM9867-145
16
17Signed-off-by: Philip Withnall <pwithnall@gnome.org>
18Fixes: #3834
19
20CVE: CVE-2025-14087
21Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/31f82e22e21bae520b7228f7f57d357fb20df8a4]
22Signed-off-by: Peter Marko <peter.marko@siemens.com>
23---
24 glib/gvariant-parser.c | 10 +++++-----
25 1 file changed, 5 insertions(+), 5 deletions(-)
26
27diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
28index 2f1d3db9f..2d6e9856f 100644
29--- a/glib/gvariant-parser.c
30+++ b/glib/gvariant-parser.c
31@@ -594,7 +594,7 @@ ast_resolve (AST *ast,
32 {
33 GVariant *value;
34 gchar *pattern;
35- gint i, j = 0;
36+ size_t i, j = 0;
37
38 pattern = ast_get_pattern (ast, error);
39
40@@ -1555,9 +1555,9 @@ string_free (AST *ast)
41 * No leading/trailing space allowed. */
42 static gboolean
43 unicode_unescape (const gchar *src,
44- gint *src_ofs,
45+ size_t *src_ofs,
46 gchar *dest,
47- gint *dest_ofs,
48+ size_t *dest_ofs,
49 gsize length,
50 SourceRef *ref,
51 GError **error)
52@@ -1618,7 +1618,7 @@ string_parse (TokenStream *stream,
53 gsize length;
54 gchar quote;
55 gchar *str;
56- gint i, j;
57+ size_t i, j;
58
59 token_stream_start_ref (stream, &ref);
60 token = token_stream_get (stream);
61@@ -1748,7 +1748,7 @@ bytestring_parse (TokenStream *stream,
62 gsize length;
63 gchar quote;
64 gchar *str;
65- gint i, j;
66+ size_t i, j;
67
68 token_stream_start_ref (stream, &ref);
69 token = token_stream_get (stream);
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-02.patch b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-02.patch
new file mode 100644
index 0000000000..595f9c1b93
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-02.patch
@@ -0,0 +1,240 @@
1From ac9de0871281cf734f6e269988f90a2521582a08 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@gnome.org>
3Date: Tue, 25 Nov 2025 19:19:16 +0000
4Subject: [PATCH] gvariant-parser: Use size_t to count numbers of child
5 elements
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Rather than using `gint`, which could overflow for arrays (or dicts, or
11tuples) longer than `INT_MAX`. There may be other limits which prevent
12parsed containers becoming that long, but we might as well make the type
13system reflect the programmer’s intention as best it can anyway.
14
15For arrays and tuples this is straightforward. For dictionaries, it’s
16slightly complicated by the fact that the code used
17`dict->n_children == -1` to indicate that the `Dictionary` struct in
18question actually represented a single freestanding dict entry. In
19GVariant text format, that would be `{1, "one"}`.
20
21The implementation previously didn’t define the semantics of
22`dict->n_children < -1`.
23
24Now, instead, change `Dictionary.n_children` to `size_t`, and define a
25magic value `DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY` to indicate that
26the `Dictionary` represents a single freestanding dict entry.
27
28This magic value is `SIZE_MAX`, and given that a dictionary entry takes
29more than one byte to represent in GVariant text format, that means it’s
30not possible to have that many entries in a parsed dictionary, so this
31magic value won’t be hit by a normal dictionary. An assertion checks
32this anyway.
33
34Spotted while working on #3834.
35
36Signed-off-by: Philip Withnall <pwithnall@gnome.org>
37
38CVE: CVE-2025-14087
39Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/ac9de0871281cf734f6e269988f90a2521582a08]
40Signed-off-by: Peter Marko <peter.marko@siemens.com>
41---
42 glib/gvariant-parser.c | 58 ++++++++++++++++++++++++------------------
43 1 file changed, 33 insertions(+), 25 deletions(-)
44
45diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
46index 2d6e9856f..519baa3f3 100644
47--- a/glib/gvariant-parser.c
48+++ b/glib/gvariant-parser.c
49@@ -647,9 +647,9 @@ static AST *parse (TokenStream *stream,
50 GError **error);
51
52 static void
53-ast_array_append (AST ***array,
54- gint *n_items,
55- AST *ast)
56+ast_array_append (AST ***array,
57+ size_t *n_items,
58+ AST *ast)
59 {
60 if ((*n_items & (*n_items - 1)) == 0)
61 *array = g_renew (AST *, *array, *n_items ? 2 ** n_items : 1);
62@@ -658,10 +658,10 @@ ast_array_append (AST ***array,
63 }
64
65 static void
66-ast_array_free (AST **array,
67- gint n_items)
68+ast_array_free (AST **array,
69+ size_t n_items)
70 {
71- gint i;
72+ size_t i;
73
74 for (i = 0; i < n_items; i++)
75 ast_free (array[i]);
76@@ -670,11 +670,11 @@ ast_array_free (AST **array,
77
78 static gchar *
79 ast_array_get_pattern (AST **array,
80- gint n_items,
81+ size_t n_items,
82 GError **error)
83 {
84 gchar *pattern;
85- gint i;
86+ size_t i;
87
88 /* Find the pattern which applies to all children in the array, by l-folding a
89 * coalesce operation.
90@@ -706,7 +706,7 @@ ast_array_get_pattern (AST **array,
91 * pair of values.
92 */
93 {
94- int j = 0;
95+ size_t j = 0;
96
97 while (TRUE)
98 {
99@@ -891,7 +891,7 @@ typedef struct
100 AST ast;
101
102 AST **children;
103- gint n_children;
104+ size_t n_children;
105 } Array;
106
107 static gchar *
108@@ -924,7 +924,7 @@ array_get_value (AST *ast,
109 Array *array = (Array *) ast;
110 const GVariantType *childtype;
111 GVariantBuilder builder;
112- gint i;
113+ size_t i;
114
115 if (!g_variant_type_is_array (type))
116 return ast_type_error (ast, type, error);
117@@ -1010,7 +1010,7 @@ typedef struct
118 AST ast;
119
120 AST **children;
121- gint n_children;
122+ size_t n_children;
123 } Tuple;
124
125 static gchar *
126@@ -1020,7 +1020,7 @@ tuple_get_pattern (AST *ast,
127 Tuple *tuple = (Tuple *) ast;
128 gchar *result = NULL;
129 gchar **parts;
130- gint i;
131+ size_t i;
132
133 parts = g_new (gchar *, tuple->n_children + 4);
134 parts[tuple->n_children + 1] = (gchar *) ")";
135@@ -1050,7 +1050,7 @@ tuple_get_value (AST *ast,
136 Tuple *tuple = (Tuple *) ast;
137 const GVariantType *childtype;
138 GVariantBuilder builder;
139- gint i;
140+ size_t i;
141
142 if (!g_variant_type_is_tuple (type))
143 return ast_type_error (ast, type, error);
144@@ -1242,9 +1242,16 @@ typedef struct
145
146 AST **keys;
147 AST **values;
148- gint n_children;
149+
150+ /* Iff this is DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY then this struct
151+ * represents a single freestanding dict entry (`{1, "one"}`) rather than a
152+ * full dict. In the freestanding case, @keys and @values have exactly one
153+ * member each. */
154+ size_t n_children;
155 } Dictionary;
156
157+#define DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY ((size_t) -1)
158+
159 static gchar *
160 dictionary_get_pattern (AST *ast,
161 GError **error)
162@@ -1259,7 +1266,7 @@ dictionary_get_pattern (AST *ast,
163 return g_strdup ("Ma{**}");
164
165 key_pattern = ast_array_get_pattern (dict->keys,
166- abs (dict->n_children),
167+ (dict->n_children == DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY) ? 1 : dict->n_children,
168 error);
169
170 if (key_pattern == NULL)
171@@ -1290,7 +1297,7 @@ dictionary_get_pattern (AST *ast,
172 return NULL;
173
174 result = g_strdup_printf ("M%s{%c%s}",
175- dict->n_children > 0 ? "a" : "",
176+ (dict->n_children > 0 && dict->n_children != DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY) ? "a" : "",
177 key_char, value_pattern);
178 g_free (value_pattern);
179
180@@ -1304,7 +1311,7 @@ dictionary_get_value (AST *ast,
181 {
182 Dictionary *dict = (Dictionary *) ast;
183
184- if (dict->n_children == -1)
185+ if (dict->n_children == DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY)
186 {
187 const GVariantType *subtype;
188 GVariantBuilder builder;
189@@ -1337,7 +1344,7 @@ dictionary_get_value (AST *ast,
190 {
191 const GVariantType *entry, *key, *val;
192 GVariantBuilder builder;
193- gint i;
194+ size_t i;
195
196 if (!g_variant_type_is_subtype_of (type, G_VARIANT_TYPE_DICTIONARY))
197 return ast_type_error (ast, type, error);
198@@ -1378,12 +1385,12 @@ static void
199 dictionary_free (AST *ast)
200 {
201 Dictionary *dict = (Dictionary *) ast;
202- gint n_children;
203+ size_t n_children;
204
205- if (dict->n_children > -1)
206- n_children = dict->n_children;
207- else
208+ if (dict->n_children == DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY)
209 n_children = 1;
210+ else
211+ n_children = dict->n_children;
212
213 ast_array_free (dict->keys, n_children);
214 ast_array_free (dict->values, n_children);
215@@ -1401,7 +1408,7 @@ dictionary_parse (TokenStream *stream,
216 maybe_wrapper, dictionary_get_value,
217 dictionary_free
218 };
219- gint n_keys, n_values;
220+ size_t n_keys, n_values;
221 gboolean only_one;
222 Dictionary *dict;
223 AST *first;
224@@ -1444,7 +1451,7 @@ dictionary_parse (TokenStream *stream,
225 goto error;
226
227 g_assert (n_keys == 1 && n_values == 1);
228- dict->n_children = -1;
229+ dict->n_children = DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY;
230
231 return (AST *) dict;
232 }
233@@ -1477,6 +1484,7 @@ dictionary_parse (TokenStream *stream,
234 }
235
236 g_assert (n_keys == n_values);
237+ g_assert (n_keys != DICTIONARY_N_CHILDREN_FREESTANDING_ENTRY);
238 dict->n_children = n_keys;
239
240 return (AST *) dict;
diff --git a/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-03.patch b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-03.patch
new file mode 100644
index 0000000000..4a474f39fc
--- /dev/null
+++ b/meta/recipes-core/glib-2.0/glib-2.0/CVE-2025-14087-03.patch
@@ -0,0 +1,150 @@
1From acaabfedff42e974334dd5368e6103d2845aaba6 Mon Sep 17 00:00:00 2001
2From: Philip Withnall <pwithnall@gnome.org>
3Date: Tue, 25 Nov 2025 19:25:58 +0000
4Subject: [PATCH] gvariant-parser: Convert error handling code to use size_t
5
6The error handling code allows for printing out the range of input bytes
7related to a parsing error. This was previously done using `gint`, but
8the input could be longer than `INT_MAX`, so it should really be done
9using `size_t`.
10
11Spotted while working on #3834.
12
13Signed-off-by: Philip Withnall <pwithnall@gnome.org>
14
15CVE: CVE-2025-14087
16Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/acaabfedff42e974334dd5368e6103d2845aaba6]
17Signed-off-by: Peter Marko <peter.marko@siemens.com>
18---
19 glib/gvariant-parser.c | 36 +++++++++++++++++++++++-------------
20 1 file changed, 23 insertions(+), 13 deletions(-)
21
22diff --git a/glib/gvariant-parser.c b/glib/gvariant-parser.c
23index 519baa3f3..1b1ddd654 100644
24--- a/glib/gvariant-parser.c
25+++ b/glib/gvariant-parser.c
26@@ -88,7 +88,9 @@ g_variant_parser_get_error_quark (void)
27
28 typedef struct
29 {
30- gint start, end;
31+ /* Offsets from the start of the input, in bytes. Can be equal when referring
32+ * to a point rather than a range. The invariant `end >= start` always holds. */
33+ size_t start, end;
34 } SourceRef;
35
36 G_GNUC_PRINTF(5, 0)
37@@ -103,14 +105,16 @@ parser_set_error_va (GError **error,
38 GString *msg = g_string_new (NULL);
39
40 if (location->start == location->end)
41- g_string_append_printf (msg, "%d", location->start);
42+ g_string_append_printf (msg, "%" G_GSIZE_FORMAT, location->start);
43 else
44- g_string_append_printf (msg, "%d-%d", location->start, location->end);
45+ g_string_append_printf (msg, "%" G_GSIZE_FORMAT "-%" G_GSIZE_FORMAT,
46+ location->start, location->end);
47
48 if (other != NULL)
49 {
50 g_assert (other->start != other->end);
51- g_string_append_printf (msg, ",%d-%d", other->start, other->end);
52+ g_string_append_printf (msg, ",%" G_GSIZE_FORMAT "-%" G_GSIZE_FORMAT,
53+ other->start, other->end);
54 }
55 g_string_append_c (msg, ':');
56
57@@ -137,11 +141,15 @@ parser_set_error (GError **error,
58
59 typedef struct
60 {
61+ /* We should always have the following ordering constraint:
62+ * start <= this <= stream <= end
63+ * Additionally, unless in an error or EOF state, `this < stream`.
64+ */
65 const gchar *start;
66 const gchar *stream;
67 const gchar *end;
68
69- const gchar *this;
70+ const gchar *this; /* (nullable) */
71 } TokenStream;
72
73
74@@ -172,7 +180,7 @@ token_stream_set_error (TokenStream *stream,
75 static gboolean
76 token_stream_prepare (TokenStream *stream)
77 {
78- gint brackets = 0;
79+ gssize brackets = 0;
80 const gchar *end;
81
82 if (stream->this != NULL)
83@@ -402,7 +410,7 @@ static void
84 pattern_copy (gchar **out,
85 const gchar **in)
86 {
87- gint brackets = 0;
88+ gssize brackets = 0;
89
90 while (**in == 'a' || **in == 'm' || **in == 'M')
91 *(*out)++ = *(*in)++;
92@@ -2666,7 +2674,7 @@ g_variant_builder_add_parsed (GVariantBuilder *builder,
93 static gboolean
94 parse_num (const gchar *num,
95 const gchar *limit,
96- guint *result)
97+ size_t *result)
98 {
99 gchar *endptr;
100 gint64 bignum;
101@@ -2676,10 +2684,12 @@ parse_num (const gchar *num,
102 if (endptr != limit)
103 return FALSE;
104
105+ /* The upper bound here is more restrictive than it technically needs to be,
106+ * but should be enough for any practical situation: */
107 if (bignum < 0 || bignum > G_MAXINT)
108 return FALSE;
109
110- *result = (guint) bignum;
111+ *result = (size_t) bignum;
112
113 return TRUE;
114 }
115@@ -2690,7 +2700,7 @@ add_last_line (GString *err,
116 {
117 const gchar *last_nl;
118 gchar *chomped;
119- gint i;
120+ size_t i;
121
122 /* This is an error at the end of input. If we have a file
123 * with newlines, that's probably the empty string after the
124@@ -2835,7 +2845,7 @@ g_variant_parse_error_print_context (GError *error,
125
126 if (dash == NULL || colon < dash)
127 {
128- guint point;
129+ size_t point;
130
131 /* we have a single point */
132 if (!parse_num (error->message, colon, &point))
133@@ -2853,7 +2863,7 @@ g_variant_parse_error_print_context (GError *error,
134 /* We have one or two ranges... */
135 if (comma && comma < colon)
136 {
137- guint start1, end1, start2, end2;
138+ size_t start1, end1, start2, end2;
139 const gchar *dash2;
140
141 /* Two ranges */
142@@ -2869,7 +2879,7 @@ g_variant_parse_error_print_context (GError *error,
143 }
144 else
145 {
146- guint start, end;
147+ size_t start, end;
148
149 /* One range */
150 if (!parse_num (error->message, dash, &start) || !parse_num (dash + 1, colon, &end))
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 1c4c21614a..c5704a27bc 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
@@ -66,6 +66,9 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
66 file://CVE-2025-7039-02.patch \ 66 file://CVE-2025-7039-02.patch \
67 file://CVE-2025-13601-01.patch \ 67 file://CVE-2025-13601-01.patch \
68 file://CVE-2025-13601-02.patch \ 68 file://CVE-2025-13601-02.patch \
69 file://CVE-2025-14087-01.patch \
70 file://CVE-2025-14087-02.patch \
71 file://CVE-2025-14087-03.patch \
69 " 72 "
70SRC_URI:append:class-native = " file://relocate-modules.patch" 73SRC_URI:append:class-native = " file://relocate-modules.patch"
71 74