public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Lars Wendler" <polynomial-c@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: app-emulation/virtualbox/, app-emulation/virtualbox/files/
Date: Thu, 11 May 2017 12:07:28 +0000 (UTC)	[thread overview]
Message-ID: <1494504444.711bd6953ba3b6e086e30f77048b693f31082d73.polynomial-c@gentoo> (raw)

commit:     711bd6953ba3b6e086e30f77048b693f31082d73
Author:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
AuthorDate: Thu May 11 12:07:06 2017 +0000
Commit:     Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
CommitDate: Thu May 11 12:07:24 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=711bd695

app-emulation/virtualbox: Fixed OpenGL issue (bug #616238).

Package-Manager: Portage-2.3.5, Repoman-2.3.2

 .../virtualbox-5.1.22-opengl_dlopen_fix.patch      | 167 +++++++++++++++++++++
 ...x-5.1.22.ebuild => virtualbox-5.1.22-r1.ebuild} |   1 +
 2 files changed, 168 insertions(+)

diff --git a/app-emulation/virtualbox/files/virtualbox-5.1.22-opengl_dlopen_fix.patch b/app-emulation/virtualbox/files/virtualbox-5.1.22-opengl_dlopen_fix.patch
new file mode 100644
index 00000000000..71fa978ca6e
--- /dev/null
+++ b/app-emulation/virtualbox/files/virtualbox-5.1.22-opengl_dlopen_fix.patch
@@ -0,0 +1,167 @@
+Index: VirtualBox-5.1.22/src/VBox/HostDrivers/Support/posix/SUPR3HardenedMain-posix.cpp
+===================================================================
+--- VirtualBox-5.1.22/src/VBox/HostDrivers/Support/posix/SUPR3HardenedMain-posix.cpp	(revision 115126)
++++ VirtualBox-5.1.22/src/VBox/HostDrivers/Support/posix/SUPR3HardenedMain-posix.cpp	(revision 115307)
+@@ -341,6 +341,7 @@
+      * Patch 64-bit hosts.
+      */
+     uint32_t cRipRelMovs = 0;
++    uint32_t cRelCalls = 0;
+ 
+     /* Just use the disassembler to skip 12 bytes or more, we might need to
+        rewrite mov instructions using RIP relative addressing. */
+@@ -349,7 +350,8 @@
+         cbInstr = 1;
+         int rc = DISInstr(pbTarget + offJmpBack, DISCPUMODE_64BIT, &Dis, &cbInstr);
+         if (   RT_FAILURE(rc)
+-            || (Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW)
++            || (   Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW
++                && Dis.pCurInstr->uOpcode != OP_CALL)
+             || (   Dis.ModRM.Bits.Mod == 0
+                 && Dis.ModRM.Bits.Rm  == 5 /* wrt RIP */
+                 && Dis.pCurInstr->uOpcode != OP_MOV))
+@@ -357,15 +359,23 @@
+ 
+         if (Dis.ModRM.Bits.Mod == 0 && Dis.ModRM.Bits.Rm == 5 /* wrt RIP */)
+             cRipRelMovs++;
++        if (   Dis.pCurInstr->uOpcode == OP_CALL
++            && (Dis.pCurInstr->fOpType & DISOPTYPE_RELATIVE_CONTROLFLOW))
++            cRelCalls++;
+ 
+         offJmpBack += cbInstr;
+         cbPatchMem += cbInstr;
+     }
+ 
++    /*
++     * Each relative call requires extra bytes as it is converted to a pushq imm32
++     * + mov [RSP+4], imm32 + a jmp qword [$+8 wrt RIP] to avoid clobbering registers.
++     */
++    cbPatchMem += cRelCalls * RT_ALIGN_32(13 + 6 + 8, 8);
+     cbPatchMem += 14; /* jmp qword [$+8 wrt RIP] + 8 byte address to jump to. */
+     cbPatchMem = RT_ALIGN_32(cbPatchMem, 8);
+ 
+-    /* Allocate suitable exectuable memory available. */
++    /* Allocate suitable executable memory available. */
+     bool fConvRipRelMovs = false;
+     uint8_t *pbPatchMem = supR3HardenedMainPosixExecMemAlloc(cbPatchMem, pbTarget, cRipRelMovs > 0);
+     if (!pbPatchMem)
+@@ -396,7 +406,8 @@
+         cbInstr = 1;
+         int rc = DISInstr(pbTarget + offInsn, DISCPUMODE_64BIT, &Dis, &cbInstr);
+         if (   RT_FAILURE(rc)
+-            || (Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW))
++            || (   Dis.pCurInstr->fOpType & DISOPTYPE_CONTROLFLOW
++                && Dis.pCurInstr->uOpcode != OP_CALL))
+             return VERR_SUPLIB_UNEXPECTED_INSTRUCTION;
+ 
+         if (   Dis.ModRM.Bits.Mod == 0
+@@ -439,6 +450,34 @@
+                 pbPatchMem   += sizeof(int32_t);
+             }
+         }
++        else if (   Dis.pCurInstr->uOpcode == OP_CALL
++                 && (Dis.pCurInstr->fOpType & DISOPTYPE_RELATIVE_CONTROLFLOW))
++        {
++            /* Convert to absolute jump. */
++            uintptr_t uAddr = (uintptr_t)&pbTarget[offInsn + cbInstr] + (intptr_t)Dis.Param1.uValue;
++
++            /* Skip the push instructions till the return address is known. */
++            uint8_t *pbPatchMemPush = pbPatchMem;
++            pbPatchMem += 13;
++
++            *pbPatchMem++ = 0xff; /* jmp qword [$+8 wrt RIP] */
++            *pbPatchMem++ = 0x25;
++            *(uint32_t *)pbPatchMem = (uint32_t)(RT_ALIGN_PT(pbPatchMem + 4, 8, uint8_t *) - (pbPatchMem + 4));
++            pbPatchMem = RT_ALIGN_PT(pbPatchMem + 4, 8, uint8_t *);
++            *(uint64_t *)pbPatchMem = uAddr;
++            pbPatchMem += sizeof(uint64_t);
++
++            /* Push the return address onto stack. Difficult on amd64 without clobbering registers... */
++            uintptr_t uAddrReturn = (uintptr_t)pbPatchMem;
++            *pbPatchMemPush++ = 0x68; /* push imm32 sign-extended as 64-bit*/
++            *(uint32_t *)pbPatchMemPush = RT_LO_U32(uAddrReturn);
++            pbPatchMemPush += sizeof(uint32_t);
++            *pbPatchMemPush++ = 0xc7;
++            *pbPatchMemPush++ = 0x44;
++            *pbPatchMemPush++ = 0x24;
++            *pbPatchMemPush++ = 0x04; /* movl [RSP+4], imm32 */
++            *(uint32_t *)pbPatchMemPush = RT_HI_U32(uAddrReturn);
++        }
+         else
+         {
+             memcpy(pbPatchMem, pbTarget + offInsn, cbInstr);
+Index: VirtualBox-5.1.22/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
+===================================================================
+--- VirtualBox-5.1.22/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp	(revision 115126)
++++ VirtualBox-5.1.22/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp	(revision 115307)
+@@ -86,6 +86,9 @@
+ /** The max path length acceptable for a trusted path. */
+ #define SUPR3HARDENED_MAX_PATH      260U
+ 
++/** Enable to resolve symlinks using realpath() instead of cooking our own stuff. */
++#define SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH 1
++
+ #ifdef RT_OS_SOLARIS
+ # define dirfd(d) ((d)->d_fd)
+ #endif
+@@ -1091,7 +1094,8 @@
+ #endif
+ 
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
++#ifndef SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH
++# if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
+ /**
+  * Copies the error message to the error buffer and returns @a rc.
+  *
+@@ -1104,6 +1108,7 @@
+ {
+     return supR3HardenedSetErrorN(rc, pErrInfo, 1, pszMsg);
+ }
++# endif
+ #endif
+ 
+ 
+@@ -1893,7 +1898,9 @@
+     /*
+      * Verify each component from the root up.
+      */
++#ifndef SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH
+     uint32_t                iLoops = 0;
++#endif
+     SUPR3HARDENEDFSOBJSTATE FsObjState;
+     uint32_t                iComponent = 0;
+     while (iComponent < Info.cComponents)
+@@ -1915,6 +1922,24 @@
+             if (   RT_SUCCESS(rc)
+                 && S_ISLNK(FsObjState.Stat.st_mode))
+             {
++#if SUP_HARDENED_VERIFY_FOLLOW_SYMLINKS_USE_REALPATH /* Another approach using realpath() and verifying the result when encountering a symlink. */
++                char *pszFilenameResolved = realpath(pszFilename, NULL);
++                if (pszFilenameResolved)
++                {
++                    rc = supR3HardenedVerifyFile(pszFilenameResolved, hNativeFile, fMaybe3rdParty, pErrInfo);
++                    free(pszFilenameResolved);
++                    return rc;
++                }
++                else
++                {
++                    int iErr = errno;
++                    supR3HardenedError(VERR_ACCESS_DENIED, false /*fFatal*/,
++                                       "supR3HardenedVerifyFileFollowSymlinks: Failed to resolve the real path '%s': %s (%d)\n",
++                                       pszFilename, strerror(iErr), iErr);
++                    return supR3HardenedSetError4(VERR_ACCESS_DENIED, pErrInfo,
++                                                  "realpath failed for '", pszFilename, "': ", strerror(iErr));
++                }
++#else
+                 /* Don't loop forever. */
+                 iLoops++;
+                 if (iLoops < 8)
+@@ -1989,6 +2014,7 @@
+                 else
+                     return supR3HardenedSetError3(VERR_TOO_MANY_SYMLINKS, pErrInfo,
+                                                   "Too many symbolic links: '", pszFilename, "'");
++#endif
+             }
+         }
+         if (RT_FAILURE(rc))

