public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtcore/files/, dev-qt/qtcore/
Date: Sun, 26 Jun 2022 08:25:21 +0000 (UTC)	[thread overview]
Message-ID: <1656231913.cb10b0356e62b2521c0d4592a35b5dfb6e5cd2ca.sam@gentoo> (raw)

commit:     cb10b0356e62b2521c0d4592a35b5dfb6e5cd2ca
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 26 08:22:31 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun 26 08:25:13 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cb10b035

dev-qt/qtcore: backport FORTIFY_SOURCE=3 patch

GCC 12 is now in ~arch and we're likely to get more people trying
out F_S=3 as a result. This patch is now in Qt5PatchCollection
and given the previous workaround ended up being insufficient
(it's not enough to force F_S=2 in qtcore, as reverse deps
end up being broken if _they_ are built with F_S=3, even
though the cause is in qtcore), let's backport the fix now.

Bug: https://bugs.gentoo.org/847145
Closes: https://bugs.gentoo.org/852974
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/qtcore-5.15.5-fortify-source-3.patch     |  61 ++++++++++++
 dev-qt/qtcore/qtcore-5.15.5-r1.ebuild              | 102 +++++++++++++++++++++
 2 files changed, 163 insertions(+)

diff --git a/dev-qt/qtcore/files/qtcore-5.15.5-fortify-source-3.patch b/dev-qt/qtcore/files/qtcore-5.15.5-fortify-source-3.patch
new file mode 100644
index 000000000000..1be46b496cf9
--- /dev/null
+++ b/dev-qt/qtcore/files/qtcore-5.15.5-fortify-source-3.patch
@@ -0,0 +1,61 @@
+https://invent.kde.org/qt/qt/qtbase/-/commit/6d3d164bec17876f5b24ae9102767ef1236aa37b
+
+From 6d3d164bec17876f5b24ae9102767ef1236aa37b Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Mon, 20 Jun 2022 20:35:12 +0100
+Subject: [PATCH] QArrayData: fix UB via reinterpret_cast (crash with
+ FORTIFY_SOURCE=3)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+FORTIFY_SOURCE=3 is a new level of FORTIFY_SOURCE available with GCC 12+.
+
+With Qt 5.15, it ends up triggering UB in the pointer arithmetic
+in QArrayData which breaks various FOSS applications using qtcore.
+
+Qt upstream fixed this independently for 6.x (in at least
+eab6eb64d2fab21c4791738323ca7d670a907de1) but did so at the same time as
+various internal changes and hence is not appropriate for cherry-picking to 5.15.x.
+
+I reported the issue to Qt (QTBUG-103782) and they've created a fix for 5.15 which
+is not yet public but based on the description in the bug, should be functionally
+the same as this. They have not backported the intrusive internal changes
+from 6.x.
+
+Originally grabbed from https://build.opensuse.org/package/view_file/KDE:Qt:5.15/libqt5-qtbase/mitigate-FORTIFY_SOURCE-3.patch.
+
+Bug: https://bugs.gentoo.org/847145
+Bug: https://bugs.gentoo.org/852974
+Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104964
+Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105709
+Task-number: QTBUG-103782
+Thanks-to: Martin Liška <mliska@suse.cz>
+--- a/src/corelib/tools/qarraydata.h
++++ b/src/corelib/tools/qarraydata.h
+@@ -42,6 +42,7 @@
+ 
+ #include <QtCore/qrefcount.h>
+ #include <string.h>
++#include <cstdint>
+ 
+ QT_BEGIN_NAMESPACE
+ 
+@@ -58,14 +59,14 @@ struct Q_CORE_EXPORT QArrayData
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     const void *data() const
+     {
+         Q_ASSERT(size == 0
+                 || offset < 0 || size_t(offset) >= sizeof(QArrayData));
+-        return reinterpret_cast<const char *>(this) + offset;
++        return reinterpret_cast<void *> (reinterpret_cast<uintptr_t>(this) + offset);
+     }
+ 
+     // This refers to array data mutability, not "header data" represented by
+GitLab

