git.iko.soy/typeable/nixpkgs
on master help sign in
virtualbox: Rebase hardened.patch on top of 5.1.22

The merge of the version bump in 6fb9f892382b4b091fc9edcae00e2eb4c0729bda didn't take care of our patch for the hardening mode and thus enabling VirtualBox without also force-disabling hardening mode will result in a build error. While the patch is largely identical with the old version, I've removed one particular change around the following code: if (pFsObjState->Stat.st_mode & S_IWOTH) return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, pErrInfo, "World writable: '", pszPath, "'"); In the old version of the patch we have checked whether the path is within the Nix store and suppressed the error return if that's the case. The reason why I did that in the first place was because we had a bunch of symlinks which were writable. In VirtualBox 5.1.22 the code specifically checks whether the file is a symlink, so we can safely drop our change. Tested via all of the "virtualbox" NixOS VM subtests and they now all succeed. Signed-off-by: aszlig <aszlig@redmoonstudios.org>

commit63fb845fcf6ea02db7933f503948a01fb2f6c2a4 authoraszlig <aszlig@redmoonstudios.org> dateFri 23 Jun 2017, 05:48 (9 years ago) parentfa6fd34
1 file changed+19−31
pkgs/applications/virtualization/virtualbox/hardened.patch+19−31
pkgs/applications/virtualization/virtualbox/hardened.patch+19−31
@@ -1,8 +1,8 @@
11diff --git a/include/iprt/mangling.h b/include/iprt/mangling.h
2−index 70c596a..78972ed 100644
2+index c1daa8f..8618371 100644
33--- a/include/iprt/mangling.h
44+++ b/include/iprt/mangling.h
5−@@ -1068,6 +1068,7 @@
5+@@ -1440,6 +1440,7 @@
66 # define RTPathStripSuffix RT_MANGLER(RTPathStripSuffix)
77 # define RTPathStripFilename RT_MANGLER(RTPathStripFilename)
88 # define RTPathStripTrailingSlash RT_MANGLER(RTPathStripTrailingSlash)
@@ -10,7 +10,7 @@ index 70c596a..78972ed 100644
1010 # define RTPathTemp RT_MANGLER(RTPathTemp)
1111 # define RTPathTraverseList RT_MANGLER(RTPathTraverseList)
1212 # define RTPathUnlink RT_MANGLER(RTPathUnlink)
13−@@ -1105,6 +1106,7 @@
13+@@ -1478,6 +1479,7 @@
1414 # define RTProcGetAffinityMask RT_MANGLER(RTProcGetAffinityMask)
1515 # define RTProcGetExecutablePath RT_MANGLER(RTProcGetExecutablePath)
1616 # define RTProcGetPriority RT_MANGLER(RTProcGetPriority)
@@ -19,10 +19,10 @@ index 70c596a..78972ed 100644
1919 # define RTProcQueryParent RT_MANGLER(RTProcQueryParent)
2020 # define RTProcQueryUsername RT_MANGLER(RTProcQueryUsername)
2121diff --git a/include/iprt/path.h b/include/iprt/path.h
22−index 7e42754..b4de4c8 100644
22+index 8bd42bc..2c23d3e 100644
2323--- a/include/iprt/path.h
2424+++ b/include/iprt/path.h
25−@@ -1049,6 +1049,15 @@ RTDECL(int) RTPathCalcRelative(char *pszPathDst, size_t cbPathDst,
25+@@ -1064,6 +1064,15 @@ RTDECL(int) RTPathCalcRelative(char *pszPathDst, size_t cbPathDst,
2626 RTDECL(int) RTPathExecDir(char *pszPath, size_t cchPath);
2727
2828 /**
@@ -39,10 +39,10 @@ index 7e42754..b4de4c8 100644
3939 *
4040 * @returns iprt status code.
4141diff --git a/include/iprt/process.h b/include/iprt/process.h
42−index 2760306..0ce6c92 100644
42+index 043653e..1070280 100644
4343--- a/include/iprt/process.h
4444+++ b/include/iprt/process.h
45−@@ -313,6 +313,16 @@ RTR3DECL(const char *) RTProcShortName(void);
45+@@ -327,6 +327,16 @@ RTR3DECL(const char *) RTProcShortName(void);
4646 RTR3DECL(char *) RTProcGetExecutablePath(char *pszExecPath, size_t cbExecPath);
4747
4848 /**
@@ -60,11 +60,11 @@ index 2760306..0ce6c92 100644
6060 *
6161 * The way this work is that it will spawn a detached / backgrounded /
6262diff --git a/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp b/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
63−index c39d2f7..896b352 100644
63+index ce0f288..6193108 100644
6464--- a/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
6565+++ b/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
66−@@ -1415,18 +1415,19 @@ static int supR3HardenedVerifyFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState, bo
67− NOREF(fRelaxed);
66+@@ -1489,9 +1489,9 @@ static int supR3HardenedVerifyFsObject(PCSUPR3HARDENEDFSOBJSTATE pFsObjState, bo
67+ bool fBad = !fRelaxed || pFsObjState->Stat.st_gid != 2 /*bin*/ || suplibHardenedStrCmp(pszPath, "/usr/lib/iconv");
6868 #else
6969 NOREF(fRelaxed);
7070- bool fBad = true;
@@ -75,23 +75,11 @@ index c39d2f7..896b352 100644
7575 return supR3HardenedSetError3(VERR_SUPLIB_WRITE_NON_SYS_GROUP, pErrInfo,
7676 "An unknown (and thus untrusted) group has write access to '", pszPath,
7777 "' and we therefore cannot trust the directory content or that of any subdirectory");
78− }
79−
80− /*
81−- * World must not have write access. There is no relaxing this rule.
82−+ * World must not have write access.
83−+ * There is no relaxing this rule, except when it comes to the Nix store.
84− */
85−- if (pFsObjState->Stat.st_mode & S_IWOTH)
86−+ if (pFsObjState->Stat.st_mode & S_IWOTH && suplibHardenedStrCmp(pszPath, "/nix/store"))
87− return supR3HardenedSetError3(VERR_SUPLIB_WORLD_WRITABLE, pErrInfo,
88− "World writable: '", pszPath, "'");
89−
9078diff --git a/src/VBox/Main/src-server/MachineImpl.cpp b/src/VBox/Main/src-server/MachineImpl.cpp
91−index 95dc9a7..39170bc 100644
79+index 320c569..9bfe41f 100644
9280--- a/src/VBox/Main/src-server/MachineImpl.cpp
9381+++ b/src/VBox/Main/src-server/MachineImpl.cpp
94−@@ -7326,7 +7326,7 @@ HRESULT Machine::i_launchVMProcess(IInternalSessionControl *aControl,
82+@@ -7543,7 +7543,7 @@ HRESULT Machine::i_launchVMProcess(IInternalSessionControl *aControl,
9583
9684 /* get the path to the executable */
9785 char szPath[RTPATH_MAX];
@@ -101,10 +89,10 @@ index 95dc9a7..39170bc 100644
10189 szPath[cchBufLeft++] = RTPATH_DELIMITER;
10290 szPath[cchBufLeft] = 0;
10391diff --git a/src/VBox/Main/src-server/NetworkServiceRunner.cpp b/src/VBox/Main/src-server/NetworkServiceRunner.cpp
104−index e9e1ba62..4d1c1e1 100644
92+index 1e38d99..5e43dda 100644
10593--- a/src/VBox/Main/src-server/NetworkServiceRunner.cpp
10694+++ b/src/VBox/Main/src-server/NetworkServiceRunner.cpp
107−@@ -79,7 +79,7 @@ int NetworkServiceRunner::start()
95+@@ -85,7 +85,7 @@ int NetworkServiceRunner::start(bool aKillProcOnStop)
10896
10997 /* get the path to the executable */
11098 char exePathBuf[RTPATH_MAX];
@@ -114,7 +102,7 @@ index e9e1ba62..4d1c1e1 100644
114102 char *substrBs = strrchr(exePathBuf, '\\');
115103 char *suffix = substrSl ? substrSl : substrBs;
116104diff --git a/src/VBox/Main/src-server/generic/NetIf-generic.cpp b/src/VBox/Main/src-server/generic/NetIf-generic.cpp
117−index 8559d2a..2177f27 100644
105+index 98dc91a..43a819f 100644
118106--- a/src/VBox/Main/src-server/generic/NetIf-generic.cpp
119107+++ b/src/VBox/Main/src-server/generic/NetIf-generic.cpp
120108@@ -47,7 +47,7 @@ static int NetIfAdpCtl(const char * pcszIfName, const char *pszAddr, const char
@@ -126,7 +114,7 @@ index 8559d2a..2177f27 100644
126114 if (RT_FAILURE(rc))
127115 {
128116 LogRel(("NetIfAdpCtl: failed to get program path, rc=%Rrc.\n", rc));
129−@@ -90,7 +90,7 @@ static int NetIfAdpCtl(HostNetworkInterface * pIf, const char *pszAddr, const ch
117+@@ -89,7 +89,7 @@ static int NetIfAdpCtl(HostNetworkInterface * pIf, const char *pszAddr, const ch
130118 int NetIfAdpCtlOut(const char * pcszName, const char * pcszCmd, char *pszBuffer, size_t cBufSize)
131119 {
132120 char szAdpCtl[RTPATH_MAX];
@@ -135,7 +123,7 @@ index 8559d2a..2177f27 100644
135123 if (RT_FAILURE(rc))
136124 {
137125 LogRel(("NetIfAdpCtlOut: Failed to get program path, rc=%Rrc\n", rc));
138−@@ -202,7 +202,7 @@ int NetIfCreateHostOnlyNetworkInterface(VirtualBox *pVirtualBox,
126+@@ -201,7 +201,7 @@ int NetIfCreateHostOnlyNetworkInterface(VirtualBox *pVirtualBox,
139127 progress.queryInterfaceTo(aProgress);
140128
141129 char szAdpCtl[RTPATH_MAX];
@@ -145,7 +133,7 @@ index 8559d2a..2177f27 100644
145133 {
146134 progress->i_notifyComplete(E_FAIL,
147135diff --git a/src/VBox/Runtime/r3/path.cpp b/src/VBox/Runtime/r3/path.cpp
148−index be2ad8f..7ddf105 100644
136+index 944848e..744a261 100644
149137--- a/src/VBox/Runtime/r3/path.cpp
150138+++ b/src/VBox/Runtime/r3/path.cpp
151139@@ -81,6 +81,12 @@ RTDECL(int) RTPathExecDir(char *pszPath, size_t cchPath)
@@ -162,7 +150,7 @@ index be2ad8f..7ddf105 100644
162150 {
163151 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE)
164152diff --git a/src/VBox/Runtime/r3/process.cpp b/src/VBox/Runtime/r3/process.cpp
165−index 7bde6af..2656cae 100644
153+index 2aab645..9795f21 100644
166154--- a/src/VBox/Runtime/r3/process.cpp
167155+++ b/src/VBox/Runtime/r3/process.cpp
168156@@ -111,6 +111,26 @@ RTR3DECL(char *) RTProcGetExecutablePath(char *pszExecPath, size_t cbExecPath)