diff --git a/app-emulation/virtualbox/virtualbox-5.1.22.ebuild b/app-emulation/virtualbox/virtualbox-5.1.22-r1.ebuild
similarity index 99%
rename from app-emulation/virtualbox/virtualbox-5.1.22.ebuild
rename to app-emulation/virtualbox/virtualbox-5.1.22-r1.ebuild
index 6f576db8b96..fda76d43805 100644
--- a/app-emulation/virtualbox/virtualbox-5.1.22.ebuild
+++ b/app-emulation/virtualbox/virtualbox-5.1.22-r1.ebuild
@@ -188,6 +188,7 @@ src_prepare() {
 	fi
 
 	eapply "${WORKDIR}/patches"
+	eapply "${FILESDIR}/${P}-opengl_dlopen_fix.patch" #616238
 
 	eapply_user
 }


             reply	other threads:[~2017-05-11 12:07 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 12:07 Lars Wendler [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-09-15 13:02 [gentoo-commits] repo/gentoo:master commit in: app-emulation/virtualbox/, app-emulation/virtualbox/files/ Viorel Munteanu
2024-09-15 13:02 Viorel Munteanu
2024-02-10 16:31 Viorel Munteanu
2024-02-10 16:31 Viorel Munteanu
2024-01-28 10:44 Viorel Munteanu
2023-08-28 10:08 Viorel Munteanu
2023-08-15 12:50 Viorel Munteanu
2023-08-15 12:50 Viorel Munteanu
2023-07-20  9:40 Viorel Munteanu
2023-06-02 18:27 Viorel Munteanu
2023-05-15 14:35 Viorel Munteanu
2023-04-21 16:38 Viorel Munteanu
2023-02-21 15:06 Viorel Munteanu
2023-02-03 14:35 Viorel Munteanu
2022-11-20  8:20 Viorel Munteanu
2022-11-02  6:41 Viorel Munteanu
2022-09-05 12:39 Joonas Niilola
2022-08-18 18:43 Sam James
2022-07-06  6:05 Sam James
2021-04-22 16:55 Lars Wendler
2020-06-03  0:10 Andreas Sturmlechner
2020-06-02 21:52 Andreas Sturmlechner
2019-01-16 12:02 Lars Wendler
2018-12-07 21:42 Lars Wendler
2018-11-17 11:55 Lars Wendler
2018-02-19 14:16 Lars Wendler
2018-02-16 14:56 Lars Wendler
2017-07-26 19:21 Richard Farina
2017-02-21 22:05 Magnus Granberg
2016-03-11 17:31 Lars Wendler

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=1494504444.711bd6953ba3b6e086e30f77048b693f31082d73.polynomial-c@gentoo \
    --to=polynomial-c@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