Skip to content

Commit d7b8822

Browse files
[AUTO-CHERRYPICK] Add patch to package qt5-qtbase to address CVE-2022-25643 - branch main (#8588)
Co-authored-by: Alberto Perez <aperezguevar@microsoft.com>
1 parent b8f18fa commit d7b8822

2 files changed

Lines changed: 114 additions & 1 deletion

File tree

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
2+
index a20a274870..30ef0625db 100644
3+
--- a/src/corelib/io/qlockfile_win.cpp
4+
+++ b/src/corelib/io/qlockfile_win.cpp
5+
@@ -48,6 +48,8 @@
6+
#include "QtCore/qdebug.h"
7+
#include "QtCore/qthread.h"
8+
9+
+#include "private/qsystemlibrary_p.h"
10+
+
11+
QT_BEGIN_NAMESPACE
12+
13+
static inline bool fileExists(const wchar_t *fileName)
14+
@@ -150,7 +152,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
15+
#if !defined(Q_OS_WINRT)
16+
typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
17+
18+
- HMODULE hPsapi = LoadLibraryA("psapi");
19+
+ HMODULE hPsapi = QSystemLibrary::load(L"psapi");
20+
if (!hPsapi)
21+
return QString();
22+
GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>(
23+
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
24+
index 4e84c0954b..a2f1133bc0 100644
25+
--- a/src/network/kernel/qauthenticator.cpp
26+
+++ b/src/network/kernel/qauthenticator.cpp
27+
@@ -50,6 +50,7 @@
28+
#include <qstring.h>
29+
#include <qdatetime.h>
30+
#include <qrandom.h>
31+
+#include "private/qsystemlibrary_p.h"
32+
33+
#ifdef Q_OS_WIN
34+
#include <qmutex.h>
35+
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
36+
index 65b3e7f430..ff04fbbf98 100644
37+
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
38+
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
39+
@@ -48,6 +48,7 @@
40+
#include <qpa/qplatformnativeinterface.h>
41+
#include <QtPlatformHeaders/qwglnativecontext.h>
42+
43+
+#include <private/qsystemlibrary_p.h>
44+
#include <algorithm>
45+
46+
#include <wingdi.h>
47+
@@ -162,19 +163,25 @@ QFunctionPointer QWindowsOpengl32DLL::resolve(const char *name)
48+
49+
bool QWindowsOpengl32DLL::init(bool softwareRendering)
50+
{
51+
- const QByteArray opengl32 = QByteArrayLiteral("opengl32.dll");
52+
- const QByteArray swopengl = QByteArrayLiteral("opengl32sw.dll");
53+
+ const QByteArray opengl32 = QByteArrayLiteral("opengl32");
54+
+ const QByteArray swopengl = QByteArrayLiteral("opengl32sw");
55+
+ bool useSystemLib = false;
56+
57+
QByteArray openglDll = qgetenv("QT_OPENGL_DLL");
58+
- if (openglDll.isEmpty())
59+
+ if (openglDll.isEmpty()) {
60+
openglDll = softwareRendering ? swopengl : opengl32;
61+
+ useSystemLib = !softwareRendering;
62+
+ }
63+
64+
openglDll = openglDll.toLower();
65+
m_nonOpengl32 = openglDll != opengl32;
66+
67+
qCDebug(lcQpaGl) << "Qt: Using WGL and OpenGL from" << openglDll;
68+
69+
- m_lib = ::LoadLibraryA(openglDll.constData());
70+
+ if (useSystemLib)
71+
+ m_lib = QSystemLibrary::load((wchar_t*)(QString::fromLatin1(openglDll).utf16()));
72+
+ else
73+
+ m_lib = LoadLibraryA(openglDll.constData());
74+
if (!m_lib) {
75+
qErrnoWarning(::GetLastError(), "Failed to load %s", openglDll.constData());
76+
return false;
77+
@@ -184,7 +191,7 @@ bool QWindowsOpengl32DLL::init(bool softwareRendering)
78+
// Load opengl32.dll always. GDI functions like ChoosePixelFormat do
79+
// GetModuleHandle for opengl32.dll and behave differently (and call back into
80+
// opengl32) when the module is present. This is fine for dummy contexts and windows.
81+
- ::LoadLibraryA("opengl32.dll");
82+
+ QSystemLibrary::load(L"opengl32");
83+
}
84+
85+
wglCreateContext = reinterpret_cast<HGLRC (WINAPI *)(HDC)>(resolve("wglCreateContext"));
86+
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
87+
index 49da6ee3e3..d78a18b35d 100644
88+
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
89+
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
90+
@@ -49,6 +49,7 @@
91+
#include <QtCore/qstandardpaths.h>
92+
#include <QtCore/qlibraryinfo.h>
93+
#include <QtCore/qhash.h>
94+
+#include <private/qsystemlibrary_p.h>
95+
96+
#ifndef QT_NO_OPENGL
97+
#include <private/qopengl_p.h>
98+
@@ -396,7 +397,7 @@ bool QWindowsOpenGLTester::testDesktopGL()
99+
100+
// Test #1: Load opengl32.dll and try to resolve an OpenGL 2 function.
101+
// This will typically fail on systems that do not have a real OpenGL driver.
102+
- lib = LoadLibraryA("opengl32.dll");
103+
+ lib = QSystemLibrary::load(L"opengl32");
104+
if (lib) {
105+
CreateContext = reinterpret_cast<CreateContextType>(
106+
reinterpret_cast<QFunctionPointer>(::GetProcAddress(lib, "wglCreateContext")));

SPECS/qt5-qtbase/qt5-qtbase.spec

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
Name: qt5-qtbase
3434
Summary: Qt5 - QtBase components
3535
Version: 5.12.11
36-
Release: 11%{?dist}
36+
Release: 12%{?dist}
3737
# See LICENSE.GPL3-EXCEPT.txt, for exception details
3838
License: GFDL AND LGPLv3 AND GPLv2 AND GPLv3 with exceptions AND QT License Agreement 4.0
3939
Vendor: Microsoft Corporation
@@ -156,6 +156,9 @@ Patch88: CVE-2023-51714.patch
156156
# - https://code.qt.io/cgit/qt/qtbase.git/commit/?id=cca8ed0547405b1c
157157
Patch89: CVE-2021-38593.patch
158158

159+
# Fix CVE-2022-25643
160+
Patch90: CVE-2022-25643.patch
161+
159162
# Do not check any files in %%{_qt5_plugindir}/platformthemes/ for requires.
160163
# Those themes are there for platform integration. If the required libraries are
161164
# not there, the platform to integrate with isn't either. Then Qt will just
@@ -266,6 +269,7 @@ Qt5 libraries used for drawing widgets and OpenGL items.
266269
%patch87 -p1
267270
%patch88 -p1
268271
%patch89 -p1
272+
%patch90 -p1
269273

270274
## upstream patches
271275

@@ -771,6 +775,9 @@ fi
771775
%{_qt5_libdir}/cmake/Qt5Gui/Qt5Gui_QXdgDesktopPortalThemePlugin.cmake
772776

773777
%changelog
778+
* Wed Mar 27 2024 Alberto David Perez Guevara <aperezguevar@microsoft.com> - 5.12.11-12
779+
- Add patch to resolve CVE-2022-25643.
780+
774781
* Thu Feb 15 2024 Sumedh Sharma <sumsharma@microsoft.com> - 5.12.11-11
775782
- Add patch to resolve CVE-2021-38593, used Ubuntu's patch for guidance.
776783

0 commit comments

Comments
 (0)