udp: properly support MSG_PEEK with truncated buffers
Eric Dumazet authored
[ Upstream commit 197c949e ]

Backport of this upstream commit into stable kernels :
89c22d8c ("net: Fix skb csum races when peeking")
exposed a bug in udp stack vs MSG_PEEK support, when user provides
a buffer smaller than skb payload.

In this case,
skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr),
                                 msg->msg_iov);
returns -EFAULT.

This bug does not happen in upstream kernels since Al Viro did a great
job to replace this into :
skb_copy_and_csum_datagram_msg(skb, sizeof(struct udphdr), msg);
This variant is safe vs short buffers.

For the time being, instead reverting Herbert Xu patch and add back
skb->ip_summed invalid changes, simply store the result of
udp_lib_checksum_complete() so that we avoid computing the checksum a
second time, and avoid the problematic
skb_copy_and_csum_datagram_iovec() call.

This patch can be applied on recent kernels as it avoids a double
chec...
5c564705
Name Last commit Last update
..
6lowpan 6lowpan: nhc: add other known rfc6282 compressions
802 net: Kill dev_rebuild_header
8021q vlan: Correctly propagate promisc|allmulti flags in notifier.
9p p9_client_readdir() fix
appletalk appletalk: Use eth_<foo>_addr instead of memset
atm Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
ax25 ax25: add link layer header validation function
batman-adv batman-adv: Reduce refcnt of removed router when updating route
bluetooth Bluetooth: Fix user channel for 32bit userspace on 64bit kernel
bridge net: bridge: fix old ioctl unlocked net device walk
caif unix/caif: sk_socket can disappear when state is unlocked
can can: bcm: fix hrtimer/tasklet termination in bcm op removal
ceph libceph: verify authorize reply on connect
core tunnels: Don't apply GRO to multiple layers of encapsulation.
dcb net/dcb: Add IEEE QCN attribute
dccp tcp/dccp: fix timewait races in timer handling
decnet decnet: Do not build routes to devices without decnet private data.
dns_resolver Merge commit 'v3.16' into next
dsa net: dsa: Do not override PHY interface if already configured
ethernet net: add recursion limit to GRO
hsr net/hsr: Fix NULL pointer dereference and refcnt bugs when deleting a HSR interface.
ieee802154 ieee802154: Fix sockaddr_ieee802154 implicit padding information leak.
ipv4 udp: properly support MSG_PEEK with truncated buffers
ipv6 udp: properly support MSG_PEEK with truncated buffers
ipx net: Remove iocb argument from sendmsg and recvmsg
irda
iucv
key
l2tp
lapb
llc
mac80211
mac802154
mpls
netfilter
netlabel
netlink
netrom
nfc
openvswitch
packet
phonet
rds
rfkill
rose
rxrpc
sched
sctp
sunrpc
switchdev
tipc
unix
vmw_vsock
wimax
wireless
x25
xfrm
Kconfig
Makefile
compat.c
socket.c
sysctl_net.c