VirtualBox

Ignore:
Timestamp:
Nov 10, 2015 4:33:48 PM (9 years ago)
Author:
vboxsync
Message:

NetLwf/win: Allocate miniport name buffer from non-paged pool.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetLwf-win.cpp

    r57831 r58651  
    189189    NDIS_HANDLE hWorkItem;
    190190#endif /* !VBOXNETLWF_SYNC_SEND */
    191     /** Name of underlying adapter */
    192     ANSI_STRING strMiniportName;
    193191    /** MAC address of underlying adapter */
    194192    RTMAC MacAddr;
     
    203201    /** true if the host wants the adapter to be in promisc mode */
    204202    bool fHostPromisc;
     203    /** Name of underlying adapter */
     204    char szMiniportName[1];
    205205} VBOXNETLWF_MODULE;
    206206typedef VBOXNETLWF_MODULE *PVBOXNETLWF_MODULE;
     
    775775    AssertReturn(pGlobals, NDIS_STATUS_FAILURE);
    776776
     777    ANSI_STRING strMiniportName;
     778    /* We use the miniport name to associate this filter module with the netflt instance */
     779    NTSTATUS rc = RtlUnicodeStringToAnsiString(&strMiniportName,
     780                                               pParameters->BaseMiniportName,
     781                                               TRUE);
     782    if (rc != STATUS_SUCCESS)
     783    {
     784        Log(("ERROR! vboxNetLwfWinAttach: RtlUnicodeStringToAnsiString(%ls) failed with 0x%x\n",
     785             pParameters->BaseMiniportName, rc));
     786        return NDIS_STATUS_FAILURE;
     787    }
     788    DbgPrint("vboxNetLwfWinAttach: friendly name=%wZ\n", pParameters->BaseMiniportInstanceName);
     789    DbgPrint("vboxNetLwfWinAttach: name=%Z\n", strMiniportName);
     790
     791    UINT cbModuleWithNameExtra = sizeof(VBOXNETLWF_MODULE) + strMiniportName.Length;
    777792    PVBOXNETLWF_MODULE pModuleCtx = (PVBOXNETLWF_MODULE)NdisAllocateMemoryWithTagPriority(hFilter,
    778                                                                       sizeof(VBOXNETLWF_MODULE),
     793                                                                      cbModuleWithNameExtra,
    779794                                                                      VBOXNETLWF_MEM_TAG,
    780795                                                                      LowPoolPriority);
    781796    if (!pModuleCtx)
     797    {
     798        RtlFreeAnsiString(&strMiniportName);
    782799        return NDIS_STATUS_RESOURCES;
     800    }
    783801    Log4(("vboxNetLwfWinAttach: allocated module context 0x%p\n", pModuleCtx));
    784802
    785     NdisZeroMemory(pModuleCtx, sizeof(VBOXNETLWF_MODULE));
     803    NdisZeroMemory(pModuleCtx, cbModuleWithNameExtra);
     804    NdisMoveMemory(pModuleCtx->szMiniportName, strMiniportName.Buffer, strMiniportName.Length);
     805    RtlFreeAnsiString(&strMiniportName);
    786806
    787807    pModuleCtx->hWorkItem = NdisAllocateIoWorkItem(g_VBoxNetLwfGlobals.hFilterDriver);
     
    793813        return NDIS_STATUS_RESOURCES;
    794814    }
    795 
    796     /* We use the miniport name to associate this filter module with the netflt instance */
    797     NTSTATUS rc = RtlUnicodeStringToAnsiString(&pModuleCtx->strMiniportName,
    798                                                pParameters->BaseMiniportName,
    799                                                TRUE);
    800     if (rc != STATUS_SUCCESS)
    801     {
    802         Log(("ERROR! vboxNetLwfWinAttach: RtlUnicodeStringToAnsiString(%ls) failed with 0x%x\n",
    803              pParameters->BaseMiniportName, rc));
    804         NdisFreeIoWorkItem(pModuleCtx->hWorkItem);
    805         NdisFreeMemory(pModuleCtx, 0, 0);
    806         return NDIS_STATUS_FAILURE;
    807     }
    808     DbgPrint("vboxNetLwfWinAttach: friendly name=%wZ\n", pParameters->BaseMiniportInstanceName);
    809     DbgPrint("vboxNetLwfWinAttach: name=%Z\n", pModuleCtx->strMiniportName);
    810815
    811816    Assert(pParameters->MacAddressLength == sizeof(RTMAC));
     
    844849    {
    845850        Log(("ERROR! vboxNetLwfWinAttach: NdisAllocateNetBufferListPool failed\n"));
    846         RtlFreeAnsiString(&pModuleCtx->strMiniportName);
    847851        NdisFreeIoWorkItem(pModuleCtx->hWorkItem);
    848852        NdisFreeMemory(pModuleCtx, 0, 0);
     
    863867        NdisFreeNetBufferListPool(pModuleCtx->hPool);
    864868        Log4(("vboxNetLwfWinAttach: freed NBL+NB pool 0x%p\n", pModuleCtx->hPool));
    865         RtlFreeAnsiString(&pModuleCtx->strMiniportName);
    866869        NdisFreeIoWorkItem(pModuleCtx->hWorkItem);
    867870        NdisFreeMemory(pModuleCtx, 0, 0);
     
    917920        Log4(("vboxNetLwfWinDetach: freed NBL+NB pool 0x%p\n", pModuleCtx->hPool));
    918921    }
    919     RtlFreeAnsiString(&pModuleCtx->strMiniportName);
    920922    NdisFreeIoWorkItem(pModuleCtx->hWorkItem);
    921923    NdisFreeMemory(hModuleCtx, 0, 0);
     
    21272129        else
    21282130        {
    2129             DbgPrint("VBoxNetLwf: no saved offload config to modify for %Z\n", pModuleCtx->strMiniportName);
     2131            DbgPrint("VBoxNetLwf: no saved offload config to modify for %s\n", pModuleCtx->szMiniportName);
    21302132            NdisZeroMemory(&OffloadConfig, sizeof(OffloadConfig));
    21312133            OffloadConfig.Header.Type = NDIS_OBJECT_TYPE_OFFLOAD;
     
    21452147        }
    21462148        else
    2147             DbgPrint("VBoxNetLwf: no saved offload config to restore for %Z\n", pModuleCtx->strMiniportName);
     2149            DbgPrint("VBoxNetLwf: no saved offload config to restore for %s\n", pModuleCtx->szMiniportName);
    21482150    }
    21492151}
     
    23322334    AssertReturn(pThis, VERR_INVALID_PARAMETER);
    23332335    Log(("vboxNetFltOsInitInstance: trunk name=%s\n", pThis->szName));
    2334     ANSI_STRING strInst;
    2335     RtlInitAnsiString(&strInst, pThis->szName);
    23362336    PVBOXNETLWF_MODULE pModuleCtx = NULL;
    23372337    NdisAcquireSpinLock(&g_VBoxNetLwfGlobals.Lock);
    23382338    RTListForEach(&g_VBoxNetLwfGlobals.listModules, pModuleCtx, VBOXNETLWF_MODULE, node)
    23392339    {
    2340         DbgPrint("vboxNetFltOsInitInstance: evaluating module, name=%Z\n", pModuleCtx->strMiniportName);
    2341         if (RtlEqualString(&strInst, &pModuleCtx->strMiniportName, TRUE))
     2340        DbgPrint("vboxNetFltOsInitInstance: evaluating module, name=%s\n", pModuleCtx->szMiniportName);
     2341        if (!RTStrICmp(pThis->szName, pModuleCtx->szMiniportName))
    23422342        {
    23432343            NdisReleaseSpinLock(&g_VBoxNetLwfGlobals.Lock);
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