On Thu, Apr 25, 2019 at 11:42 AM Willem de Bruijn
<willemdebruijn.ker...@gmail.com> wrote:
>
> On Thu, Apr 25, 2019 at 10:35 AM David Laight <david.lai...@aculab.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?

Thanks,

  Willem

Reply via email to