VirtualBox

Ignore:
Timestamp:
Jul 14, 2014 7:44:01 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94990
Message:

IPRT: Make RTMemSafer use the SUPR3 page allocation if available to allocate locked down memory. Change API to make allocation strategy tweakable to allow for pageable allocations where the support library is not available (build tools like bldRTSignTool) while still making sure the memory is non-pageable for sensitive data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/math/bignum.cpp

    r51915 r52018  
    118118    Assert(cbNew > cbOld);
    119119
    120     void *pvNew;
     120    void *pvNew = NULL;
    121121    if (pBigNum->fSensitive)
    122         pvNew = RTMemSaferReallocZ(cbOld, pBigNum->pauElements, cbNew);
     122    {
     123        int rc = RTMemSaferReallocZEx(cbOld, pBigNum->pauElements, cbNew, &pvNew, RTMEMSAFER_ALLOC_EX_ALLOW_PAGEABLE_BACKING);
     124        Assert(VALID_PTR(pvNew) || RT_FAILURE(rc));
     125    }
    123126    else
    124127        pvNew = RTMemRealloc(pBigNum->pauElements, cbNew);
     
    323326        pBigNum->cAllocated = RT_ALIGN_32(pBigNum->cUsed, 4);
    324327        if (pBigNum->fSensitive)
    325             pBigNum->pauElements = (RTBIGNUMELEMENT *)RTMemSaferAllocZ(pBigNum->cAllocated * RTBIGNUM_ELEMENT_SIZE);
     328        {
     329            int rc = RTMemSaferAllocZEx((void **)&pBigNum->pauElements, pBigNum->cAllocated * RTBIGNUM_ELEMENT_SIZE,
     330                                        RTMEMSAFER_ALLOC_EX_ALLOW_PAGEABLE_BACKING);
     331            Assert(VALID_PTR(pBigNum->pauElements) || RT_FAILURE(rc));
     332        }
    326333        else
    327334            pBigNum->pauElements = (RTBIGNUMELEMENT *)RTMemAlloc(pBigNum->cAllocated * RTBIGNUM_ELEMENT_SIZE);
     
    457464        pBigNum->cAllocated = RT_ALIGN_32(pBigNum->cUsed, 4);
    458465        if (pBigNum->fSensitive)
    459             pBigNum->pauElements = (RTBIGNUMELEMENT *)RTMemSaferAllocZ(pBigNum->cAllocated * RTBIGNUM_ELEMENT_SIZE);
     466        {
     467            rc = RTMemSaferAllocZEx((void **)&pBigNum->pauElements, pBigNum->cAllocated * RTBIGNUM_ELEMENT_SIZE,
     468                                    RTMEMSAFER_ALLOC_EX_ALLOW_PAGEABLE_BACKING);
     469            Assert(VALID_PTR(pBigNum->pauElements) || RT_FAILURE(rc));
     470        }
    460471        else
    461472            pBigNum->pauElements = (RTBIGNUMELEMENT *)RTMemAlloc(pBigNum->cAllocated * RTBIGNUM_ELEMENT_SIZE);
Note: See TracChangeset for help on using the changeset viewer.

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