Subject: Re: [PATCH net] rtnetlink: Refine sanity checks in rtnl_fdb_{add|del}

From: Ido Schimmel <[email-masked]>
Date: Fri, 30 Nov 2018 18:00:59 +0200

On Fri, Nov 30, 2018 at 07:51:34AM -0800, Eric Dumazet wrote:
> On Fri, Nov 30, 2018 at 7:46 AM Eric Dumazet <[email-masked]> wrote:
> >
> > On Fri, Nov 30, 2018 at 7:40 AM Eric Dumazet <[email-masked]> wrote:
> > >
> > > On Fri, Nov 30, 2018 at 7:36 AM David Ahern <[email-masked]> wrote:
> > > >
> > > > On 11/30/18 7:58 AM, Ido Schimmel wrote:
> > > > > Can you please share the reproducer (assuming it exists)? I don't really
> > > > > understand the fix. None of the functions you patched are in the trace.
> > > > > Also, looking at IPv4 GRE code, while GRE device has dev->addr_len set
> > > > > to 4, dev->type is set to ARPHRD_IPGRE.
> > > >
> > > > I had the same reaction ... you can not claim to be an ethernet device
> > > > and have a hw address that is not 6 bytes.
> > >
> > > This has been discussed a number of times.... TUNSETLINK can do that.
> > > (I have not checked what the repro does )
> >
> >
> > Oh well...ndo_dflt_fdb_dump() seems to be used on a gre device.
> 
> What about :
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 54cfbda0b58be34dcb164028f17cdde2826c857b..b4cfc139c8b05b19564e02f29bd030c5ff85b51b
> 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -3800,6 +3800,9 @@ int ndo_dflt_fdb_dump(struct sk_buff *skb,
>  {
>         int err;
> 
> +       if (dev->type != ARPHRD_ETHER || dev->addr_len != ETH_ALEN)
> +               return -EINVAL;

This makes more sense. I'm still compiling the kmsan kernel. I'll be
able to test the patch after compilation is done.

> +
>         netif_addr_lock_bh(dev);
>         err = nlmsg_populate_fdb(skb, cb, dev, idx, &dev->uc);
>         if (err)