On 10/27/18 2:39 PM, Ido Schimmel wrote:
> When an FDB entry is configured, the address is validated to have the
> length of an Ethernet address, but the device for which the address is
> configured can be of any type.
>
> The above can result in the use of uninitialized memory when the address
> is later compared against existing addresses since 'dev->addr_len' is
> used and it may be greater than ETH_ALEN, as with ip6tnl devices.
>
> Fix this by making sure that FDB entries are only configured for
> Ethernet devices.
...
>
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index f679c7a7d761..728a97f9f700 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -3600,6 +3600,11 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct
> nlmsghdr *nlh,
> return -EINVAL;
> }
>
> + if (dev->type != ARPHRD_ETHER) {
> + NL_SET_ERR_MSG(extack, "invalid device type");
If only Ethernet devices are supported, then the error message can be
more specific: "FDB add only support for Ethernet devices"
> + return -EINVAL;
> + }
> +
> addr = nla_data(tb[NDA_LLADDR]);
>
> err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
> @@ -3704,6 +3709,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct
> nlmsghdr *nlh,
> return -EINVAL;
> }
>
> + if (dev->type != ARPHRD_ETHER) {
> + NL_SET_ERR_MSG(extack, "invalid device type");
same here.
> + return -EINVAL;
> + }
> +
> addr = nla_data(tb[NDA_LLADDR]);
>
> err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
>