From owner-svn-ports-all@freebsd.org Mon Dec 24 16:46:19 2018 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D739C13490FE; Mon, 24 Dec 2018 16:46:18 +0000 (UTC) (envelope-from adridg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 76F788C6A2; Mon, 24 Dec 2018 16:46:18 +0000 (UTC) (envelope-from adridg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 641262714D; Mon, 24 Dec 2018 16:46:18 +0000 (UTC) (envelope-from adridg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBOGkI8m080077; Mon, 24 Dec 2018 16:46:18 GMT (envelope-from adridg@FreeBSD.org) Received: (from adridg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBOGkHMX080069; Mon, 24 Dec 2018 16:46:17 GMT (envelope-from adridg@FreeBSD.org) Message-Id: <201812241646.wBOGkHMX080069@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adridg set sender to adridg@FreeBSD.org using -f From: Adriaan de Groot Date: Mon, 24 Dec 2018 16:46:17 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r488276 - in head/net/qt5-network: . files X-SVN-Group: ports-head X-SVN-Commit-Author: adridg X-SVN-Commit-Paths: in head/net/qt5-network: . files X-SVN-Commit-Revision: 488276 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 76F788C6A2 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.97)[-0.971,0]; NEURAL_HAM_LONG(-1.00)[-0.998,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Dec 2018 16:46:19 -0000 Author: adridg Date: Mon Dec 24 16:46:16 2018 New Revision: 488276 URL: https://svnweb.freebsd.org/changeset/ports/488276 Log: Fix net/qt5-network in the face of VLANs. Adding a VLAN to a FreeBSD system caused memory corruption -- usually enough to make rtld fall over with symbol resolution errors, although in DEBUG builds it would just crash. Revamp network interface discovery to not be full of memory gotcha's. An explanation is included in the patches. While here, "make makesum" has moved some files around. PR: 231402, 233798, 232318 Reported by: Ting-Wei Lan, Nils Beyer, Marek Zarychta Added: head/net/qt5-network/files/patch-src_network_socket_qnet__unix__p.h (contents, props changed) head/net/qt5-network/files/patch-src_network_ssl_qsslcontext__openssl.cpp (contents, props changed) head/net/qt5-network/files/patch-src_plugins_bearer_generic_qgenericengine.cpp (contents, props changed) Deleted: head/net/qt5-network/files/patch-qsslcontext_openssl.cpp head/net/qt5-network/files/patch-src_network_socket_qnet_unix_p.h Modified: head/net/qt5-network/Makefile head/net/qt5-network/files/patch-src_network_kernel_qnetworkinterface__unix.cpp Modified: head/net/qt5-network/Makefile ============================================================================== --- head/net/qt5-network/Makefile Mon Dec 24 16:09:43 2018 (r488275) +++ head/net/qt5-network/Makefile Mon Dec 24 16:46:16 2018 (r488276) @@ -2,6 +2,7 @@ PORTNAME= network DISTVERSION= ${QT5_VERSION} +PORTREVISION= 1 CATEGORIES= net ipv6 PKGNAMEPREFIX= qt5- Modified: head/net/qt5-network/files/patch-src_network_kernel_qnetworkinterface__unix.cpp ============================================================================== --- head/net/qt5-network/files/patch-src_network_kernel_qnetworkinterface__unix.cpp Mon Dec 24 16:09:43 2018 (r488275) +++ head/net/qt5-network/files/patch-src_network_kernel_qnetworkinterface__unix.cpp Mon Dec 24 16:46:16 2018 (r488276) @@ -1,12 +1,95 @@ ---- src/network/kernel/qnetworkinterface_unix.cpp.orig 2018-06-15 07:29:31 UTC +Clean up interface type and MTU detection. + + - Introduce a class SockPuppet that handles closing the socket + automatically, and handles different address families as well. + - Finding MTU requires using AF_LOCAL, cribbed that detail from ifconfig.c + - Zero out structures more diligently, initialize pointers to nullptr. + - In particular, don't use a union of structs passed in to ioctl(). + Make them separate structs (with block scope so the compiler might + place them on top of each other, that would be ok). + +--- src/network/kernel/qnetworkinterface_unix.cpp.orig 2018-12-24 17:00:42 UTC +++ src/network/kernel/qnetworkinterface_unix.cpp -@@ -463,9 +463,6 @@ static QNetworkInterface::InterfaceType probeIfType(in - case IFM_ETHER: - return QNetworkInterface::Ethernet; +@@ -419,12 +419,23 @@ QT_BEGIN_INCLUDE_NAMESPACE + #endif // QT_PLATFORM_UIKIT + QT_END_INCLUDE_NAMESPACE -- case IFM_FDDI: -- return QNetworkInterface::Fddi; +-static int openSocket(int &socket) ++template struct SockPuppet + { +- if (socket == -1) +- socket = qt_safe_socket(AF_INET, SOCK_DGRAM, 0); +- return socket; +-} ++ int socket{-1}; ++ ++ int open() ++ { ++ if (socket == -1) ++ socket = qt_safe_socket(address_family, SOCK_DGRAM, 0); ++ return socket; ++ } ++ ++ ~SockPuppet() ++ { ++ if (socket != -1) ++ qt_safe_close(socket); ++ } ++} ; + + static QNetworkInterface::InterfaceType probeIfType(int socket, int iftype, struct ifmediareq *req) + { +@@ -477,15 +488,8 @@ static QNetworkInterface::InterfaceType + static QList createInterfaces(ifaddrs *rawList) + { + QList interfaces; +- union { +- struct ifmediareq mediareq; +- struct ifreq req; +- }; +- int socket = -1; - - case IFM_IEEE80211: - return QNetworkInterface::Ieee80211; +- // ensure both structs start with the name field, of size IFNAMESIZ +- Q_STATIC_ASSERT(sizeof(mediareq.ifm_name) == sizeof(req.ifr_name)); +- Q_ASSERT(&mediareq.ifm_name == &req.ifr_name); ++ SockPuppet socket; ++ SockPuppet localSocket; + + // on NetBSD we use AF_LINK and sockaddr_dl + // scan the list for that family +@@ -500,13 +504,21 @@ static QList + iface->flags = convertFlags(ptr->ifa_flags); + iface->hardwareAddress = iface->makeHwAddress(sdl->sdl_alen, (uchar*)LLADDR(sdl)); + +- strlcpy(mediareq.ifm_name, ptr->ifa_name, sizeof(mediareq.ifm_name)); +- iface->type = probeIfType(openSocket(socket), sdl->sdl_type, &mediareq); +- iface->mtu = getMtu(socket, &req); ++ { ++ ifmediareq req; ++ memset(&req, 0, sizeof(req)); ++ strncpy(req.ifm_name, ptr->ifa_name, sizeof(req.ifm_name)); ++ iface->type = probeIfType(socket.open(), sdl->sdl_type, &req); ++ } ++ { ++ ifreq req; ++ memset(&req, 0, sizeof(req)); ++ strncpy(req.ifr_name, ptr->ifa_name, sizeof(req.ifr_name)); ++ req.ifr_addr.sa_family = AF_LOCAL; ++ iface->mtu = getMtu(localSocket.open(), &req); ++ } } + +- if (socket != -1) +- qt_safe_close(socket); + return interfaces; + } + +@@ -605,7 +617,7 @@ static QList + { + QList interfaces; + +- ifaddrs *interfaceListing; ++ ifaddrs *interfaceListing = nullptr; + if (getifaddrs(&interfaceListing) == -1) { + // error + return interfaces; Added: head/net/qt5-network/files/patch-src_network_socket_qnet__unix__p.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/qt5-network/files/patch-src_network_socket_qnet__unix__p.h Mon Dec 24 16:46:16 2018 (r488276) @@ -0,0 +1,17 @@ +Some extra includes for us. + +--- src/network/socket/qnet_unix_p.h.orig 2018-12-03 11:15:26 UTC ++++ src/network/socket/qnet_unix_p.h +@@ -71,6 +71,12 @@ + # include + #endif + ++#if defined(Q_OS_FREEBSD) ++# include ++# include ++# include ++#endif ++ + QT_BEGIN_NAMESPACE + + // Almost always the same. If not, specify in qplatformdefs.h. Added: head/net/qt5-network/files/patch-src_network_ssl_qsslcontext__openssl.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/qt5-network/files/patch-src_network_ssl_qsslcontext__openssl.cpp Mon Dec 24 16:46:16 2018 (r488276) @@ -0,0 +1,15 @@ +* +* Fix for libressl after openssl111 API change +* +* +--- src/network/ssl/qsslcontext_openssl.cpp.orig 2018-12-03 11:15:26 UTC ++++ src/network/ssl/qsslcontext_openssl.cpp +@@ -249,7 +249,7 @@ void QSslContext::applyBackendConfig(QSs + if (sslContext->sslConfiguration.backendConfiguration().isEmpty()) + return; + +-#if OPENSSL_VERSION_NUMBER >= 0x10002000L ++#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER) + if (QSslSocket::sslLibraryVersionNumber() >= 0x10002000L) { + QSharedPointer cctx(q_SSL_CONF_CTX_new(), &q_SSL_CONF_CTX_free); + if (cctx) { Added: head/net/qt5-network/files/patch-src_plugins_bearer_generic_qgenericengine.cpp ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net/qt5-network/files/patch-src_plugins_bearer_generic_qgenericengine.cpp Mon Dec 24 16:46:16 2018 (r488276) @@ -0,0 +1,42 @@ +Determine suitable bearer. This code is basically the same +as the Linux code, except out ioctl()s are named differently +and we need an AF_LOCAL socket (this detail cribbed from ifconfig.c). +If getting the HW address succeeds, assume it's Ethernet. Tested +with two Ethernet cards and a vlan (all of which have a MAC reported +by ifconfig). + +--- src/plugins/bearer/generic/qgenericengine.cpp.orig 2018-12-03 12:15:26.000000000 +0100 ++++ src/plugins/bearer/generic/qgenericengine.cpp 2018-12-23 12:42:48.095145000 +0100 +@@ -82,7 +82,7 @@ + // needed as interface is used as parameter name in qGetInterfaceType + #undef interface + +-#ifdef Q_OS_LINUX ++#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) + #include + #include + #include +@@ -139,6 +139,23 @@ + + if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER) + return QNetworkConfiguration::BearerEthernet; ++ ++#elif defined(Q_OS_FREEBSD) ++ int sock = socket(AF_LOCAL, SOCK_DGRAM, 0); ++ ++ ifreq request; ++ memset(&request, 0, sizeof(struct ifreq)); ++ strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name) - 1); ++ request.ifr_name[sizeof(request.ifr_name) - 1] = '\0'; ++ ++ if (sock >= 0) { ++ int result = ioctl(sock, SIOCGHWADDR, &request); ++ close(sock); ++ ++ if (result >= 0) ++ return QNetworkConfiguration::BearerEthernet; ++ } ++ + #elif defined(Q_OS_WINRT) + ComPtr networkInfoStatics; + HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &networkInfoStatics);