VirtualBox

Changeset 104954 in vbox


Ignore:
Timestamp:
Jun 18, 2024 11:14:14 AM (7 months ago)
Author:
vboxsync
Message:

Additions/solaris/vboxfs_mount,Additions/VBoxService/VBoxServiceAutoMount:
The Solaris mount(2) system call limits the size of the mount options
buffer to MAX_MNTOPT_STR from <sys/mount.h> (currently 1024). Passing a
buffer size larger than this results in a failure with mount(2)
returning EINVAL which in this case prevents users from being able to
mount shared folders by hand. Undo a regression introduced in r158032.

Location:
trunk/src/VBox/Additions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceAutoMount.cpp

    r100331 r104954  
    389389    if (RT_SUCCESS(rc))
    390390    {
    391         uint32_t cbOpts = RTSystemGetPageSize();
    392         char *pszOpts = (char *)alloca(cbOpts);
    393         RT_BZERO(pszOpts, cbOpts);
    394 
    395391# ifdef RT_OS_SOLARIS
    396392        int const fFlags = MS_OPTIONSTR;
    397         RTStrPrintf(pszOpts, cbOpts, "uid=0,gid=%d,dmode=0770,fmode=0770,dmask=0000,fmask=0000", grp_vboxsf->gr_gid);
     393        char szOptBuf[MAX_MNTOPT_STR] = { '\0', };
     394        RTStrPrintf(szOptBuf, sizeof(szOptBuf), "uid=0,gid=%d,dmode=0770,fmode=0770,dmask=0000,fmask=0000", grp_vboxsf->gr_gid);
    398395        int r = mount(pszShareName,
    399396                      pszMountPoint,
     
    402399                      NULL,                     /* char *dataptr */
    403400                      0,                        /* int datalen */
    404                       pszOpts,
    405                       cbOpts);
     401                      szOptBuf,
     402                      sizeof(szOptBuf));
    406403        if (r == 0)
    407404            VGSvcVerbose(0, "vbsvcAutoMountWorker: Shared folder '%s' was mounted to '%s'\n", pszShareName, pszMountPoint);
     
    411408
    412409# else /* RT_OS_LINUX */
     410        uint32_t cbOpts = RTSystemGetPageSize();
     411        char *pszOpts = (char *)alloca(cbOpts);
     412        RT_BZERO(pszOpts, cbOpts);
    413413        struct utsname uts;
    414414        AssertStmt(uname(&uts) != -1, strcpy(uts.release, "4.4.0"));
     
    14691469    }
    14701470
     1471#  if defined(RT_OS_LINUX)
     1472    /*
     1473     * Linux a bit more work...
     1474     */
     1475    struct utsname uts;
     1476    AssertStmt(uname(&uts) != -1, strcpy(uts.release, "4.4.0"));
    14711477    /*
    14721478     * Allocate options string buffer which is limited to a page on most systems.
     
    14741480    uint32_t cbOpts = RTSystemGetPageSize();
    14751481    char *pszOpts = (char *)alloca(cbOpts);
    1476 
    1477 #  if defined(RT_OS_LINUX)
    1478     /*
    1479      * Linux a bit more work...
    1480      */
    1481     struct utsname uts;
    1482     AssertStmt(uname(&uts) != -1, strcpy(uts.release, "4.4.0"));
    14831482
    14841483    /* Built mount option string.  Need st_name for pre 2.6.0 kernels. */
     
    15381537     *       with EOVERFLOW in vfs_buildoptionstr() during domount() otherwise.
    15391538     */
    1540     ssize_t cchOpts = RTStrPrintf2(pszOpts, cbOpts,
     1539    char szOpts[MAX_MNTOPT_STR] = { '\0', };
     1540    ssize_t cchOpts = RTStrPrintf2(szOpts, sizeof(szOpts),
    15411541                                   "uid=0,gid=%d,dmode=0770,fmode=0770,dmask=0000,fmask=0000,tag=%s", gidMount, g_szTag);
    15421542    if (cchOpts <= 0)
    15431543    {
    1544         VGSvcError("vbsvcAutomounterMountIt: pszOpts overflow! %zd\n", cchOpts);
     1544        VGSvcError("vbsvcAutomounterMountIt: szOpts overflow! %zd\n", cchOpts);
    15451545        return VERR_BUFFER_OVERFLOW;
    15461546    }
    15471547
    15481548    rc = mount(pEntry->pszName, pEntry->pszActualMountPoint, MS_OPTIONSTR, "vboxfs",
    1549                NULL /*dataptr*/, 0 /* datalen */, pszOpts, MAX_MNTOPT_STR);
     1549               NULL /*dataptr*/, 0 /* datalen */, szOpts, MAX_MNTOPT_STR);
    15501550    if (rc == 0)
    15511551    {
     
    15561556
    15571557    rc = errno;
    1558     VGSvcError("vbsvcAutomounterMountIt: mount failed for '%s' on '%s' (pszOpts=%s): %s (%d)\n",
    1559                pEntry->pszName, pEntry->pszActualMountPoint, pszOpts, strerror(rc), rc);
     1558    VGSvcError("vbsvcAutomounterMountIt: mount failed for '%s' on '%s' (szOpts=%s): %s (%d)\n",
     1559               pEntry->pszName, pEntry->pszActualMountPoint, szOpts, strerror(rc), rc);
    15601560    return VERR_OPEN_FAILED;
    15611561
  • trunk/src/VBox/Additions/solaris/SharedFolders/vboxfs_mount.c

    r100317 r104954  
    4747#include <sys/mount.h>
    4848
    49 #include <iprt/param.h> /* For PAGE_SIZE */
    50 
    5149#include "vboxfs.h"
    5250
     
    5553*   Global Variables                                                                                                             *
    5654*********************************************************************************************************************************/
    57 static char g_achOptBuf[PAGE_SIZE] = { '\0', };
     55static char g_achOptBuf[MAX_MNTOPT_STR] = { '\0', };
    5856static const int g_RetErr = 33;
    5957static const int g_RetMagic = 2;
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