udp: only allow UFO for packets from SOCK_DGRAM sockets 75/179675/2
authorMichal Kubeček <mkubecek@suse.cz>
Mon, 2 Mar 2015 17:27:11 +0000 (18:27 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Thu, 24 May 2018 04:20:24 +0000 (13:20 +0900)
commit5fbb797e9254b1eaad671ed761d7f71201aa9c46
treec955bd700eed8937358d8601b74a1df981fb4822
parent287fe4c141bfccbc8a6c1f6e7708559841a36400
udp: only allow UFO for packets from SOCK_DGRAM sockets

[ Upstream commit acf8dd0a9d0b9e4cdb597c2f74802f79c699e802 ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: cherry-pick from linux-3.10.y to apply CVE patch]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Ie0707eb6445f53af54a750c667a3b9f2bb5efa77
net/ipv4/ip_output.c
net/ipv6/ip6_output.c