Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfriesen committed Dec 17, 2024
1 parent f85a4c9 commit 78e7865
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/xdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,6 @@ XskFillTx(
continue;
}


if (Buffer->DataLength > min(Xsk->Tx.Xdp.MaxBufferLength, Xsk->Tx.Xdp.MaxFrameLength)) {
Xsk->Statistics.TxInvalidDescriptors++;
STAT_INC(XdpTxQueueGetStats(Xsk->Tx.Xdp.Queue), XskInvalidDescriptors);
Expand Down
10 changes: 9 additions & 1 deletion src/xdplwf/send.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ XdpGenericBuildTxNbl(
if (*NextHeader != IPPROTO_TCP ||
Buffer->DataLength < Layer4HeaderOffset + sizeof(*Tcp) ||
Tcp->th_len < (sizeof(*Tcp) >> 2) ||
/* N.B. The TCP header length is only validated to fit within the frame's
buffer, in order to prevent memory access violations by NDIS drivers
further in the send path. It is not compared to the IP packet's length,
which may result in the frame eventually being dropped by a receiver. */
Buffer->DataLength < Layer4HeaderOffset + (Tcp->th_len << 2)) {
goto InvalidOffload;
}
Expand All @@ -281,7 +285,11 @@ XdpGenericBuildTxNbl(
if (*NextHeader != IPPROTO_UDP ||
Buffer->DataLength < Layer4HeaderOffset + sizeof(*Udp) ||
Udp->uh_ulen < sizeof(*Udp) ||
Buffer->DataLength < ntohs(Udp->uh_ulen) /* Allow UDP length to exceed IP length */) {
/* N.B. The UDP datagram length is only validated to fit within the frame's
buffer, in order to prevent memory access violations by NDIS drivers
further in the send path. It is not compared to the IP packet's length,
which may result in the frame eventually being dropped by a receiver. */
Buffer->DataLength < ntohs(Udp->uh_ulen)) {
goto InvalidOffload;
}
ChecksumInfo->Transmit.UdpChecksum = TRUE;
Expand Down

0 comments on commit 78e7865

Please sign in to comment.