]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.13/ip-fix-ip_checksum-handling.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.13 / ip-fix-ip_checksum-handling.patch
CommitLineData
b2af825a
GKH
1From foo@baz Thu Feb 23 21:13:05 CET 2017
2From: Paolo Abeni <pabeni@redhat.com>
3Date: Tue, 21 Feb 2017 09:33:18 +0100
4Subject: ip: fix IP_CHECKSUM handling
5
6From: Paolo Abeni <pabeni@redhat.com>
7
8
9[ Upstream commit ca4ef4574f1ee5252e2cd365f8f5d5bafd048f32 ]
10
11The skbs processed by ip_cmsg_recv() are not guaranteed to
12be linear e.g. when sending UDP packets over loopback with
13MSGMORE.
14Using csum_partial() on [potentially] the whole skb len
15is dangerous; instead be on the safe side and use skb_checksum().
16
17Thanks to syzkaller team to detect the issue and provide the
18reproducer.
19
20v1 -> v2:
21 - move the variable declaration in a tighter scope
22
23Fixes: ad6f939ab193 ("ip: Add offset parameter to ip_cmsg_recv")
24Reported-by: Andrey Konovalov <andreyknvl@google.com>
25Signed-off-by: Paolo Abeni <pabeni@redhat.com>
26Acked-by: Eric Dumazet <edumazet@google.com>
27Signed-off-by: David S. Miller <davem@davemloft.net>
28Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29---
30 net/ipv4/ip_sockglue.c | 8 ++++----
31 1 file changed, 4 insertions(+), 4 deletions(-)
32
33--- a/net/ipv4/ip_sockglue.c
34+++ b/net/ipv4/ip_sockglue.c
35@@ -105,10 +105,10 @@ static void ip_cmsg_recv_checksum(struct
36 if (skb->ip_summed != CHECKSUM_COMPLETE)
37 return;
38
39- if (offset != 0)
40- csum = csum_sub(csum,
41- csum_partial(skb_transport_header(skb) + tlen,
42- offset, 0));
43+ if (offset != 0) {
44+ int tend_off = skb_transport_offset(skb) + tlen;
45+ csum = csum_sub(csum, skb_checksum(skb, tend_off, offset, 0));
46+ }
47
48 put_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);
49 }