VirtualBox

Changeset 32338 in vbox


Ignore:
Timestamp:
Sep 9, 2010 11:12:45 AM (14 years ago)
Author:
vboxsync
Message:

NetFlt/win: fix possible stack overflow for loopback handling on heavy network load

Location:
trunk/src/VBox/HostDrivers/VBoxNetFlt/win
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltCommon-win.h

    r29682 r32338  
    366366    /** number of packets in the aReceivedPackets array*/
    367367    ULONG                          cReceivedPacketCount;
     368    /** flag indicating whether rx packet queueing is allowed */
     369    BOOLEAN                        bIsReceivePacketQueueingDisabled;
    368370    /** packet filter flags set by the upper protocols */
    369371    ULONG                          fUpperProtocolSetFilter;
  • trunk/src/VBox/HostDrivers/VBoxNetFlt/win/VBoxNetFltPt-win.c

    r29616 r32338  
    328328
    329329        pAdapt->cReceivedPacketCount = 0;
     330        /* reset the value in case */
     331        pAdapt->bIsReceivePacketQueueingDisabled = FALSE;
    330332        ReturnPackets = TRUE;
    331333    }
     
    876878         */
    877879
    878         if ((pAdapt->cReceivedPacketCount == MAX_RECEIVE_PACKET_ARRAY_SIZE) || DoIndicate || bReturn)
     880        if ((pAdapt->cReceivedPacketCount == MAX_RECEIVE_PACKET_ARRAY_SIZE) || DoIndicate || bReturn
     881                || pAdapt->bIsReceivePacketQueueingDisabled)
    879882        {
    880883            NdisMoveMemory(PacketArray,
     
    891894            {
    892895                DoIndicate = TRUE;
     896                pAdapt->bIsReceivePacketQueueingDisabled = TRUE;
    893897            }
    894898        }
     
    900904        if(DoIndicate)
    901905        {
     906            /* the tcp stack can send ACK packets right in the context of its PtReceive for this packet,
     907             * and thoose (tcp-sent) packets can be looped back again.
     908             * If this happens there is a possibility that new RX packets are received by us
     909             * after we do this NdisMIndicateReceivePacket and before we do a new NdisMIndicateReceivePacket
     910             * for the looped back tcp-sent packet.
     911             * If we queue those newly received packets and indicate them together with the looped back packet
     912             * with the latter NdisMIndicateReceivePacket, we may end up tcp stack sending ACKs in the context of its PtReceive again.
     913             * Thus this may lead to stack overflows on a heavy network loads.
     914             * To prevent this we disable the RX packet queuing when we do NdisMIndicateReceivePacket here,
     915             * thus if new packets arrive to us in another thread, we simply indicate them up instead of queuing them.
     916             * */
     917            Assert(pAdapt->bIsReceivePacketQueueingDisabled);
    902918            NdisMIndicateReceivePacket(pAdapt->hMiniportHandle, PacketArray, NumberOfPackets);
     919            RTSpinlockAcquireNoInts(pNetFlt->hSpinlock, &Tmp);
     920            pAdapt->bIsReceivePacketQueueingDisabled = FALSE;
     921            RTSpinlockReleaseNoInts(pNetFlt->hSpinlock, &Tmp);
    903922        }
    904923    }
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