* [PATCH net v2] ip: fix IP_CHECKSUM handling
@ 2017-02-21 8:33 Paolo Abeni
2017-02-21 14:02 ` Eric Dumazet
2017-02-21 17:26 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2017-02-21 8:33 UTC (permalink / raw)
To: netdev
Cc: David S. Miller, Andrey Konovalov, Eric Dumazet, Tom Herbert,
Stephen Hemminger
The skbs processed by ip_cmsg_recv() are not guaranteed to
be linear e.g. when sending UDP packets over loopback with
MSGMORE.
Using csum_partial() on [potentially] the whole skb len
is dangerous; instead be on the safe side and use skb_checksum().
Thanks to syzkaller team to detect the issue and provide the
reproducer.
v1 -> v2:
- move the variable declaration in a tighter scope
Fixes: ad6f939ab193 ("ip: Add offset parameter to ip_cmsg_recv")
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/ipv4/ip_sockglue.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 9000117..fc4bf4d 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -116,10 +116,10 @@ static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,
if (skb->ip_summed != CHECKSUM_COMPLETE)
return;
- if (offset != 0)
- csum = csum_sub(csum,
- csum_partial(skb_transport_header(skb) + tlen,
- offset, 0));
+ if (offset != 0) {
+ int tend_off = skb_transport_offset(skb) + tlen;
+ csum = csum_sub(csum, skb_checksum(skb, tend_off, offset, 0));
+ }
put_cmsg(msg, SOL_IP, IP_CHECKSUM, sizeof(__wsum), &csum);
}
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] ip: fix IP_CHECKSUM handling
2017-02-21 8:33 [PATCH net v2] ip: fix IP_CHECKSUM handling Paolo Abeni
@ 2017-02-21 14:02 ` Eric Dumazet
2017-02-21 17:26 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2017-02-21 14:02 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, David S. Miller, Andrey Konovalov, Eric Dumazet,
Tom Herbert, Stephen Hemminger
On Tue, 2017-02-21 at 09:33 +0100, Paolo Abeni wrote:
> The skbs processed by ip_cmsg_recv() are not guaranteed to
> be linear e.g. when sending UDP packets over loopback with
> MSGMORE.
> Using csum_partial() on [potentially] the whole skb len
> is dangerous; instead be on the safe side and use skb_checksum().
>
> Thanks to syzkaller team to detect the issue and provide the
> reproducer.
Acked-by: Eric Dumazet <edumazet@google.com>
Thanks Paolo !
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2] ip: fix IP_CHECKSUM handling
2017-02-21 8:33 [PATCH net v2] ip: fix IP_CHECKSUM handling Paolo Abeni
2017-02-21 14:02 ` Eric Dumazet
@ 2017-02-21 17:26 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-02-21 17:26 UTC (permalink / raw)
To: pabeni; +Cc: netdev, andreyknvl, edumazet, tom, stephen
From: Paolo Abeni <pabeni@redhat.com>
Date: Tue, 21 Feb 2017 09:33:18 +0100
> The skbs processed by ip_cmsg_recv() are not guaranteed to
> be linear e.g. when sending UDP packets over loopback with
> MSGMORE.
> Using csum_partial() on [potentially] the whole skb len
> is dangerous; instead be on the safe side and use skb_checksum().
>
> Thanks to syzkaller team to detect the issue and provide the
> reproducer.
>
> v1 -> v2:
> - move the variable declaration in a tighter scope
>
> Fixes: ad6f939ab193 ("ip: Add offset parameter to ip_cmsg_recv")
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-21 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-21 8:33 [PATCH net v2] ip: fix IP_CHECKSUM handling Paolo Abeni
2017-02-21 14:02 ` Eric Dumazet
2017-02-21 17:26 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.