Re: [PATCH] net: arp, ipv6: handle special case of tap device

From: David Miller
Date: Sat Sep 29 2018 - 14:40:37 EST


From: Vladis Dronov <vdronov@xxxxxxxxxx>
Date: Wed, 26 Sep 2018 11:30:18 +0200

> @@ -187,7 +187,14 @@ EXPORT_SYMBOL(arp_tbl);
>
> int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir)
> {
> - switch (dev->type) {
> + unsigned short type = dev->type;
> +
> +#if IS_ENABLED(CONFIG_TAP)
> + if (dev->rtnl_link_ops && !strcmp(dev->rtnl_link_ops->kind, "tun"))
> + type = ARPHRD_ETHER;
> +#endif /* CONFIG_TAP */

This is insanely ugly.

dev->type determines the link layer header layout and size.

You can fix the kernel, but userspace AF_PACKET applications are still
going to be broken by this behavior. And that is just the tip of the
iceberg.

I'm not applying this, sorry. I think tun/tap should be prevented from
allowing the dev->type to be changed, unless it will make those changes
adjust the link layer headers properly as well.

Sorry.