VirtualBox

Changeset 51100 in vbox for trunk


Ignore:
Timestamp:
Apr 17, 2014 5:50:33 PM (11 years ago)
Author:
vboxsync
Message:

SUPDrv-darwin.cpp: Fixed buggy g_apSessionHashTab search in VBoxDrvDarwinIOCtl that could lead to spurious EINVAL/VERR_INVALID_PARAMETER errors and worse.

File:
1 edited

Legend:

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

    r49965 r51100  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    455455
    456456    /*
     457     * The process issuing the request must be the current process.
     458     */
     459    RTPROCESS Process = RTProcSelf();
     460    if (Process != proc_pid(pProcess))
     461        return EIO;
     462
     463    /*
    457464     * Find the session created by org_virtualbox_SupDrvClient, fail
    458465     * if no such session, and mark it as opened. We set the uid & gid
     
    472479        RTGID           Gid = pCred->cr_rgid;
    473480#endif
    474         RTPROCESS       Process = RTProcSelf();
    475481        unsigned        iHash = SESSION_HASH(Process);
    476482        RTSpinlockAcquire(g_Spinlock);
     
    552558     */
    553559    RTSpinlockAcquire(g_Spinlock);
     560
    554561    pSession = g_apSessionHashTab[iHash];
    555     while (pSession && pSession->Process != Process && pSession->fUnrestricted == fUnrestricted && pSession->fOpened)
     562    while (pSession && (pSession->Process != Process || pSession->fUnrestricted != fUnrestricted || !pSession->fOpened))
    556563        pSession = pSession->pNextHash;
    557564
    558565    if (RT_LIKELY(pSession))
    559566        supdrvSessionRetain(pSession);
     567
    560568    RTSpinlockReleaseNoInts(g_Spinlock);
    561     if (!pSession)
     569    if (RT_UNLIKELY(!pSession))
    562570    {
    563571        OSDBGPRINT(("VBoxDrvDarwinIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#lx\n",
     
    14111419
    14121420                PSUPDRVSESSION pCur = g_apSessionHashTab[iHash];
    1413                 if (pCur && pCur->Process != m_pSession->Process)
    1414                 {
    1415                     do pCur = pCur->pNextHash;
    1416                     while (pCur && pCur->Process != m_pSession->Process);
    1417                 }
     1421                while (pCur && pCur->Process != m_pSession->Process)
     1422                    pCur = pCur->pNextHash;
    14181423                if (!pCur)
    14191424                {
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