From: Eric Dumazet <eric.dumazet@gmail.com>
To: Mike Maloney <maloneykernel@gmail.com>,
netdev@vger.kernel.org, davem@davemloft.net
Cc: Mike Maloney <maloney@google.com>
Subject: Re: [PATCH net] ipv6: fix udpv6 sendmsg crash caused by too small MTU
Date: Wed, 10 Jan 2018 09:21:51 -0800 [thread overview]
Message-ID: <1515604911.131759.23.camel@gmail.com> (raw)
In-Reply-To: <20180110171013.129868-1-maloneykernel@gmail.com>
On Wed, 2018-01-10 at 12:10 -0500, Mike Maloney wrote:
> From: Mike Maloney <maloney@google.com>
>
> The logic in __ip6_append_data() assumes that the MTU is at least large
> enough for the headers. A device's MTU may be adjusted after being
> added while sendmsg() is processing data, resulting in
> __ip6_append_data() seeing any MTU. For an mtu smaller than the size of
> the fragmentation header, the math results in a negative 'maxfraglen',
> which causes problems when refragmenting any previous skb in the
> skb_write_queue, leaving it possibly malformed.
>
> Instead sendmsg returns EINVAL when the mtu is calculated to be less
> than IPV6_MIN_MTU.
>
You forgot your SOB
> Reported-by: syzbot <syzkaller@googlegroups.com>
> ---
Also please add after this '---' marker that your patch depends on my
prior fix ( https://patchwork.ozlabs.org/patch/858234/
ipv6: fix possible mem leaks in ipv6_make_skb() )
( Or we leak a dst reference )
We probably should have sent a patch series.
Thanks.
> net/ipv6/ip6_output.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
> index f7dd51c42314..f309ce7120d0 100644
> --- a/net/ipv6/ip6_output.c
> +++ b/net/ipv6/ip6_output.c
> @@ -1206,14 +1206,16 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
> v6_cork->tclass = ipc6->tclass;
> if (rt->dst.flags & DST_XFRM_TUNNEL)
> mtu = np->pmtudisc >= IPV6_PMTUDISC_PROBE ?
> - rt->dst.dev->mtu : dst_mtu(&rt->dst);
> + READ_ONCE(rt->dst.dev->mtu) : dst_mtu(&rt->dst);
> else
> mtu = np->pmtudisc >= IPV6_PMTUDISC_PROBE ?
> - rt->dst.dev->mtu : dst_mtu(rt->dst.path);
> + READ_ONCE(rt->dst.dev->mtu) : dst_mtu(rt->dst.path);
> if (np->frag_size < mtu) {
> if (np->frag_size)
> mtu = np->frag_size;
> }
> + if (mtu < IPV6_MIN_MTU)
> + return -EINVAL;
> cork->base.fragsize = mtu;
> if (dst_allfrag(rt->dst.path))
> cork->base.flags |= IPCORK_ALLFRAG;
next prev parent reply other threads:[~2018-01-10 17:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 17:10 [PATCH net] ipv6: fix udpv6 sendmsg crash caused by too small MTU Mike Maloney
2018-01-10 17:21 ` Eric Dumazet [this message]
2018-01-10 17:43 ` Mike Maloney
-- strict thread matches above, loose matches on Subject: below --
2018-01-10 17:45 Mike Maloney
2018-01-10 18:56 ` Eric Dumazet
2018-01-15 18:30 ` David Miller
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=1515604911.131759.23.camel@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=davem@davemloft.net \
--cc=maloney@google.com \
--cc=maloneykernel@gmail.com \
--cc=netdev@vger.kernel.org \
/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).