udp: segment looped gso packets correctly
Subsystems (3)
Willem de Bruijn
maintainerPATCH 1/1 udp: segment looped gso packets correctly
From: Willem de Bruijn <[email protected]>
Multicast and broadcast packets can be looped from egress to ingress pre segmentation with dev_loopback_xmit. That function unconditionally sets ip_summed to CHECKSUM_UNNECESSARY.
udp_rcv_segment segments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type. __udp_gso_segment interprets !CHECKSUM_PARTIAL as CHECKSUM_NONE. But the offsets are not correct for gso_make_checksum.
UDP GSO packets are of type CHECKSUM_PARTIAL, with their uh->check set to the correct pseudo header checksum. Reset ip_summed to this type. (CHECKSUM_PARTIAL is allowed on ingress, see comments in skbuff.h)
--- include/net/udp.h | 3 +++ 1 file changed, 3 insertions(+)
include/net/udp.h +3 -0
@@ -476,6 +476,9 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,if (!inet_get_convert_csum (sk)) features |=NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM ; +if (skb->pkt_type ==PACKET_LOOPBACK ) + skb->ip_summed =CHECKSUM_PARTIAL ; +/* the GSO CB lays after the UDP one, no need to save and restore any * CB fragment */
Signature · 1 line
2.25.0.341.g760bfbb309-goog
Quoted 27 lines · Willem de Bruijn
From: Willem de Bruijn <[email protected]>
Multicast and broadcast packets can be looped from egress to ingress pre segmentation with
dev_loopback_xmit. That function unconditionally setsip_summedtoCHECKSUM_UNNECESSARY.
udp_rcv_segmentsegments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type.__udp_gso_segmentinterprets !CHECKSUM_PARTIAL asCHECKSUM_NONE. But the offsets are not correct forgso_make_checksum.UDP GSO packets are of type
CHECKSUM_PARTIAL, with theiruh->checkset to the correct pseudo header checksum. Resetip_summedto this type. (CHECKSUM_PARTIALis allowed on ingress, see comments inskbuff.h)Reported-by syzbot <[email protected]>Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")Signed-off-by Willem de Bruijn <[email protected]>--- include/net/udp.h | 3 +++ 1 file changed, 3 insertions(+)include/net/udp.h +0
-0
include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 484
Quoted 9 lines
include/net/udp.h +3
-0@@ -476,6 +476,9 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,if (!inet_get_convert_csum (sk)) features |=NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM ; +if (skb->pkt_type ==PACKET_LOOPBACK ) + skb->ip_summed =CHECKSUM_PARTIAL ; +/* the GSO CB lays after the UDP one, no need to save and restore any * CB fragment */
LGTM, Thanks!
Out of sheer curiosity, do you know what was the kernel behaviour before the 'fixes' commit ? GSO packet delivered to user-space stillaggregated ?!?
Thanks,
Paolo
Willem de Bruijn
maintainerQuoted 41 lines · Paolo Abeni
Quoted 27 lines · Willem de Bruijn
From: Willem de Bruijn <[email protected]>
Multicast and broadcast packets can be looped from egress to ingress pre segmentation with
dev_loopback_xmit. That function unconditionally setsip_summedtoCHECKSUM_UNNECESSARY.
udp_rcv_segmentsegments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type.__udp_gso_segmentinterprets !CHECKSUM_PARTIAL asCHECKSUM_NONE. But the offsets are not correct forgso_make_checksum.UDP GSO packets are of type
CHECKSUM_PARTIAL, with theiruh->checkset to the correct pseudo header checksum. Resetip_summedto this type. (CHECKSUM_PARTIALis allowed on ingress, see comments inskbuff.h)Reported-by syzbot <[email protected]>Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")Signed-off-by Willem de Bruijn <[email protected]>--- include/net/udp.h | 3 +++ 1 file changed, 3 insertions(+)include/net/udp.h +0
-0include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 484
Quoted 9 lines
include/net/udp.h +3
-0@@ -476,6 +476,9 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,if (!inet_get_convert_csum (sk)) features |=NETIF_F_IP_CSUM |NETIF_F_IPV6_CSUM ; +if (skb->pkt_type ==PACKET_LOOPBACK ) + skb->ip_summed =CHECKSUM_PARTIAL ; +/* the GSO CB lays after the UDP one, no need to save and restore any * CB fragment */ LGTM, Thanks!
Quoted 4 lines
Acked-by Paolo Abeni <[email protected]>Out of sheer curiosity, do you know what was the kernel behaviour before the 'fixes' commit ? GSO packet delivered to user-space stillaggregated ?!?
Yes.. I had missed this entire ip_mc_output path when adding segmentation (clearly).
Your patch fixed that. The other options would be segmenting in dev_loopback_xmit or outright failing the call in udp_send_skb. Neither of which is appealing.
Thanks for reviewing!
David Miller
maintainerFrom: Willem de Bruijn <[email protected]>
Date: Mon, 27 Jan 2020 15:40:31 -0500
Quoted 11 lines
From: Willem de Bruijn <[email protected]>
Multicast and broadcast packets can be looped from egress to ingress pre segmentation with
dev_loopback_xmit. That function unconditionally setsip_summedtoCHECKSUM_UNNECESSARY.
udp_rcv_segmentsegments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type.__udp_gso_segmentinterprets !CHECKSUM_PARTIAL asCHECKSUM_NONE. But the offsets are not correct forgso_make_checksum.
Quoted 7 lines
UDP GSO packets are of type
CHECKSUM_PARTIAL, with theiruh->checkset to the correct pseudo header checksum. Resetip_summedto this type. (CHECKSUM_PARTIALis allowed on ingress, see comments inskbuff.h)Reported-by syzbot <[email protected]>Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")Signed-off-by Willem de Bruijn <[email protected]>
Applied and queued up for -stable, but I have to say:
include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 481
Quoted 3 lines
include/net/udp.h +3
-0+if (skb->pkt_type ==PACKET_LOOPBACK ) + skb->ip_summed =CHECKSUM_PARTIAL ; +
There are a lot of implementation detail assumptions encoded into that conditional statement :-)
Feel free to follow-up with a patch adding a comment containing a condensed version of your commit log here.
Thanks.
Willem de Bruijn
maintainerQuoted 29 lines · David Miller
From: Willem de Bruijn <[email protected]>
Date: Mon, 27 Jan 2020 15:40:31 -0500Quoted 11 lines
From: Willem de Bruijn <[email protected]>
Multicast and broadcast packets can be looped from egress to ingress pre segmentation with
dev_loopback_xmit. That function unconditionally setsip_summedtoCHECKSUM_UNNECESSARY.
udp_rcv_segmentsegments gso packets in the udp rx path. Segmentation usually executes on egress, and does not expect packets of this type.__udp_gso_segmentinterprets !CHECKSUM_PARTIAL asCHECKSUM_NONE. But the offsets are not correct forgso_make_checksum.Quoted 7 lines
UDP GSO packets are of type
CHECKSUM_PARTIAL, with theiruh->checkset to the correct pseudo header checksum. Resetip_summedto this type. (CHECKSUM_PARTIALis allowed on ingress, see comments inskbuff.h)Reported-by syzbot <[email protected]>Fixes cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")Signed-off-by Willem de Bruijn <[email protected]>Applied and queued up for -stable, but I have to say:
include/net/udp.h static inline struct sk_buff *udp_rcv_segment(struct sock *sk, · line 481
Quoted 3 lines
include/net/udp.h +3
-0+if (skb->pkt_type ==PACKET_LOOPBACK ) + skb->ip_summed =CHECKSUM_PARTIAL ; +
Quoted 5 lines
There are a lot of implementation detail assumptions encoded into that conditional statement :-)
Feel free to follow-up with a patch adding a comment containing a condensed version of your commit log here.
Will do. Yeah, that does look pretty obscure. I may have gotten a bit too used to relying solely on git blame ;-)
Thanks!