Skip to content

Commit fd311cc

Browse files
authored
[Medium] Patch mysql for CVE-2025-0838 and updated patch for CVE-2024-2410 (#15874)
1 parent 84695f2 commit fd311cc

3 files changed

Lines changed: 207 additions & 21 deletions

File tree

SPECS/mysql/CVE-2024-2410.patch

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ Date: Fri, 13 Oct 2023 15:20:54 -0700
44
Subject: [PATCH] Internal change
55

66
PiperOrigin-RevId: 573332237
7+
8+
Upstream Patch Reference: https://github.com/protocolbuffers/protobuf/commit/b955165ebdcc5a8ba9c267230d6305f4e3d9c118.patch
79
---
810
.../protobuf/io/test_zero_copy_stream.h | 22 ++++++++++++-------
9-
src/google/protobuf/json/BUILD.bazel | 1 +
10-
src/google/protobuf/json/internal/parser.cc | 2 +-
11-
src/google/protobuf/json/json_test.cc | 20 +++++++++++++++++
11+
.../src/google/protobuf/json/BUILD.bazel | 1 +
12+
.../google/protobuf/json/internal/parser.cc | 2 +-
13+
.../src/google/protobuf/json/json_test.cc | 20 +++++++++++++++++
1214
4 files changed, 36 insertions(+), 9 deletions(-)
1315

14-
diff --git a/src/google/protobuf/io/test_zero_copy_stream.h b/src/google/protobuf/io/test_zero_copy_stream.h
15-
index 4c5a06db400e..1a56d7038c96 100644
16+
diff --git a/extra/protobuf/protobuf-24.4/src/google/protobuf/io/test_zero_copy_stream.h b/extra/protobuf/protobuf-24.4/src/google/protobuf/io/test_zero_copy_stream.h
17+
index db2c87ad..06fb8d84 100644
1618
--- a/extra/protobuf/protobuf-24.4/src/google/protobuf/io/test_zero_copy_stream.h
1719
+++ b/extra/protobuf/protobuf-24.4/src/google/protobuf/io/test_zero_copy_stream.h
18-
@@ -9,12 +9,12 @@
20+
@@ -32,12 +32,12 @@
1921
#define GOOGLE_PROTOBUF_IO_TEST_ZERO_COPY_STREAM_H__
2022

2123
#include <deque>
@@ -29,7 +31,7 @@ index 4c5a06db400e..1a56d7038c96 100644
2931
#include "google/protobuf/io/zero_copy_stream.h"
3032

3133
// Must be included last.
32-
@@ -37,18 +37,22 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream {
34+
@@ -60,18 +60,22 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream {
3335
TestZeroCopyInputStream(const TestZeroCopyInputStream& other)
3436
: ZeroCopyInputStream(),
3537
buffers_(other.buffers_),
@@ -55,7 +57,7 @@ index 4c5a06db400e..1a56d7038c96 100644
5557
buffers_.pop_front();
5658
*data = last_returned_buffer_->data();
5759
*size = static_cast<int>(last_returned_buffer_->size());
58-
@@ -58,19 +62,19 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream {
60+
@@ -81,19 +85,19 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream {
5961

6062
void BackUp(int count) override {
6163
ABSL_CHECK_GE(count, 0) << "count must not be negative";
@@ -78,7 +80,7 @@ index 4c5a06db400e..1a56d7038c96 100644
7880
while (true) {
7981
if (count == 0) return true;
8082
if (buffers_.empty()) return false;
81-
@@ -96,7 +100,9 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream {
83+
@@ -119,7 +123,9 @@ class TestZeroCopyInputStream final : public ZeroCopyInputStream {
8284
// move them to `last_returned_buffer_`. It makes it simpler to keep track of
8385
// the state of the object. The extra cost is not relevant for testing.
8486
std::deque<std::string> buffers_;
@@ -89,8 +91,8 @@ index 4c5a06db400e..1a56d7038c96 100644
8991
int64_t byte_count_ = 0;
9092
};
9193

92-
diff --git a/src/google/protobuf/json/BUILD.bazel b/src/google/protobuf/json/BUILD.bazel
93-
index dece74e4d0f0..6ec8184e0e09 100644
94+
diff --git a/extra/protobuf/protobuf-24.4/src/google/protobuf/json/BUILD.bazel b/extra/protobuf/protobuf-24.4/src/google/protobuf/json/BUILD.bazel
95+
index d6019f93..22c8802a 100644
9496
--- a/extra/protobuf/protobuf-24.4/src/google/protobuf/json/BUILD.bazel
9597
+++ b/extra/protobuf/protobuf-24.4/src/google/protobuf/json/BUILD.bazel
9698
@@ -41,6 +41,7 @@ cc_test(
@@ -101,11 +103,11 @@ index dece74e4d0f0..6ec8184e0e09 100644
101103
"//src/google/protobuf/util:json_format_cc_proto",
102104
"//src/google/protobuf/util:json_format_proto3_cc_proto",
103105
"//src/google/protobuf/util:type_resolver_util",
104-
diff --git a/src/google/protobuf/json/internal/parser.cc b/src/google/protobuf/json/internal/parser.cc
105-
index 17e8fcc07c42..fbf492afa715 100644
106+
diff --git a/extra/protobuf/protobuf-24.4/src/google/protobuf/json/internal/parser.cc b/extra/protobuf/protobuf-24.4/src/google/protobuf/json/internal/parser.cc
107+
index af12372d..3cffba52 100644
106108
--- a/extra/protobuf/protobuf-24.4/src/google/protobuf/json/internal/parser.cc
107109
+++ b/extra/protobuf/protobuf-24.4/src/google/protobuf/json/internal/parser.cc
108-
@@ -1273,7 +1273,7 @@ absl::Status ParseMessage(JsonLexer& lex, const Desc<Traits>& desc,
110+
@@ -1296,7 +1296,7 @@ absl::Status ParseMessage(JsonLexer& lex, const Desc<Traits>& desc,
109111
}
110112
}
111113

@@ -114,27 +116,27 @@ index 17e8fcc07c42..fbf492afa715 100644
114116
});
115117
}
116118
} // namespace
117-
diff --git a/src/google/protobuf/json/json_test.cc b/src/google/protobuf/json/json_test.cc
118-
index 48379ceeb5f9..2ff1e87a90fe 100644
119+
diff --git a/extra/protobuf/protobuf-24.4/src/google/protobuf/json/json_test.cc b/extra/protobuf/protobuf-24.4/src/google/protobuf/json/json_test.cc
120+
index 88f7e6d5..c2ba0b8e 100644
119121
--- a/extra/protobuf/protobuf-24.4/src/google/protobuf/json/json_test.cc
120122
+++ b/extra/protobuf/protobuf-24.4/src/google/protobuf/json/json_test.cc
121-
@@ -26,6 +26,7 @@
123+
@@ -49,6 +49,7 @@
122124
#include "absl/strings/string_view.h"
123125
#include "google/protobuf/descriptor_database.h"
124126
#include "google/protobuf/dynamic_message.h"
125127
+#include "google/protobuf/io/test_zero_copy_stream.h"
126128
#include "google/protobuf/io/zero_copy_stream.h"
127129
#include "google/protobuf/io/zero_copy_stream_impl_lite.h"
128130
#include "google/protobuf/util/json_format.pb.h"
129-
@@ -50,6 +51,7 @@ using ::proto3::TestMap;
131+
@@ -73,6 +74,7 @@ using ::proto3::TestMap;
130132
using ::proto3::TestMessage;
131133
using ::proto3::TestOneof;
132134
using ::proto3::TestWrapper;
133135
+using ::testing::ContainsRegex;
134136
using ::testing::ElementsAre;
135137
using ::testing::IsEmpty;
136138
using ::testing::Not;
137-
@@ -1331,6 +1333,24 @@ TEST_P(JsonTest, ClearPreExistingRepeatedInJsonValues) {
139+
@@ -1354,6 +1356,24 @@ TEST_P(JsonTest, ClearPreExistingRepeatedInJsonValues) {
138140
EXPECT_THAT(s.fields(), IsEmpty());
139141
}
140142

@@ -159,4 +161,6 @@ index 48379ceeb5f9..2ff1e87a90fe 100644
159161
} // namespace
160162
} // namespace json
161163
} // namespace protobuf
162-
164+
--
165+
2.45.4
166+

SPECS/mysql/CVE-2025-0838.patch

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
From 5a0e2cb5e3958dd90bb8569a2766622cb74d90c1 Mon Sep 17 00:00:00 2001
2+
From: Derek Mauro <dmauro@google.com>
3+
Date: Thu, 23 Jan 2025 06:33:43 -0800
4+
Subject: [PATCH] Fix potential integer overflow in hash container
5+
create/resize
6+
7+
The sized constructors, reserve(), and rehash() methods of
8+
absl::{flat,node}_hash_{set,map} did not impose an upper bound on
9+
their size argument. As a result, it was possible for a caller to pass
10+
a very large size that would cause an integer overflow when computing
11+
the size of the container's backing store. Subsequent accesses to the
12+
container might then access out-of-bounds memory.
13+
14+
The fix is in two parts:
15+
16+
1) Update max_size() to return the maximum number of items that can be
17+
stored in the container
18+
19+
2) Validate the size arguments to the constructors, reserve(), and
20+
rehash() methods, and abort the program when the argument is invalid
21+
22+
We've looked at uses of these containers in Google codebases like
23+
Chrome, and determined this vulnerability is likely to be difficult to
24+
exploit. This is primarily because container sizes are rarely
25+
attacker-controlled.
26+
27+
The bug was discovered by Dmitry Vyukov <dvyukov@google.com>.
28+
29+
PiperOrigin-RevId: 718841870
30+
Change-Id: Ic09dc9de140a35dbb45ab9d90f58383cf2de8286
31+
32+
Upstream Patch Reference: https://github.com/abseil/abseil-cpp/commit/5a0e2cb5e3958dd90bb8569a2766622cb74d90c1.patch
33+
---
34+
.../absl/container/internal/raw_hash_set.cc | 5 +++
35+
.../absl/container/internal/raw_hash_set.h | 36 ++++++++++++++++++-
36+
.../container/internal/raw_hash_set_test.cc | 8 +++++
37+
3 files changed, 48 insertions(+), 1 deletion(-)
38+
39+
diff --git a/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.cc b/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.cc
40+
index 2ff95b61..58a516b6 100644
41+
--- a/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.cc
42+
+++ b/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.cc
43+
@@ -23,6 +23,7 @@
44+
#include "absl/base/config.h"
45+
#include "absl/base/dynamic_annotations.h"
46+
#include "absl/hash/hash.h"
47+
+#include "absl/base/internal/raw_logging.h"
48+
49+
namespace absl {
50+
ABSL_NAMESPACE_BEGIN
51+
@@ -258,6 +259,10 @@ void ClearBackingArray(CommonFields& c, const PolicyFunctions& policy,
52+
}
53+
}
54+
55+
+void HashTableSizeOverflow() {
56+
+ ABSL_RAW_LOG(FATAL, "Hash table size overflow");
57+
+}
58+
+
59+
} // namespace container_internal
60+
ABSL_NAMESPACE_END
61+
} // namespace absl
62+
diff --git a/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.h b/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.h
63+
index 5f89d8ef..ba2d98d8 100644
64+
--- a/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.h
65+
+++ b/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set.h
66+
@@ -236,6 +236,15 @@ namespace container_internal {
67+
#define ABSL_SWISSTABLE_ENABLE_GENERATIONS
68+
#endif
69+
70+
+#ifdef ABSL_SWISSTABLE_ASSERT
71+
+#error ABSL_SWISSTABLE_ASSERT cannot be directly set
72+
+#else
73+
+// We use this macro for assertions that users may see when the table is in an
74+
+// invalid state that sanitizers may help diagnose.
75+
+#define ABSL_SWISSTABLE_ASSERT(CONDITION) \
76+
+ assert((CONDITION) && "Try enabling sanitizers.")
77+
+#endif
78+
+
79+
// We use uint8_t so we don't need to worry about padding.
80+
using GenerationType = uint8_t;
81+
82+
@@ -939,6 +948,9 @@ inline size_t SlotOffset(size_t capacity, size_t slot_align) {
83+
// Given the capacity of a table, computes the total size of the backing
84+
// array.
85+
inline size_t AllocSize(size_t capacity, size_t slot_size, size_t slot_align) {
86+
+ ABSL_SWISSTABLE_ASSERT(
87+
+ slot_size <=
88+
+ ((std::numeric_limits<size_t>::max)() - SlotOffset(capacity, slot_align)) / capacity);
89+
return SlotOffset(capacity, slot_align) + capacity * slot_size;
90+
}
91+
92+
@@ -1076,6 +1088,15 @@ inline size_t NormalizeCapacity(size_t n) {
93+
return n ? ~size_t{} >> countl_zero(n) : 1;
94+
}
95+
96+
+template <size_t kSlotSize>
97+
+size_t MaxValidCapacity() {
98+
+ return NormalizeCapacity((std::numeric_limits<size_t>::max)() / 4 /
99+
+ kSlotSize);
100+
+}
101+
+
102+
+// Use a non-inlined function to avoid code bloat.
103+
+[[noreturn]] void HashTableSizeOverflow();
104+
+
105+
// General notes on capacity/growth methods below:
106+
// - We use 7/8th as maximum load factor. For 16-wide groups, that gives an
107+
// average of two empty slots per group.
108+
@@ -1717,6 +1738,10 @@ class raw_hash_set {
109+
const allocator_type& alloc = allocator_type())
110+
: settings_(CommonFields{}, hash, eq, alloc) {
111+
if (bucket_count) {
112+
+ if (ABSL_PREDICT_FALSE(bucket_count >
113+
+ MaxValidCapacity<sizeof(slot_type)>())) {
114+
+ HashTableSizeOverflow();
115+
+ }
116+
common().set_capacity(NormalizeCapacity(bucket_count));
117+
initialize_slots();
118+
}
119+
@@ -1916,7 +1941,9 @@ class raw_hash_set {
120+
bool empty() const { return !size(); }
121+
size_t size() const { return common().size(); }
122+
size_t capacity() const { return common().capacity(); }
123+
- size_t max_size() const { return (std::numeric_limits<size_t>::max)(); }
124+
+ size_t max_size() const {
125+
+ return CapacityToGrowth(MaxValidCapacity<sizeof(slot_type)>());
126+
+ }
127+
128+
ABSL_ATTRIBUTE_REINITIALIZES void clear() {
129+
// Iterating over this container is O(bucket_count()). When bucket_count()
130+
@@ -2266,6 +2293,9 @@ class raw_hash_set {
131+
auto m = NormalizeCapacity(n | GrowthToLowerboundCapacity(size()));
132+
// n == 0 unconditionally rehashes as per the standard.
133+
if (n == 0 || m > capacity()) {
134+
+ if (ABSL_PREDICT_FALSE(m > MaxValidCapacity<sizeof(slot_type)>())) {
135+
+ HashTableSizeOverflow();
136+
+ }
137+
resize(m);
138+
139+
// This is after resize, to ensure that we have completed the allocation
140+
@@ -2276,6 +2306,9 @@ class raw_hash_set {
141+
142+
void reserve(size_t n) {
143+
if (n > size() + growth_left()) {
144+
+ if (ABSL_PREDICT_FALSE(n > max_size())) {
145+
+ HashTableSizeOverflow();
146+
+ }
147+
size_t m = GrowthToLowerboundCapacity(n);
148+
resize(NormalizeCapacity(m));
149+
150+
@@ -2882,5 +2915,6 @@ ABSL_NAMESPACE_END
151+
} // namespace absl
152+
153+
#undef ABSL_SWISSTABLE_ENABLE_GENERATIONS
154+
+#undef ABSL_SWISSTABLE_ASSERT
155+
156+
#endif // ABSL_CONTAINER_INTERNAL_RAW_HASH_SET_H_
157+
diff --git a/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set_test.cc b/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set_test.cc
158+
index 242a97cb..d5d5f393 100644
159+
--- a/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set_test.cc
160+
+++ b/extra/abseil/abseil-cpp-20230802.1/absl/container/internal/raw_hash_set_test.cc
161+
@@ -2510,6 +2510,14 @@ TEST(Iterator, InvalidComparisonDifferentTables) {
162+
"Invalid iterator comparison.*non-end");
163+
}
164+
165+
+TEST(Table, MaxSizeOverflow) {
166+
+ size_t overflow = (std::numeric_limits<size_t>::max)();
167+
+ EXPECT_DEATH_IF_SUPPORTED(IntTable t(overflow), "Hash table size overflow");
168+
+ IntTable t;
169+
+ EXPECT_DEATH_IF_SUPPORTED(t.reserve(overflow), "Hash table size overflow");
170+
+ EXPECT_DEATH_IF_SUPPORTED(t.rehash(overflow), "Hash table size overflow");
171+
+}
172+
+
173+
} // namespace
174+
} // namespace container_internal
175+
ABSL_NAMESPACE_END
176+
--
177+
2.45.4
178+

SPECS/mysql/mysql.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: MySQL.
22
Name: mysql
33
Version: 8.0.45
4-
Release: 2%{?dist}
4+
Release: 3%{?dist}
55
License: GPLv2 with exceptions AND LGPLv2 AND BSD
66
Vendor: Microsoft Corporation
77
Distribution: Mariner
@@ -16,6 +16,7 @@ Patch1: CVE-2024-2410.patch
1616
Patch2: fix-tests-for-unsupported-chacha-ciphers.patch
1717
Patch3: CVE-2025-62813.patch
1818
Patch4: CVE-2026-0994.patch
19+
Patch5: CVE-2025-0838.patch
1920
BuildRequires: cmake
2021
BuildRequires: libtirpc-devel
2122
BuildRequires: openssl-devel
@@ -116,6 +117,9 @@ fi
116117
%{_libdir}/pkgconfig/mysqlclient.pc
117118

118119
%changelog
120+
* Mon Feb 16 2026 Aditya Singh <v-aditysing@microsoft.com> - 8.0.45-3
121+
- Patch for CVE-2025-0838
122+
119123
* Mon Feb 09 2026 Jyoti Kanase <v-jykanase@microsoft.com> - 8.0.45-2
120124
- Patch for CVE-2026-0994
121125

0 commit comments

Comments
 (0)