VirtualBox

Changeset 35152 in vbox


Ignore:
Timestamp:
Dec 15, 2010 4:45:42 PM (14 years ago)
Author:
vboxsync
Message:

*: added fFlags parameter to SUPR3HardenedLdrLoadAppPriv(), SUPR3HardenedLdrLoad() and RTLdrLoadEx(). VBoxSVC: slurp in VBoxVMM because it is required by the extension packs

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/sup.h

    r34959 r35152  
    10381038 * @param   pszFilename     Image filename. This must have a path.
    10391039 * @param   phLdrMod        Where to store the handle to the loaded module.
     1040 * @param   fFlags          See RTLDRFLAGS_.
    10401041 * @param   pszError        Where to return error message on failure.
    10411042 * @param   cbError         The size of the error buffer.
    10421043 */
    1043 SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszError, size_t cbError);
     1044SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError);
    10441045
    10451046/**
     
    10511052 *
    10521053 * @returns iprt status code.
    1053  * @param   pszFilename Image filename.
    1054  * @param   phLdrMod    Where to store the handle to the loaded module.
     1054 * @param   pszFilename     Image filename.
     1055 * @param   phLdrMod        Where to store the handle to the loaded module.
     1056 * @param   fFlags          See RTLDRFLAGS_*.
    10551057 * @param   pszError        Where to return error message on failure.
    10561058 * @param   cbError         The size of the error buffer.
    10571059 */
    1058 SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszError, size_t cbError);
     1060SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError);
    10591061
    10601062/**
  • trunk/include/iprt/ldr.h

    r34959 r35152  
    3636 */
    3737
     38/** Symbols defined in this library are not made available to resolve
     39 * references in subsequently loaded libraries (default). */
     40#define RTLDRFLAGS_LOCAL        0
     41/** Symbols defined in this library will be made available for symbol
     42 * resolution of subsequently loaded libraries. */
     43#define RTLDRFLAGS_GLOBAL       RT_BIT(0)
     44
     45
    3846RT_C_DECLS_BEGIN
    3947
     
    8997 * @param   pszFilename Image filename.
    9098 * @param   phLdrMod    Where to store the handle to the loader module.
     99 * @param   fFlags      See RTLDFLAGS_.
    91100 * @param   pszError    Where to store an error message on failure. Optional.
    92101 * @param   cbError     The size of the buffer pointed to by @a pszError.
    93102 */
    94 RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszError, size_t cbError);
     103RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError);
    95104
    96105/**
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r34959 r35152  
    836836
    837837            Log2(("VBoxHeadless: loading VBoxFFmpegFB shared library\n"));
    838             rrc = SUPR3HardenedLdrLoadAppPriv("VBoxFFmpegFB", &hLdrFFmpegFB, szErr, sizeof(szErr));
     838            rrc = SUPR3HardenedLdrLoadAppPriv("VBoxFFmpegFB", &hLdrFFmpegFB, 0 /*=fFlags*/, szErr, sizeof(szErr));
    839839
    840840            if (RT_SUCCESS(rrc))
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r35114 r35152  
    51155115        char szErr[8192];
    51165116        szErr[0] = '\0';
    5117         int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxDbg", &mhVBoxDbg, szErr, sizeof(szErr));
     5117        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxDbg", &mhVBoxDbg, 0 /*=fFlags*/, szErr, sizeof(szErr));
    51185118        if (RT_FAILURE(vrc))
    51195119        {
  • trunk/src/VBox/GuestHost/OpenGL/Makefile.kmk

    r33676 r35152  
    400400        $(VBOX_PATH_CROGL_GENFILES)/state_isenabled.c \
    401401        $(VBOX_PATH_CROGL_GENFILES)/state/cr_statefuncs.h
     402ifneq ($(KBUILD_TARGET),win)
     403state_tracker/state_lists.c_CFLAGS += $(VBOX_GCC_Wno-pointer-sign)
     404VBoxOGLcrstate_CFLAGS +=
     405endif
    402406
    403407#
  • trunk/src/VBox/HostDrivers/Support/SUPLib.cpp

    r34972 r35152  
    20832083 * @param   pszFilename     The full file name.
    20842084 * @param   phLdrMod        Where to store the handle to the loaded module.
     2085 * @param   fFlags          See RTLDFLAGS_.
    20852086 * @param   pszError        Where to return the loader error. Optional.
    20862087 * @param   cbError         The size of the buffer pointed to by @a pszError.
    20872088 */
    2088 static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszError, size_t cbError)
     2089static int supR3HardenedLdrLoadIt(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
    20892090{
    20902091#ifdef VBOX_WITH_HARDENING
     
    21032104     * Try load it.
    21042105     */
    2105     return RTLdrLoadEx(pszFilename, phLdrMod, pszError, cbError);
    2106 }
    2107 
    2108 
    2109 SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszError, size_t cbError)
     2106    return RTLdrLoadEx(pszFilename, phLdrMod, fFlags, pszError, cbError);
     2107}
     2108
     2109
     2110SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
    21102111{
    21112112    /*
     
    21452146     * Pass it on to the common library loader.
    21462147     */
    2147     return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, pszError, cbError);
    2148 }
    2149 
    2150 
    2151 SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszError, size_t cbError)
    2152 {
    2153     LogFlow(("SUPR3HardenedLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, pszError, cbError));
     2148    return supR3HardenedLdrLoadIt(pszFilename, phLdrMod, fFlags, pszError, cbError);
     2149}
     2150
     2151
     2152SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
     2153{
     2154    LogFlow(("SUPR3HardenedLdrLoadAppPriv: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, fFlags, pszError, cbError));
    21542155
    21552156    /*
     
    22072208     * Pass it on to SUPR3HardenedLdrLoad.
    22082209     */
    2209     rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, pszError, cbError);
     2210    rc = SUPR3HardenedLdrLoad(szPath, phLdrMod, fFlags, pszError, cbError);
    22102211
    22112212    LogFlow(("SUPR3HardenedLdrLoadAppPriv: returns %Rrc\n", rc));
     
    22442245     * Try load it.
    22452246     */
    2246     return RTLdrLoadEx(pszFilename, phLdrMod, pszErr, cbErr);
     2247    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*=fFlags*/, pszErr, cbErr);
    22472248}
    22482249
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r35146 r35152  
    23402340            rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &mVRDPLibrary, szErr, sizeof(szErr));
    23412341        else
    2342             rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, szErr, sizeof(szErr));
     2342            rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &mVRDPLibrary, 0 /*=fFlags*/, szErr, sizeof(szErr));
    23432343        if (RT_SUCCESS(rc))
    23442344        {
  • trunk/src/VBox/Main/ExtPackManagerImpl.cpp

    r35100 r35152  
    149149    /** The current context. */
    150150    VBOXEXTPACKCTX      enmContext;
     151#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_DARWIN)
     152    /** File handle for the VBoxVMM libary which we slurp because ExtPacks depend on it. */
     153    RTLDRMOD            hVBoxVMM;
     154#endif
    151155
    152156    RTMEMEF_NEW_AND_DELETE_OPERATORS();
     
    11711175    {
    11721176        char szError[8192];
    1173         vrc = RTLdrLoadEx(m->strMainModPath.c_str(), &m->hMainMod, szError, sizeof(szError));
     1177        vrc = RTLdrLoadEx(m->strMainModPath.c_str(), &m->hMainMod, 0 /*=fFlags*/, szError, sizeof(szError));
    11741178        if (RT_FAILURE(vrc))
    11751179        {
     
    17611765    m->pVirtualBox          = a_pVirtualBox;
    17621766    m->enmContext           = a_enmContext;
     1767
     1768    /*
     1769     * Slurp in VBoxVMM which is used by VBoxPuelMain.
     1770     */
     1771#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_DARWIN)
     1772    if (a_enmContext == VBOXEXTPACKCTX_PER_USER_DAEMON)
     1773    {
     1774        char szError[8192];
     1775        int vrc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &m->hVBoxVMM, RTLDRFLAGS_GLOBAL, szError, sizeof(szError));
     1776        if (RT_FAILURE(vrc))
     1777            m->hVBoxVMM = NIL_RTLDRMOD;
     1778        /* cleanup in ::uninit()? */
     1779    }
     1780#endif
    17631781
    17641782    /*
  • trunk/src/VBox/Main/VRDEServerImpl.cpp

    r35146 r35152  
    494494        rc = SUPR3HardenedLdrLoadPlugIn(pszLibraryName, &hmod, szErr, sizeof(szErr));
    495495    else
    496         rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, szErr, sizeof(szErr));
     496        rc = SUPR3HardenedLdrLoadAppPriv(pszLibraryName, &hmod, 0 /*=fFlags*/, szErr, sizeof(szErr));
    497497    if (RT_SUCCESS(rc))
    498498    {
  • trunk/src/VBox/Main/hgcm/HGCM.cpp

    r34959 r35152  
    264264    char szErr[8192];
    265265    szErr[0] = '\0';
    266     int rc = SUPR3HardenedLdrLoadAppPriv (m_pszSvcLibrary, &m_hLdrMod, szErr, sizeof(szErr));
     266    int rc = SUPR3HardenedLdrLoadAppPriv (m_pszSvcLibrary, &m_hLdrMod, 0 /*=fFlags*/, szErr, sizeof(szErr));
    267267
    268268    if (RT_SUCCESS(rc))
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r34563 r35152  
    11551155            do
    11561156            {
    1157                 rc = RTLdrLoad(filename.c_str(), &hlibAuth);
     1157                rc = RTLdrLoad(filename.c_str(), &hlibAuth, RTLDRFLAGS_LOCAL);
    11581158                if (RT_FAILURE(rc))
    11591159                {
  • trunk/src/VBox/Runtime/common/ldr/ldrNative.cpp

    r34959 r35152  
    9696RTDECL(int) RTLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod)
    9797{
    98     return RTLdrLoadEx(pszFilename, phLdrMod, NULL, 0);
     98    return RTLdrLoadEx(pszFilename, phLdrMod, 0 /*=fFlags*/, NULL, 0);
    9999}
    100100RT_EXPORT_SYMBOL(RTLdrLoad);
    101101
    102102
    103 RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, char *pszError, size_t cbError)
    104 {
    105     LogFlow(("RTLdrLoadEx: pszFilename=%p:{%s} phLdrMod=%p pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, pszError, cbError));
     103RTDECL(int) RTLdrLoadEx(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, char *pszError, size_t cbError)
     104{
     105    LogFlow(("RTLdrLoadEx: pszFilename=%p:{%s} phLdrMod=%p fFlags=%08x pszError=%p cbError=%zu\n", pszFilename, pszFilename, phLdrMod, fFlags, pszError, cbError));
    106106
    107107    /*
     
    136136         * Attempt to open the module.
    137137         */
    138         rc = rtldrNativeLoad(pszFilename, &pMod->hNative, pszError, cbError);
     138        rc = rtldrNativeLoad(pszFilename, &pMod->hNative, fFlags, pszError, cbError);
    139139        if (RT_SUCCESS(rc))
    140140        {
  • trunk/src/VBox/Runtime/include/internal/ldr.h

    r34959 r35152  
    365365 * @param   pszFilename     The image filename.
    366366 * @param   phHandle        Where to store the module handle on success.
     367 * @param   fFlags          See RTLDRFLAGS_.
    367368 * @param   pszError        Where to store the error message. Optional.
    368369 * @param   cbError         The size of the error message buffer.
    369370 */
    370 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, char *pszError, size_t cbError);
     371int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError);
    371372
    372373int rtldrPEOpen(PRTLDRREADER pReader, uint32_t fFlags, RTLDRARCH enmArch, RTFOFF offNtHdrs, PRTLDRMOD phLdrMod);
  • trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp

    r34959 r35152  
    4141
    4242
    43 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, char *pszError, size_t cbError)
     43int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)
    4444{
    4545    /*
     
    6969     * Attempt load.
    7070     */
    71     void *pvMod = dlopen(pszFilename, RTLD_NOW | RTLD_LOCAL);
     71    int fFlagsNative = RTLD_NOW;
     72    if (fFlags & RTLDRFLAGS_GLOBAL)
     73        fFlagsNative |= RTLD_GLOBAL;
     74    else
     75        fFlagsNative |= RTLD_LOCAL;
     76    void *pvMod = dlopen(pszFilename, fFlagsNative);
    7277    if (pvMod)
    7378    {
  • trunk/src/VBox/Runtime/r3/win/ldrNative-win.cpp

    r34962 r35152  
    4040
    4141
    42 int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, char *pszError, size_t cbError)
     42int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, char *pszError, size_t cbError)
    4343{
    4444    Assert(sizeof(*phHandle) >= sizeof(HMODULE));
     45    AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER);
    4546
    4647    /*
  • trunk/src/VBox/Storage/VD.cpp

    r34959 r35152  
    21292129        }
    21302130
    2131         rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, NULL, 0);
     2131        rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);
    21322132        if (RT_SUCCESS(rc))
    21332133        {
     
    22532253        }
    22542254
    2255         rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, NULL, 0);
     2255        rc = SUPR3HardenedLdrLoad(pszPluginPath, &hPlugin, 0 /*=fFlags*/, NULL, 0);
    22562256        if (RT_SUCCESS(rc))
    22572257        {
  • trunk/src/recompiler/VBoxREMWrapper.cpp

    r34959 r35152  
    21332133     */
    21342134    const char *pszModule = remIs64bitEnabled(pVM) ? "VBoxREM64" : "VBoxREM32";
    2135     int rc = SUPR3HardenedLdrLoadAppPriv(pszModule, &g_ModREM2, NULL, 0);
     2135    int rc = SUPR3HardenedLdrLoadAppPriv(pszModule, &g_ModREM2, 0 /*=fFlags*/, NULL, 0);
    21362136    if (RT_SUCCESS(rc))
    21372137    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette