From: Stephen Hemminger <stephen@networkplumber.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
Andrey Konovalov <andreyknvl@google.com>,
Eric Dumazet <edumazet@google.com>,
Tom Herbert <tom@herbertland.com>
Subject: Re: [PATCH net] ip: fix IP_CHECKSUM handling
Date: Mon, 20 Feb 2017 09:23:25 -0800 [thread overview]
Message-ID: <20170220092325.3cedb62c@xeon-e3> (raw)
In-Reply-To: <ba355a67bf3e5b3155ee1ead02fa73046be7391f.1487609562.git.pabeni@redhat.com>
On Mon, 20 Feb 2017 17:55:39 +0100
Paolo Abeni <pabeni@redhat.com> 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.
>
> 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 | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
> index 9000117..d88bbe2 100644
> --- a/net/ipv4/ip_sockglue.c
> +++ b/net/ipv4/ip_sockglue.c
> @@ -112,14 +112,15 @@ static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,
> int tlen, int offset)
> {
> __wsum csum = skb->csum;
> + int tend_off;
>
> 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) {
> + tend_off = skb_transport_offset(skb) + tlen;
> + csum = csum_sub(csum, skb_checksum(skb, tend_off, offset, 0));
> + }
If you need to add a local variable (tend_off) then please make its scope
as tight as possible. i.e.
if (offset != 0) {
int tend_off = skb_transport_offset(skb) + tlen;
prev parent reply other threads:[~2017-02-20 17:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-20 16:55 [PATCH net] ip: fix IP_CHECKSUM handling Paolo Abeni
2017-02-20 17:23 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170220092325.3cedb62c@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=andreyknvl@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tom@herbertland.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).