Re: [PATCH 4.4 60/74] ipv6: fix udpv6 sendmsg crash caused by too small MTU

From: Ben Hutchings
Date: Mon Feb 19 2018 - 14:52:33 EST


On Mon, 2018-02-19 at 20:46 +0100, Ben Hutchings wrote:
> On Mon, 2018-01-29 at 13:57 +0100, Greg Kroah-Hartman wrote:
> > 4.4-stable review patch.ÂÂIf anyone has any objections, please let me know.
> >
> > ------------------
> >
> > From: Mike Maloney <maloney@xxxxxxxxxx>
> >
> >
> > [ Upstream commit 749439bfac6e1a2932c582e2699f91d329658196 ]
>
> [...]
> > --- a/net/ipv6/ip6_output.c
> > +++ b/net/ipv6/ip6_output.c
> > @@ -1246,14 +1246,16 @@ static int ip6_setup_cork(struct sock *s
> > Â v6_cork->tclass = 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;
>
> This error path appears to leak a reference to rt->dst.

Never mind, I see that the callers release it.

Ben.

> Ben.
>
> > > > Â cork->base.fragsize = mtu;
> > > > Â if (dst_allfrag(rt->dst.path))
> > > > Â cork->base.flags |= IPCORK_ALLFRAG;
> >
> >
> >
--
Ben Hutchings
Software Developer, Codethink Ltd.