VirtualBox

Changeset 101359 in vbox for trunk/src/VBox/Additions/linux


Ignore:
Timestamp:
Oct 5, 2023 3:26:17 PM (16 months ago)
Author:
vboxsync
Message:

Additions: Linux: Replace VBSF_UNFORTIFIED_MEMCPY with RT_BCOPY_UNFORTIFIED, bugref:10209.

Location:
trunk/src/VBox/Additions/linux/sharedfolders
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/linux/sharedfolders/dirops.c

    r99739 r101359  
    7878        pReq = (VBOXSFCREATEREQ *)VbglR0PhysHeapAlloc(RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath.String) + sf_i->path->u16Size);
    7979        if (pReq) {
    80             VBSF_UNFORTIFIED_MEMCPY(&pReq->StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size);
     80            RT_BCOPY_UNFORTIFIED(&pReq->StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size);
    8181            RT_ZERO(pReq->CreateParms);
    8282            pReq->CreateParms.Handle      = SHFL_HANDLE_NIL;
     
    688688
    689689            RT_ZERO(*pReq);
    690             VBSF_UNFORTIFIED_MEMCPY(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
     690            RT_BCOPY_UNFORTIFIED(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
    691691            pReq->CreateParms.Handle = SHFL_HANDLE_NIL;
    692692            pReq->CreateParms.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
     
    824824        } *pReq = (union CreateAuxReq *)VbglR0PhysHeapAlloc(RT_UOFFSETOF(VBOXSFCREATEREQ, StrPath.String) + path->u16Size);
    825825        if (pReq) {
    826             VBSF_UNFORTIFIED_MEMCPY(&pReq->Create.StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
     826            RT_BCOPY_UNFORTIFIED(&pReq->Create.StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
    827827            RT_ZERO(pReq->Create.CreateParms);
    828828            pReq->Create.CreateParms.Handle                  = SHFL_HANDLE_NIL;
     
    11311131                                                                       + path->u16Size);
    11321132        if (pReq) {
    1133             VBSF_UNFORTIFIED_MEMCPY(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
     1133            RT_BCOPY_UNFORTIFIED(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
    11341134            uint32_t fFlags = fDirectory ? SHFL_REMOVE_DIR : SHFL_REMOVE_FILE;
    11351135            if (dentry->d_inode && ((dentry->d_inode->i_mode & S_IFLNK) == S_IFLNK))
     
    12511251                    PSHFLSTRING             pOldPath = sf_file_i->path;
    12521252
    1253                     VBSF_UNFORTIFIED_MEMCPY(&pReq->StrDstPath, pNewPath, SHFLSTRING_HEADER_SIZE + pNewPath->u16Size);
     1253                    RT_BCOPY_UNFORTIFIED(&pReq->StrDstPath, pNewPath, SHFLSTRING_HEADER_SIZE + pNewPath->u16Size);
    12541254                    rc = VbglR0SfHostReqRenameWithSrcContig(pSuperInfo->map.root, pReq, pOldPath, virt_to_phys(pOldPath), fRename);
    12551255                    VbglR0PhysHeapFree(pReq);
     
    13521352            if (pReq) {
    13531353                RT_ZERO(*pReq);
    1354                 VBSF_UNFORTIFIED_MEMCPY(&pReq->StrSymlinkPath, pPath, SHFLSTRING_HEADER_SIZE + pPath->u16Size);
     1354                RT_BCOPY_UNFORTIFIED(&pReq->StrSymlinkPath, pPath, SHFLSTRING_HEADER_SIZE + pPath->u16Size);
    13551355
    13561356                rc = VbglR0SfHostReqCreateSymlinkContig(pSuperInfo->map.root, pTarget, virt_to_phys(pTarget), pReq);
  • trunk/src/VBox/Additions/linux/sharedfolders/regops.c

    r100799 r101359  
    30943094        return -ENOMEM;
    30953095    }
    3096     VBSF_UNFORTIFIED_MEMCPY(&pReq->StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size);
     3096    RT_BCOPY_UNFORTIFIED(&pReq->StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size);
    30973097    RT_ZERO(pReq->CreateParms);
    30983098    pReq->CreateParms.Handle = SHFL_HANDLE_NIL;
  • trunk/src/VBox/Additions/linux/sharedfolders/utils.c

    r101081 r101359  
    193193                pString->u16Length = (uint16_t)cchNls;
    194194                pString->u16Size   = (uint16_t)(cchNls + 1);
    195                 VBSF_UNFORTIFIED_MEMCPY(pString->String.ach, pszNls, cchNls);
     195                RT_BCOPY_UNFORTIFIED(pString->String.ach, pszNls, cchNls);
    196196                pString->String.ach[cchNls] = '\0';
    197197                rc = 0;
     
    518518    if (pReq) {
    519519        RT_ZERO(*pReq);
    520         VBSF_UNFORTIFIED_MEMCPY(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
     520        RT_BCOPY_UNFORTIFIED(&pReq->StrPath, path, SHFLSTRING_HEADER_SIZE + path->u16Size);
    521521        pReq->CreateParms.Handle = SHFL_HANDLE_NIL;
    522522        pReq->CreateParms.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
     
    604604                if (pReq) {
    605605                    RT_ZERO(*pReq);
    606                     VBSF_UNFORTIFIED_MEMCPY(&pReq->StrPath, pPath, SHFLSTRING_HEADER_SIZE + pPath->u16Size);
     606                    RT_BCOPY_UNFORTIFIED(&pReq->StrPath, pPath, SHFLSTRING_HEADER_SIZE + pPath->u16Size);
    607607                    pReq->CreateParms.Handle      = SHFL_HANDLE_NIL;
    608608                    pReq->CreateParms.CreateFlags = SHFL_CF_LOOKUP | SHFL_CF_ACT_FAIL_IF_NEW;
     
    907907                    if (fAttrs & ATTR_SIZE)
    908908                        pReq->Create.CreateParms.CreateFlags |= SHFL_CF_ACCESS_WRITE;
    909                     VBSF_UNFORTIFIED_MEMCPY(&pReq->Create.StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size);
     909                    RT_BCOPY_UNFORTIFIED(&pReq->Create.StrPath, sf_i->path, SHFLSTRING_HEADER_SIZE + sf_i->path->u16Size);
    910910                    vrc = VbglR0SfHostReqCreate(pSuperInfo->map.root, &pReq->Create);
    911911                    if (RT_SUCCESS(vrc)) {
     
    10451045
    10461046    if (fRoot)
    1047         VBSF_UNFORTIFIED_MEMCPY(&tmp->String.utf8[0], d_name, d_len + 1);
     1047        RT_BCOPY_UNFORTIFIED(&tmp->String.utf8[0], d_name, d_len + 1);
    10481048    else {
    1049         VBSF_UNFORTIFIED_MEMCPY(&tmp->String.utf8[0], p_name, p_len);
     1049        RT_BCOPY_UNFORTIFIED(&tmp->String.utf8[0], p_name, p_len);
    10501050        tmp->String.utf8[p_len] = '/';
    1051         VBSF_UNFORTIFIED_MEMCPY(&tmp->String.utf8[p_len + 1], d_name, d_len);
     1051        RT_BCOPY_UNFORTIFIED(&tmp->String.utf8[p_len + 1], d_name, d_len);
    10521052        tmp->String.utf8[p_len + 1 + d_len] = '\0';
    10531053    }
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.c

    r99420 r101359  
    119119    if ((unsigned)info->length >= RT_UOFFSETOF(struct vbsf_mount_info_new, cMaxIoPages)) {
    120120        AssertCompile(sizeof(pSuperInfo->szTag) >= sizeof(info->szTag));
    121         VBSF_UNFORTIFIED_MEMCPY(pSuperInfo->szTag, info->szTag, sizeof(info->szTag));
     121        RT_BCOPY_UNFORTIFIED(pSuperInfo->szTag, info->szTag, sizeof(info->szTag));
    122122        pSuperInfo->szTag[sizeof(pSuperInfo->szTag) - 1] = '\0';
    123123    } else {
     
    243243        str_name->u16Length = name_len;
    244244        str_name->u16Size = name_len + 1;
    245         VBSF_UNFORTIFIED_MEMCPY(str_name->String.utf8, info->name, name_len + 1);
     245        RT_BCOPY_UNFORTIFIED(str_name->String.utf8, info->name, name_len + 1);
    246246
    247247        /*
     
    14901490    if (data) {
    14911491        if (VBSF_IS_MOUNT_VBOXSF_DATA(data)) {
    1492             VBSF_UNFORTIFIED_MEMCPY(info, data, sizeof(struct vbsf_mount_info_new));
     1492            RT_BCOPY_UNFORTIFIED(info, data, sizeof(struct vbsf_mount_info_new));
    14931493        } else {
    14941494            /* this will call vbsf_parse_param() */
  • trunk/src/VBox/Additions/linux/sharedfolders/vfsmod.h

    r99433 r101359  
    7777# define SFLOG_ENABLED          1
    7878# define SFLOGRELBOTH(aArgs)    do { RTLogBackdoorPrintf aArgs; printk aArgs; } while (0)
    79 #endif
    80 
    81 
    82 /** Similar workaround for CONFIG_FORTIFY_SOURCE kernel config option as we
    83  * have in the host drivers.
    84  *
    85  * In Linux 5.18-rc1, memcpy became a wrapper which does fortify checks before
    86  * making a call to __underlying_memcpy().  There are a number of places where
    87  * we trigger the "field-spanning write" fortify check, typically when copying
    88  * to SHFLSTRING structure members as these are actually of variable length but
    89  * we don't (cannot with gcc) use RT_FLEXIBLE_ARRAY_NESTED.
    90  *
    91  * Use this when copying to structures or members with a variable length member.
    92  *
    93  * @see @ticketref{21410}, @bugref{10209}
    94  */
    95 #if RTLNX_VER_MIN(5,18,0) && !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
    96 # define VBSF_UNFORTIFIED_MEMCPY __underlying_memcpy
    97 #else
    98 # define VBSF_UNFORTIFIED_MEMCPY memcpy
    9979#endif
    10080
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