NDIS 6.x: How should a protocol driver return ordinary receive NBLs during pending NdisCloseAdapterEx?

Zbigniew Kananowicz 0 Punkty reputacji
2026-11-13T10:48:25.05+00:00

NDIS 6.x: How should a protocol driver return ordinary receive NBLs during pending NdisCloseAdapterEx?

Environment:

Windows 11 x64

NDIS 6.80

NDIS intermediate / MUX driver

Protocol lower-edge binding using NdisOpenAdapterEx

Receive handling through ProtocolReceiveNetBufferLists

Binding teardown through ProtocolUnbindAdapterEx and NdisCloseAdapterEx

Background

We are investigating a potential ambiguity in the documented NDIS 6.x protocol binding lifecycle.

According to the Microsoft documentation:

NdisCloseAdapterEx invalidates the binding handle immediately, and the protocol driver must not make subsequent NdisXxx calls using that handle.

ProtocolUnbindAdapterEx documentation indicates that receive indications may continue until the close operation completes.

ProtocolReceiveNetBufferLists requires a protocol driver to return received NBLs through NdisReturnNetBufferLists when NDIS_RECEIVE_FLAGS_RESOURCES is not set and the NBLs are retained.

These statements appear to leave an unresolved edge case.

Specific race condition

Consider the following sequence:

T0: ProtocolUnbindAdapterEx begins

T1: The protocol stops forwarding received NBLs
    to its upper-edge virtual miniport.

T2: All previously retained receive NBLs
    are returned to the lower binding.

T3: NdisCloseAdapterEx is called.
    The binding handle becomes invalid.

T4: NdisCloseAdapterEx returns NDIS_STATUS_PENDING.

T5: Before ProtocolCloseAdapterCompleteEx,
    NDIS invokes ProtocolReceiveNetBufferLists
    with a new NBL and without
    NDIS_RECEIVE_FLAGS_RESOURCES.

T6: The protocol does not retain or forward
    the NBL, but needs to return it.

At T6, the protocol appears to be required to call NdisReturnNetBufferLists, while the binding handle has already been invalidated.

Questions for the NDIS engineering team

  1. Can an ordinary receive indication occur during pending Close?

After NdisCloseAdapterEx has been called, but before ProtocolCloseAdapterCompleteEx, can NDIS legally invoke ProtocolReceiveNetBufferLists with NDIS_RECEIVE_FLAGS_RESOURCES cleared?

  1. Is there an exception for NBL returns?

If such an ordinary receive is possible, is NdisReturnNetBufferLists explicitly permitted with the closing binding handle, despite the general handle invalidation rule?

Does this exception also apply to NBLs received before Close but returned during pending Close?

  1. Does NDIS guarantee special handling of late receives?

Does NDIS guarantee that receive indications occurring after Close begins:

always have NDIS_RECEIVE_FLAGS_RESOURCES set;

are completed or synchronized before the handle becomes invalid;

or follow another documented rule that makes an explicit return unnecessary?

  1. What is the correct teardown sequence?

What is the Microsoft-recommended sequence for an NDIS 6.x intermediate/MUX protocol driver to guarantee that:

no retained receive NBLs remain when the binding is destroyed;

no received NBL is leaked;

no invalid binding handle is used;

no use-after-free occurs;

receive indications concurrent with Unbind/Close are handled legally?

  1. How does the Microsoft NDIS MUX Sample address this case?

The official MUX sample appears to drain already outstanding receive NBLs before closing the lower binding.

However, we have not identified a documented guarantee preventing a new ordinary receive indication from arriving after NdisCloseAdapterEx begins.

Is the sample relying on an NDIS synchronization guarantee that is not explicitly described in the API documentation?

What we are trying to establish

We are not asking how to implement a generic receive rundown counter.

We specifically need to understand the documented NDIS contract for the interval:

NdisCloseAdapterEx call → ProtocolCloseAdapterCompleteEx

and the legal handling of ordinary receive NBLs during that interval.

A clarification from the Windows Networking / NDIS engineering team, ideally with a reference to the applicable API contract, would be greatly appreciated.

Thank you.

NDIS 6.x: How should a protocol driver return ordinary receive NBLs during pending NdisCloseAdapterEx?

Environment:

Windows 11 x64

NDIS 6.80

NDIS intermediate / MUX driver

Protocol lower-edge binding using NdisOpenAdapterEx

Receive handling through ProtocolReceiveNetBufferLists

Binding teardown through ProtocolUnbindAdapterEx and NdisCloseAdapterEx

Background

We are investigating a potential ambiguity in the documented NDIS 6.x protocol binding lifecycle.

According to the Microsoft documentation:

NdisCloseAdapterEx invalidates the binding handle immediately, and the protocol driver must not make subsequent NdisXxx calls using that handle.

ProtocolUnbindAdapterEx documentation indicates that receive indications may continue until the close operation completes.

