diff mbox

[3.13.y-ckt,stable] Patch "drivers/net: Disable UFO through virtio" has been added to staging queue

Message ID 1418069412-8305-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa Dec. 8, 2014, 8:10 p.m. UTC
This is a note to let you know that I have just added a patch titled

    drivers/net: Disable UFO through virtio

to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue

This patch is scheduled to be released in version 3.13.11-ckt13.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

From 852a3b019358f23ecb666f5d62fbbdaf07539f96 Mon Sep 17 00:00:00 2001
From: Ben Hutchings <ben@decadent.org.uk>
Date: Thu, 30 Oct 2014 18:27:12 +0000
Subject: drivers/net: Disable UFO through virtio

[ Upstream commit 3d0ad09412ffe00c9afa201d01effdb6023d09b4 ]

IPv6 does not allow fragmentation by routers, so there is no
fragmentation ID in the fixed header.  UFO for IPv6 requires the ID to
be passed separately, but there is no provision for this in the virtio
net protocol.

Until recently our software implementation of UFO/IPv6 generated a new
ID, but this was a bug.  Now we will use ID=0 for any UFO/IPv6 packet
passed through a tap, which is even worse.

Unfortunately there is no distinction between UFO/IPv4 and v6
features, so disable UFO on taps and virtio_net completely until we
have a proper solution.

We cannot depend on VM managers respecting the tap feature flags, so
keep accepting UFO packets but log a warning the first time we do
this.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Fixes: 916e4cf46d02 ("ipv6: reuse ip6_frag_id from ip6_ufo_append_data")
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 drivers/net/macvtap.c    | 13 +++++--------
 drivers/net/tun.c        | 19 +++++++++++--------
 drivers/net/virtio_net.c | 24 ++++++++++++++----------
 3 files changed, 30 insertions(+), 26 deletions(-)

--
1.9.1

Comments

Kamal Mostafa Dec. 9, 2014, 4:42 p.m. UTC | #1
On Mon, 2014-12-08 at 20:11 +0000, Ben Hutchings wrote:
> On Mon, 2014-12-08 at 12:10 -0800, Kamal Mostafa wrote:
> > This is a note to let you know that I have just added a patch titled
> > 
> >     drivers/net: Disable UFO through virtio
> > 
> > to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
> > which can be found at:
> > 
> >  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue
> > 
> > This patch is scheduled to be released in version 3.13.11-ckt13.
> > 
> > If you, or anyone else, feels it should not be added to this tree, please 
> > reply to this email.
> [...]
> 
> You should drop this as part of it needs to be reverted and that patch
> hasn't been applied upstream yet.

Okay, I'll drop "Disable UFO through virtio" from 3.13-stable.

But what about this subsequent UFO patch which refers to UFO being 'now
disabled'?  Drop this too, or leave it in?:

    drivers/net, ipv6: Select IPv6 fragment idents for virtio UFO packets
    
    [ Upstream commit 5188cd44c55db3e92cd9e77a40b5baa7ed4340f7 ]
    
    UFO is now disabled on all drivers that work with virtio net headers,
    but userland may try to send UFO/IPv6 packets anyway.  Instead of
    sending with ID=0, we should select identifiers on their behalf (as we
    used to).
    
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    Fixes: 916e4cf46d02 ("ipv6: reuse ip6_frag_id from ip6_ufo_append_data")
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Kamal Mostafa <kamal@canonical.com>

Thanks very much, Ben!

 -Kamal
Ben Hutchings Dec. 9, 2014, 5:02 p.m. UTC | #2
On Tue, 2014-12-09 at 08:42 -0800, Kamal Mostafa wrote:
> On Mon, 2014-12-08 at 20:11 +0000, Ben Hutchings wrote:
> > On Mon, 2014-12-08 at 12:10 -0800, Kamal Mostafa wrote:
> > > This is a note to let you know that I have just added a patch titled
> > > 
> > >     drivers/net: Disable UFO through virtio
> > > 
> > > to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
> > > which can be found at:
> > > 
> > >  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue
> > > 
> > > This patch is scheduled to be released in version 3.13.11-ckt13.
> > > 
> > > If you, or anyone else, feels it should not be added to this tree, please 
> > > reply to this email.
> > [...]
> > 
> > You should drop this as part of it needs to be reverted and that patch
> > hasn't been applied upstream yet.
> 
> Okay, I'll drop "Disable UFO through virtio" from 3.13-stable.
> 
> But what about this subsequent UFO patch which refers to UFO being 'now
> disabled'?  Drop this too, or leave it in?:
> 
>     drivers/net, ipv6: Select IPv6 fragment idents for virtio UFO packets
>     
>     [ Upstream commit 5188cd44c55db3e92cd9e77a40b5baa7ed4340f7 ]
>     
>     UFO is now disabled on all drivers that work with virtio net headers,
>     but userland may try to send UFO/IPv6 packets anyway.  Instead of
>     sending with ID=0, we should select identifiers on their behalf (as we
>     used to).
>     
>     Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
>     Fixes: 916e4cf46d02 ("ipv6: reuse ip6_frag_id from ip6_ufo_append_data")
>     Signed-off-by: David S. Miller <davem@davemloft.net>
>     Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> 
> Thanks very much, Ben!

That's still a useful fix, but will have some fuzz.

Ben.
Luis Henriques Dec. 9, 2014, 7:29 p.m. UTC | #3
On Tue, Dec 09, 2014 at 05:02:11PM +0000, Ben Hutchings wrote:
> On Tue, 2014-12-09 at 08:42 -0800, Kamal Mostafa wrote:
> > On Mon, 2014-12-08 at 20:11 +0000, Ben Hutchings wrote:
> > > On Mon, 2014-12-08 at 12:10 -0800, Kamal Mostafa wrote:
> > > > This is a note to let you know that I have just added a patch titled
> > > > 
> > > >     drivers/net: Disable UFO through virtio
> > > > 
> > > > to the linux-3.13.y-queue branch of the 3.13.y-ckt extended stable tree 
> > > > which can be found at:
> > > > 
> > > >  http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.13.y-queue
> > > > 
> > > > This patch is scheduled to be released in version 3.13.11-ckt13.
> > > > 
> > > > If you, or anyone else, feels it should not be added to this tree, please 
> > > > reply to this email.
> > > [...]
> > > 
> > > You should drop this as part of it needs to be reverted and that patch
> > > hasn't been applied upstream yet.
> > 
> > Okay, I'll drop "Disable UFO through virtio" from 3.13-stable.
> > 
> > But what about this subsequent UFO patch which refers to UFO being 'now
> > disabled'?  Drop this too, or leave it in?:
> > 
> >     drivers/net, ipv6: Select IPv6 fragment idents for virtio UFO packets
> >     
> >     [ Upstream commit 5188cd44c55db3e92cd9e77a40b5baa7ed4340f7 ]
> >     
> >     UFO is now disabled on all drivers that work with virtio net headers,
> >     but userland may try to send UFO/IPv6 packets anyway.  Instead of
> >     sending with ID=0, we should select identifiers on their behalf (as we
> >     used to).
> >     
> >     Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
> >     Fixes: 916e4cf46d02 ("ipv6: reuse ip6_frag_id from ip6_ufo_append_data")
> >     Signed-off-by: David S. Miller <davem@davemloft.net>
> >     Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> > 
> > Thanks very much, Ben!
> 
> That's still a useful fix, but will have some fuzz.
> 
> Ben.

I guess this also applies to the 3.16 kernel as well; I dropped both
patches earlier:

 3d0ad09412ff drivers/net: Disable UFO through virtio
 5188cd44c55d drivers/net, ipv6: Select IPv6 fragment idents for virtio UFO packets

but I should have kept the second one.  I'll queue it again for the
next release.

Cheers,
--
Luís
diff mbox

Patch

diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index ffe8fa4..b5c03de 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -66,7 +66,7 @@  static struct cdev macvtap_cdev;
 static const struct proto_ops macvtap_socket_ops;

 #define TUN_OFFLOADS (NETIF_F_HW_CSUM | NETIF_F_TSO_ECN | NETIF_F_TSO | \
-		      NETIF_F_TSO6 | NETIF_F_UFO)
+		      NETIF_F_TSO6)
 #define RX_OFFLOADS (NETIF_F_GRO | NETIF_F_LRO)
 #define TAP_FEATURES (NETIF_F_GSO | NETIF_F_SG)

