lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAF=yD-Lgcje8Fe0RfuP51Pdy7SyKwNYhRvTp3vwnOxTH3b+93Q@mail.gmail.com>
Date:   Fri, 26 Apr 2019 15:32:53 -0400
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     David Laight <David.Laight@...lab.com>
Cc:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "idosch@...sch.org" <idosch@...sch.org>,
        Willem de Bruijn <willemb@...gle.com>
Subject: Re: [PATCH net] packet: validate address length if non-zero

On Fri, Apr 26, 2019 at 11:14 AM David Laight <David.Laight@...lab.com> wrote:
>
> From: Willem de Bruijn
> > Sent: 26 April 2019 16:11
> > On Thu, Apr 25, 2019 at 11:42 AM Willem de Bruijn
> > <willemdebruijn.kernel@...il.com> wrote:
> > >
> > > On Thu, Apr 25, 2019 at 10:35 AM David Laight <David.Laight@...lab.com> wrote:
> > > >
> > > > From: Willem de Bruijn
> > > > > Sent: 25 April 2019 14:57
> > > > ...
> > > > > > I've just done a bit of software archaeology.
> > > > > >
> > > > > > Prior to 2.6.14-rc3 the send code ignored sll_halen, it was only set by the receive code.
> > > > > > So it is not surprising that old application code leaves it as zero.
> > > > > >
> > > > > > The old receive code also always set msg_namelen = sizeof (struct sockaddr_ll).
> > > > > > The receive code now sets:
> > > > > >   msg_namelen = offsetof(struct sockaddr_ll, sll_addr) + saddr->sll_halen;
> > > > > > For ethernet this changes the msg_namelen from 20 to 18.
> > > > > > A side effect (no one has noticed for years) is that you can't send a reply
> > > > > > by passing back the received address buffer.
> > > > >
> > > > > Great find, thanks. I hadn't thought of going back that far, but
> > > > > clearly should in these legacy caller questions..
> > > >
> > > > Fortunately I didn't have to find the pre-git sources :-)
> > > >
> > > > > > Looking at it all again how about:
> > > > > >         char *addr = NULL;
> > > > > >         ...
> > > > > >                         err = -EINVAL;
> > > > > >                         if (msg->msg_namelen < offsetof(struct sockaddr_ll, sll_addr))
> > > > > >                                 goto out;
> > > > > >                         proto = saddr->sll_protocol;
> > > > > >                         dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex);
> > > > > >                         if (dev && sock->type == SOCK_DGRAM) {
> > > > > >                                 if (msg->msg_namelen < dev->addr_len + offsetof(struct
> > sockaddr_ll, sll_addr))
> > > > > >                                         goto out_unlock;
> > > > > >                                 addr = saddr->sll_addr;
> > > > > >                         }
> > > > >
> > > > > Yes, given the above, this looks great to me.
> >
> > Coming back to this. Both the above and two separate send/recv fixes
> > seem fine to me. Do you have a preference either way? And do you want
> > to send the fix(es) or should I?
>
> I'll let you do it - save me working out how to get valid patches off
> my Linux systems and into outlook :-)
>
> If you are going to do the recv fix the send one can keep the check
> against the full struct sockaddr_ll.

It took a bit longer than expected, sorry. In the rx one, I went with
a branch in the relatively unlikely msg->msg_name branch rather than
an unconditional zero in the packet_rcv hot path.

http://patchwork.ozlabs.org/patch/1091764/
http://patchwork.ozlabs.org/patch/1091765/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