ProtocolReceiveNetBufferLists requires a protocol driver to return received NBLs through NdisReturnNetBufferLists when NDIS_RECEIVE_FLAGS_RESOURCES is not set and the NBLs are retained.

These statements appear to leave an unresolved edge case.

Specific race condition

Consider the following sequence:

T0: ProtocolUnbindAdapterEx begins

T1: The protocol stops forwarding received NBLs
    to its upper-edge virtual miniport.

T2: All previously retained receive NBLs
    are returned to the lower binding.

T3: NdisCloseAdapterEx is called.
    The binding handle becomes invalid.

T4: NdisCloseAdapterEx returns NDIS_STATUS_PENDING.

T5: Before ProtocolCloseAdapterCompleteEx,
    NDIS invokes ProtocolReceiveNetBufferLists
    with a new NBL and without
    NDIS_RECEIVE_FLAGS_RESOURCES.

T6: The protocol does not retain or forward
    the NBL, but needs to return it.

At T6, the protocol appears to be required to call NdisReturnNetBufferLists, while the binding handle has already been invalidated.

Questions for the NDIS engineering team

  1. Can an ordinary receive indication occur during pending Close?

After NdisCloseAdapterEx has been called, but before ProtocolCloseAdapterCompleteEx, can NDIS legally invoke ProtocolReceiveNetBufferLists with NDIS_RECEIVE_FLAGS_RESOURCES cleared?

  1. Is there an exception for NBL returns?

If such an ordinary receive is possible, is NdisReturnNetBufferLists explicitly permitted with the closing binding handle, despite the general handle invalidation rule?

Does this exception also apply to NBLs received before Close but returned during pending Close?

  1. Does NDIS guarantee special handling of late receives?

Does NDIS guarantee that receive indications occurring after Close begins:

always have NDIS_RECEIVE_FLAGS_RESOURCES set;

are completed or synchronized before the handle becomes invalid;

or follow another documented rule that makes an explicit return unnecessary?

  1. What is the correct teardown sequence?

What is the Microsoft-recommended sequence for an NDIS 6.x intermediate/MUX protocol driver to guarantee that:

no retained receive NBLs remain when the binding is destroyed;

no received NBL is leaked;

no invalid binding handle is used;

no use-after-free occurs;

receive indications concurrent with Unbind/Close are handled legally?

  1. How does the Microsoft NDIS MUX Sample address this case?

The official MUX sample appears to drain already outstanding receive NBLs before closing the lower binding.

However, we have not identified a documented guarantee preventing a new ordinary receive indication from arriving after NdisCloseAdapterEx begins.

Is the sample relying on an NDIS synchronization guarantee that is not explicitly described in the API documentation?

What we are trying to establish

We are not asking how to implement a generic receive rundown counter.

We specifically need to understand the documented NDIS contract for the interval:

NdisCloseAdapterEx call → ProtocolCloseAdapterCompleteEx

and the legal handling of ordinary receive NBLs during that interval.

A clarification from the Windows Networking / NDIS engineering team, ideally with a reference to the applicable API contract, would be greatly appreciated.

Thank you.

Windows dla firm | Windows Server | Urządzenia i wdrożenie | Konfigurowanie uaktualnień i sterowników
Komentarze: 0 Brak komentarzy

1 odpowiedź

Sortuj według: Najbardziej pomocne
  1. Ronald Sabiiti 2,250 Punkty reputacji Niezależny doradca
    2026-11-13T11:34:11.6766667+00:00

    Cześć!

    Dziękuję za szczegółowe wyjaśnienie. Postawiłeś trafne pytanie dotyczące obsługi odbioru NDIS podczas oczekującego zamknięcia adaptera.

    Dokumenty Microsoftu, które otrzymają wskaźniki, mogą być kontynuowane do zakończenia operacji zamknięcia. Jednak uchwyt wiązania staje się nieważny po NdisCloseAdapterEx wywołaniu i zwykłe otrzymanie NBL musi być zwracane, gdy NDIS_RECEIVE_FLAGS_RESOURCES nie jest ustawione.

    Dokumentacja publiczna nie precyzuje wyraźnie, jak postępować z zwykłą oznamową wiadomością przybywającą w tym okresie oczekującym-zamkniętym, w szczególności czy NdisReturnNetBufferLists jest dozwolone użycie uchwytu zamykającego.

    Dla porównania:

    Biorąc pod uwagę potencjalny wpływ na stabilność kierowcy, polecam uzyskać wyjaśnienia od zespołu inżynieryjnego NDIS na temat wspieranego obsługiwania późnych sygnałów odbioru podczas oczekującego zamknięcia.

    Mam nadzieję, że to pomoże!

    Ronald.

    Czy ta odpowiedź była pomocna?

    Komentarze: 0 Brak komentarzy

Twoja odpowiedź

Odpowiedzi mogą być oznaczone jako „Zaakceptowane” przez autora pytań i „Proponowane” przez moderatorów, co pomaga użytkownikom poznać odpowiedź rozwiązującą problem autora.