microsoft / xdp-for-windows

XDP speeds up networking on Windows
MIT License
372 stars 41 forks source link

Fix two bugs mishandling fragmented frames #508

Closed mtfriesen closed 6 months ago

mtfriesen commented 6 months ago

While testing the new RSC forwarding feature, I discovered two latent bugs in handling fragmented frames.

  1. The built-in filtering engine failed to properly handle cases where the fast (contiguous) routine partially validated and cached headers before falling back to the fragment parsing routine. When this happened, the wrong bytes were copied into the contiguous header buffer, leading to incorrect filtering.
  2. The generic TX forwarding action allowed packets containing potentially discontiguous headers onto the local RX path, which on older builds of Windows causes bugchecks, and on newer builds causes packet drops. Avoid this by copying the entire packet if such a fragmented packet occurs. This could impact performance because most IPv4 traffic and UDPv6 traffic generated by the TCPIP stack will be discontiguous within the safe "lookahead" buffer range, but there is currently no known usage of forwarding on the TX inspection path, so opt for correctness and simplicity for now.

Add automated tests that exposed these bugs.

csujedihy commented 6 months ago

You've got some downlevel test failures that seem to be related to the changes you made.

mtfriesen commented 6 months ago

You've got some downlevel test failures that seem to be related to the changes you made.

Yup, I expected as much. I plan to backport this fix to the release branch (though not spin up a release for it) and update the test artifacts.