Skip to content

Commit 7c6d2ec

Browse files
Eric Dumazetdavem330
Eric Dumazet
authored andcommitted
net: be more gentle about silly gso requests coming from user
Recent change in virtio_net_hdr_to_skb() broke some packetdrill tests. When --mss=XXX option is set, packetdrill always provide gso_type & gso_size for its inbound packets, regardless of packet size. if (packet->tcp && packet->mss) { if (packet->ipv4) gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4; else gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6; gso.gso_size = packet->mss; } Since many other programs could do the same, relax virtio_net_hdr_to_skb() to no longer return an error, but instead ignore gso settings. This keeps Willem intent to make sure no malicious packet could reach gso stack. Note that TCP stack has a special logic in tcp_set_skb_tso_segs() to clear gso_size for small packets. Fixes: 6dd912f ("net: check untrusted gso_size at kernel entry") Signed-off-by: Eric Dumazet <[email protected]> Cc: Willem de Bruijn <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 45ebf73 commit 7c6d2ec

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

include/linux/virtio_net.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,17 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
109109

110110
if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
111111
u16 gso_size = __virtio16_to_cpu(little_endian, hdr->gso_size);
112+
struct skb_shared_info *shinfo = skb_shinfo(skb);
112113

113-
if (skb->len - p_off <= gso_size)
114-
return -EINVAL;
115-
116-
skb_shinfo(skb)->gso_size = gso_size;
117-
skb_shinfo(skb)->gso_type = gso_type;
114+
/* Too small packets are not really GSO ones. */
115+
if (skb->len - p_off > gso_size) {
116+
shinfo->gso_size = gso_size;
117+
shinfo->gso_type = gso_type;
118118

119-
/* Header must be checked, and gso_segs computed. */
120-
skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
121-
skb_shinfo(skb)->gso_segs = 0;
119+
/* Header must be checked, and gso_segs computed. */
120+
shinfo->gso_type |= SKB_GSO_DODGY;
121+
shinfo->gso_segs = 0;
122+
}
122123
}
123124

124125
return 0;

0 commit comments

Comments
 (0)