diff --git a/dev-qt/qtcore/qtcore-5.15.5-r1.ebuild b/dev-qt/qtcore/qtcore-5.15.5-r1.ebuild
new file mode 100644
index 000000000000..c2235698ecbf
--- /dev/null
+++ b/dev-qt/qtcore/qtcore-5.15.5-r1.ebuild
@@ -0,0 +1,102 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+QT5_KDEPATCHSET_REV=1
+QT5_MODULE="qtbase"
+inherit linux-info qt5-build
+
+DESCRIPTION="Cross-platform application development framework"
+SLOT=5/${QT5_PV}
+
+if [[ ${QT5_BUILD_TYPE} == release ]]; then
+	KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~sparc ~x86"
+fi
+
+IUSE="icu old-kernel systemd"
+
+DEPEND="
+	dev-libs/double-conversion:=
+	dev-libs/glib:2
+	dev-libs/libpcre2[pcre16,unicode]
+	sys-libs/zlib:=
+	icu? ( dev-libs/icu:= )
+	!icu? ( virtual/libiconv )
+	systemd? ( sys-apps/systemd:= )
+"
+RDEPEND="${DEPEND}"
+
+QT5_TARGET_SUBDIRS=(
+	src/tools/bootstrap
+	src/tools/moc
+	src/tools/rcc
+	src/corelib
+	src/tools/qlalr
+	doc
+)
+
+QT5_GENTOO_PRIVATE_CONFIG=(
+	!:network
+	!:sql
+	!:testlib
+	!:xml
+)
+
+PATCHES=(
+	"${FILESDIR}"/${P}-fortify-source-3.patch
+)
+
+pkg_pretend() {
+	use kernel_linux || return
+	get_running_version
+	if kernel_is -lt 4 11 && ! use old-kernel; then
+		ewarn "The running kernel is older than 4.11. USE=old-kernel is needed for"
+		ewarn "dev-qt/qtcore to function on this kernel properly. Bugs #669994, #672856"
+	fi
+}
+
+src_prepare() {
+	# don't add -O3 to CXXFLAGS, bug 549140
+	sed -i -e '/CONFIG\s*+=/s/optimize_full//' src/corelib/corelib.pro || die
+
+	# fix missing qt_version_tag symbol w/ LTO, bug 674382
+	sed -i -e 's/^gcc:ltcg/gcc/' src/corelib/global/global.pri || die
+
+	qt5-build_src_prepare
+}
+
+src_configure() {
+	local myconf=(
+		$(qt_use icu)
+		$(qt_use !icu iconv)
+		$(qt_use systemd journald)
+	)
+	use old-kernel && myconf+=(
+		-no-feature-renameat2 # needs Linux 3.16, bug 669994
+		-no-feature-getentropy # needs Linux 3.17, bug 669994
+		-no-feature-statx # needs Linux 4.11, bug 672856
+	)
+	qt5-build_src_configure
+}
+
+src_install() {
+	qt5-build_src_install
+	qt5_symlink_binary_to_path qmake 5
+
+	local flags=(
+		DBUS FREETYPE IMAGEFORMAT_JPEG IMAGEFORMAT_PNG
+		OPENGL OPENSSL SSL WIDGETS
+	)
+
+	for flag in ${flags[@]}; do
+		cat >> "${D}"/${QT5_HEADERDIR}/QtCore/qconfig.h <<- _EOF_ || die
+
+			#if defined(QT_NO_${flag}) && defined(QT_${flag})
+			# undef QT_NO_${flag}
+			#elif !defined(QT_NO_${flag}) && !defined(QT_${flag})
+			# define QT_NO_${flag}
+			#endif
+		_EOF_
+	done
+}


             reply	other threads:[~2022-06-26  8:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-26  8:25 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-02-19 13:24 [gentoo-commits] repo/gentoo:master commit in: dev-qt/qtcore/files/, dev-qt/qtcore/ Andreas Sturmlechner
2023-02-05 13:54 Andreas Sturmlechner
2022-03-30 18:57 Andreas Sturmlechner
2021-08-25 14:36 Andreas Sturmlechner
2021-02-13 11:38 Andreas Sturmlechner
2021-01-02  1:23 Andreas Sturmlechner
2020-02-09 18:51 Andreas Sturmlechner
2020-01-25 23:56 Andreas Sturmlechner
2018-10-19 20:23 Andreas Sturmlechner
2017-11-28 11:00 Michael Palimaka
2017-05-14  0:14 Davide Pesavento
2017-04-23 19:08 Andreas Sturmlechner
2016-11-17 14:36 Michael Palimaka
2015-10-20  1:36 Davide Pesavento

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1656231913.cb10b0356e62b2521c0d4592a35b5dfb6e5cd2ca.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox