diff options
author | Michal Kubeček <mkubecek@suse.cz> | 2015-03-02 12:27:11 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-02 22:19:29 -0500 |
commit | acf8dd0a9d0b9e4cdb597c2f74802f79c699e802 (patch) | |
tree | 32e7fcfb666b6019f9c4aab4bfe095353657e920 /net | |
parent | 096b1c172853163b865884446f73977b27eb034d (diff) |
udp: only allow UFO for packets from SOCK_DGRAM sockets
If an over-MTU UDP datagram is sent through a SOCK_RAW socket to a
UFO-capable device, ip_ufo_append_data() sets skb->ip_summed to
CHECKSUM_PARTIAL unconditionally as all GSO code assumes transport layer
checksum is to be computed on segmentation. However, in this case,
skb->csum_start and skb->csum_offset are never set as raw socket
transmit path bypasses udp_send_skb() where they are usually set. As a
result, driver may access invalid memory when trying to calculate the
checksum and store the result (as observed in virtio_net driver).
Moreover, the very idea of modifying the userspace provided UDP header
is IMHO against raw socket semantics (I wasn't able to find a document
clearly stating this or the opposite, though). And while allowing
CHECKSUM_NONE in the UFO case would be more efficient, it would be a bit
too intrusive change just to handle a corner case like this. Therefore
disallowing UFO for packets from SOCK_DGRAM seems to be the best option.
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/ip_output.c | 3 | ||||
-rw-r--r-- | net/ipv6/ip6_output.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index d68199d9b2b0..a7aea2048a0d 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -888,7 +888,8 @@ static int __ip_append_data(struct sock *sk, | |||
888 | cork->length += length; | 888 | cork->length += length; |
889 | if (((length > mtu) || (skb && skb_is_gso(skb))) && | 889 | if (((length > mtu) || (skb && skb_is_gso(skb))) && |
890 | (sk->sk_protocol == IPPROTO_UDP) && | 890 | (sk->sk_protocol == IPPROTO_UDP) && |
891 | (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len) { | 891 | (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len && |
892 | (sk->sk_type == SOCK_DGRAM)) { | ||
892 | err = ip_ufo_append_data(sk, queue, getfrag, from, length, | 893 | err = ip_ufo_append_data(sk, queue, getfrag, from, length, |
893 | hh_len, fragheaderlen, transhdrlen, | 894 | hh_len, fragheaderlen, transhdrlen, |
894 | maxfraglen, flags); | 895 | maxfraglen, flags); |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 7deebf102cba..0a04a37305d5 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -1298,7 +1298,8 @@ emsgsize: | |||
1298 | if (((length > mtu) || | 1298 | if (((length > mtu) || |
1299 | (skb && skb_is_gso(skb))) && | 1299 | (skb && skb_is_gso(skb))) && |
1300 | (sk->sk_protocol == IPPROTO_UDP) && | 1300 | (sk->sk_protocol == IPPROTO_UDP) && |
1301 | (rt->dst.dev->features & NETIF_F_UFO)) { | 1301 | (rt->dst.dev->features & NETIF_F_UFO) && |
1302 | (sk->sk_type == SOCK_DGRAM)) { | ||
1302 | err = ip6_ufo_append_data(sk, queue, getfrag, from, length, | 1303 | err = ip6_ufo_append_data(sk, queue, getfrag, from, length, |
1303 | hh_len, fragheaderlen, | 1304 | hh_len, fragheaderlen, |
1304 | transhdrlen, mtu, flags, rt); | 1305 | transhdrlen, mtu, flags, rt); |