@@ -565,6 +565,8 @@  static int macvtap_skb_from_vnet_hdr(struct sk_buff *skb,
 			gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
+			pr_warn_once("macvtap: %s: using disabled UFO feature; please fix this program\n",
+				     current->comm);
 			gso_type = SKB_GSO_UDP;
 			break;
 		default:
@@ -610,8 +612,6 @@  static int macvtap_skb_to_vnet_hdr(const struct sk_buff *skb,
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-		else if (sinfo->gso_type & SKB_GSO_UDP)
-			vnet_hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
@@ -953,9 +953,6 @@  static int set_offload(struct macvtap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
-
-		if (arg & TUN_F_UFO)
-			feature_mask |= NETIF_F_UFO;
 	}

 	/* tun/tap driver inverts the usage for TSO offloads, where
@@ -966,7 +963,7 @@  static int set_offload(struct macvtap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_UFO))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;
@@ -1067,7 +1064,7 @@  static long macvtap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN | TUN_F_UFO))
+			    TUN_F_TSO_ECN))
 			return -EINVAL;

 		rtnl_lock();
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d0460a3..f3f544e 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -172,7 +172,7 @@  struct tun_struct {
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6|NETIF_F_UFO)
+			  NETIF_F_TSO6)

 	int			vnet_hdr_sz;
 	int			sndbuf;
@@ -1114,8 +1114,18 @@  static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
+		{
+			static bool warned;
+
+			if (!warned) {
+				warned = true;
+				netdev_warn(tun->dev,
+					    "%s: using disabled UFO feature; please fix this program\n",
+					    current->comm);
+			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
 			break;
+		}
 		default:
 			tun->dev->stats.rx_frame_errors++;
 			kfree_skb(skb);
@@ -1220,8 +1230,6 @@  static ssize_t tun_put_user(struct tun_struct *tun,
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 			else if (sinfo->gso_type & SKB_GSO_TCPV6)
 				gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-			else if (sinfo->gso_type & SKB_GSO_UDP)
-				gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 			else {
 				pr_err("unexpected GSO type: "
 				       "0x%x, gso_size %d, hdr_len %d\n",
@@ -1750,11 +1758,6 @@  static int set_offload(struct tun_struct *tun, unsigned long arg)
 				features |= NETIF_F_TSO6;
 			arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
 		}
-
-		if (arg & TUN_F_UFO) {
-			features |= NETIF_F_UFO;
-			arg &= ~TUN_F_UFO;
-		}
 	}

 	/* This gives the user a way to test for new features in future by
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 19d96c8..43df07d 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -473,8 +473,17 @@  static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
 			break;
 		case VIRTIO_NET_HDR_GSO_UDP:
+		{
+			static bool warned;
+
+			if (!warned) {
+				warned = true;
+				netdev_warn(dev,
+					    "host using disabled UFO feature; please fix it\n");
+			}
 			skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
 			break;
+		}
 		case VIRTIO_NET_HDR_GSO_TCPV6:
 			skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
 			break;
@@ -799,8 +808,6 @@  static int xmit_skb(struct send_queue *sq, struct sk_buff *skb)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
 			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
-		else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP)
-			hdr->hdr.gso_type = VIRTIO_NET_HDR_GSO_UDP;
 		else
 			BUG();
 		if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_ECN)
@@ -1591,7 +1598,7 @@  static int virtnet_probe(struct virtio_device *vdev)
 			dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;

 		if (virtio_has_feature(vdev, VIRTIO_NET_F_GSO)) {
-			dev->hw_features |= NETIF_F_TSO | NETIF_F_UFO
+			dev->hw_features |= NETIF_F_TSO
 				| NETIF_F_TSO_ECN | NETIF_F_TSO6;
 		}
 		/* Individual feature bits: what can host handle? */
@@ -1601,11 +1608,9 @@  static int virtnet_probe(struct virtio_device *vdev)
 			dev->hw_features |= NETIF_F_TSO6;
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
 			dev->hw_features |= NETIF_F_TSO_ECN;
-		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_UFO))
-			dev->hw_features |= NETIF_F_UFO;

 		if (gso)
-			dev->features |= dev->hw_features & (NETIF_F_ALL_TSO|NETIF_F_UFO);
+			dev->features |= dev->hw_features & NETIF_F_ALL_TSO;
 		/* (!csum && gso) case will be fixed by register_netdev() */
 	}
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_CSUM))
@@ -1645,8 +1650,7 @@  static int virtnet_probe(struct virtio_device *vdev)
 	/* If we can receive ANY GSO packets, we must allocate large ones. */
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
 	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN))
 		vi->big_packets = true;

 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -1833,9 +1837,9 @@  static struct virtio_device_id id_table[] = {
 static unsigned int features[] = {
 	VIRTIO_NET_F_CSUM, VIRTIO_NET_F_GUEST_CSUM,
 	VIRTIO_NET_F_GSO, VIRTIO_NET_F_MAC,
-	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
+	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_TSO6,
 	VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
-	VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO,
+	VIRTIO_NET_F_GUEST_ECN,
 	VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ,
 	VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN,
 	VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ,