VirtualBox

Changeset 39890 in vbox for trunk/src/VBox/Additions/common


Ignore:
Timestamp:
Jan 26, 2012 7:42:19 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75940
Message:

VMMDev,IGuest,IAdditionsFacility,VBoxGuest,iprt/types.h: VMMDev must track the guest facility reports so they can be saved and restored correctly. Also fixed a reset bug related to guestInfo2. Restrict who can report the status of which facilities. Recalc the runlevel based on which facilities are active. Restrict the number of facilities main tracks.

File:
1 edited

Legend:

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

    r38974 r39890  
    14131413}
    14141414
     1415/**
     1416 * Checks if the VMM request is allowed in the context of the given session.
     1417 *
     1418 * @returns VINF_SUCCESS or VERR_PERMISSION_DENIED.
     1419 * @param   pSession            The calling session.
     1420 * @param   enmType             The request type.
     1421 * @param   pReqHdr             The request.
     1422 */
     1423static int VBoxGuestCheckIfVMMReqAllowed(PVBOXGUESTSESSION pSession, VMMDevRequestType enmType,
     1424                                         VMMDevRequestHeader const *pReqHdr)
     1425{
     1426    /*
     1427     * Categorize the request being made.
     1428     */
     1429    /** @todo This need quite some more work! */
     1430    enum
     1431    {
     1432        kLevel_Invalid, kLevel_NoOne, kLevel_OnlyVBoxGuest, kLevel_OnlyKernel, kLevel_TrustedUsers, kLevel_AllUsers
     1433    } enmRequired;
     1434    switch (enmType)
     1435    {
     1436        /*
     1437         * Deny access to anything we don't know or provide specialized I/O controls for.
     1438         */
     1439#ifdef VBOX_WITH_HGCM
     1440        case VMMDevReq_HGCMConnect:
     1441        case VMMDevReq_HGCMDisconnect:
     1442# ifdef VBOX_WITH_64_BITS_GUESTS
     1443        case VMMDevReq_HGCMCall32:
     1444        case VMMDevReq_HGCMCall64:
     1445# else
     1446        case VMMDevReq_HGCMCall:
     1447# endif /* VBOX_WITH_64_BITS_GUESTS */
     1448        case VMMDevReq_HGCMCancel:
     1449        case VMMDevReq_HGCMCancel2:
     1450#endif /* VBOX_WITH_HGCM */
     1451        default:
     1452            enmRequired = kLevel_NoOne;
     1453            break;
     1454
     1455        /*
     1456         * There are a few things only this driver can do (and it doesn't use
     1457         * the VMMRequst I/O control route anyway, but whatever).
     1458         */
     1459        case VMMDevReq_ReportGuestInfo:
     1460        case VMMDevReq_ReportGuestInfo2:
     1461        case VMMDevReq_GetHypervisorInfo:
     1462        case VMMDevReq_SetHypervisorInfo:
     1463        case VMMDevReq_RegisterPatchMemory:
     1464        case VMMDevReq_DeregisterPatchMemory:
     1465        case VMMDevReq_GetMemBalloonChangeRequest:
     1466            enmRequired = kLevel_OnlyVBoxGuest;
     1467            break;
     1468
     1469        /*
     1470         * Trusted users apps only.
     1471         */
     1472        case VMMDevReq_QueryCredentials:
     1473        case VMMDevReq_ReportCredentialsJudgement:
     1474        case VMMDevReq_RegisterSharedModule:
     1475        case VMMDevReq_UnregisterSharedModule:
     1476        case VMMDevReq_WriteCoreDump:
     1477        case VMMDevReq_GetCpuHotPlugRequest:
     1478        case VMMDevReq_SetCpuHotPlugStatus:
     1479        case VMMDevReq_CheckSharedModules:
     1480        case VMMDevReq_GetPageSharingStatus:
     1481        case VMMDevReq_DebugIsPageShared:
     1482        case VMMDevReq_ReportGuestStats:
     1483        case VMMDevReq_GetStatisticsChangeRequest:
     1484        case VMMDevReq_ChangeMemBalloon:
     1485            enmRequired = kLevel_TrustedUsers;
     1486            break;
     1487
     1488        /*
     1489         * Anyone.
     1490         */
     1491        case VMMDevReq_GetMouseStatus:
     1492        case VMMDevReq_SetMouseStatus:
     1493        case VMMDevReq_SetPointerShape:
     1494        case VMMDevReq_GetHostVersion:
     1495        case VMMDevReq_Idle:
     1496        case VMMDevReq_GetHostTime:
     1497        case VMMDevReq_SetPowerStatus:
     1498        case VMMDevReq_AcknowledgeEvents:
     1499        case VMMDevReq_CtlGuestFilterMask:
     1500        case VMMDevReq_ReportGuestStatus:
     1501        case VMMDevReq_GetDisplayChangeRequest:
     1502        case VMMDevReq_VideoModeSupported:
     1503        case VMMDevReq_GetHeightReduction:
     1504        case VMMDevReq_GetDisplayChangeRequest2:
     1505        case VMMDevReq_SetGuestCapabilities:
     1506        case VMMDevReq_VideoModeSupported2:
     1507        case VMMDevReq_VideoAccelEnable:
     1508        case VMMDevReq_VideoAccelFlush:
     1509        case VMMDevReq_VideoSetVisibleRegion:
     1510        case VMMDevReq_GetSeamlessChangeRequest:
     1511        case VMMDevReq_GetVRDPChangeRequest:
     1512        case VMMDevReq_LogString:
     1513        case VMMDevReq_GetSessionId:
     1514            enmRequired = kLevel_AllUsers;
     1515            break;
     1516
     1517        /*
     1518         * Depends on the request parameters...
     1519         */
     1520        /** @todo this have to be changed into an I/O control and the facilities
     1521         *        tracked in the session so they can automatically be failed when the
     1522         *        session terminates without reporting the new status.
     1523         *
     1524         *  The information presented by IGuest is not reliable without this! */
     1525        case VMMDevReq_ReportGuestCapabilities:
     1526            switch (((VMMDevReportGuestStatus const *)pReqHdr)->guestStatus.facility)
     1527            {
     1528                case VBoxGuestFacilityType_All:
     1529                case VBoxGuestFacilityType_VBoxGuestDriver:
     1530                    enmRequired = kLevel_OnlyVBoxGuest;
     1531                    break;
     1532                case VBoxGuestFacilityType_VBoxService:
     1533                    enmRequired = kLevel_TrustedUsers;
     1534                    break;
     1535                case VBoxGuestFacilityType_VBoxTrayClient:
     1536                case VBoxGuestFacilityType_Seamless:
     1537                case VBoxGuestFacilityType_Graphics:
     1538                default:
     1539                    enmRequired = kLevel_AllUsers;
     1540                    break;
     1541            }
     1542            break;
     1543    }
     1544
     1545    /*
     1546     * Check against the session.
     1547     */
     1548    switch (enmRequired)
     1549    {
     1550        default:
     1551        case kLevel_NoOne:
     1552            break;
     1553        case kLevel_OnlyVBoxGuest:
     1554        case kLevel_OnlyKernel:
     1555            if (pSession->R0Process == NIL_RTR0PROCESS)
     1556                return VINF_SUCCESS;
     1557            break;
     1558        case kLevel_TrustedUsers:
     1559        case kLevel_AllUsers:
     1560            return VINF_SUCCESS;
     1561    }
     1562
     1563    return VERR_PERMISSION_DENIED;
     1564}
    14151565
    14161566static int VBoxGuestCommonIOCtl_VMMRequest(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
     
    14461596        Log(("VBoxGuestCommonIOCtl: VMMREQUEST: invalid header: size %#x, expected >= %#x (hdr); type=%#x; rc=%Rrc!!\n",
    14471597             cbData, cbReq, enmType, rc));
     1598        return rc;
     1599    }
     1600
     1601    rc = VBoxGuestCheckIfVMMReqAllowed(pSession, enmType, pReqHdr);
     1602    if (RT_FAILURE(rc))
     1603    {
     1604        Log(("VBoxGuestCommonIOCtl: VMMREQUEST: Operation not allowed! type=%#x rc=%Rrc\n", enmType, rc));
    14481605        return rc;
    14491606    }
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