VirtualBox

Changeset 99421 in vbox


Ignore:
Timestamp:
Apr 17, 2023 2:38:06 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156875
Message:

SUPDrv: Move SUPDRV_MEMCPY to SUPDrvInternal.h and try explain why and when to use. bugref:10209 ticketref:21410

Location:
trunk/src/VBox/HostDrivers/Support
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp

    r98103 r99421  
    8484# define VBOXDRV_IOCTL_ENTRY(pvSession, uIOCtl, pvReqHdr) do { } while (0)
    8585# define VBOXDRV_IOCTL_RETURN(pvSession, uIOCtl, pvReqHdr, rcRet, rcReq) do { } while (0)
    86 #endif
    87 
    88 #if defined(RT_OS_LINUX)
    89 /* In Linux 5.18-rc1, memcpy became a wrapper which does fortify checks
    90  * before triggering __underlying_memcpy() call. We do not pass these checks here,
    91  * so bypass them for now.  */
    92 # if RTLNX_VER_MIN(5,18,0) && !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
    93 #  define SUPDRV_MEMCPY __underlying_memcpy
    94 # else
    95 # define SUPDRV_MEMCPY  memcpy
    96 # endif
    97 #else
    98 # define SUPDRV_MEMCPY  memcpy
    9986#endif
    10087
     
    17781765            /* execute */
    17791766            pReq->u.Out.cFunctions = RT_ELEMENTS(g_aFunctions);
    1780             SUPDRV_MEMCPY(&pReq->u.Out.aFunctions[0], g_aFunctions, sizeof(g_aFunctions));
     1767            SUPDRV_UNFORTIFIED_MEMCPY(&pReq->u.Out.aFunctions[0], g_aFunctions, sizeof(g_aFunctions));
    17811768            pReq->Hdr.rc = VINF_SUCCESS;
    17821769            return 0;
  • trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h

    r98103 r99421  
    243243#       endif
    244244#   endif
     245#   if RTLNX_VER_MIN(5,18,0) && !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
     246#    define SUPDRV_UNFORTIFIED_MEMCPY __underlying_memcpy
     247#   endif
    245248#   define SUPR0_EXPORT_SYMBOL(a_Name) EXPORT_SYMBOL(a_Name)
    246249
     
    372375 * @todo Test on servers with many CPUs and sockets. */
    373376# define SUPDRV_USE_TSC_DELTA_THREAD
     377#endif
     378
     379/** @def SUPDRV_UNFORTIFIED_MEMCPY
     380 * Use when copying to variable length structures, it prevents a fortified
     381 * memcpy (linux 5.18+) from complaining about "field-spanning writes".
     382 * 
     383 * @see @ticketref{21410}, @bugref{10209}
     384 */
     385#if !defined(SUPDRV_UNFORTIFIED_MEMCPY) || defined(DOXYGEN_RUNNING) /* (Already defined above if fortified.) */
     386# define SUPDRV_UNFORTIFIED_MEMCPY memcpy
    374387#endif
    375388
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