Patch "vlan: Fix header ops passthru when doing TX VLAN offload." has been added to the 3.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vlan: Fix header ops passthru when doing TX VLAN offload.

to the 3.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vlan-fix-header-ops-passthru-when-doing-tx-vlan-offload.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From foo@baz Mon Jan 13 09:39:01 PST 2014
From: "David S. Miller" <davem@xxxxxxxxxxxxx>
Date: Tue, 31 Dec 2013 16:23:35 -0500
Subject: vlan: Fix header ops passthru when doing TX VLAN offload.

From: "David S. Miller" <davem@xxxxxxxxxxxxx>

[ Upstream commit 2205369a314e12fcec4781cc73ac9c08fc2b47de ]

When the vlan code detects that the real device can do TX VLAN offloads
in hardware, it tries to arrange for the real device's header_ops to
be invoked directly.

But it does so illegally, by simply hooking the real device's
header_ops up to the VLAN device.

This doesn't work because we will end up invoking a set of header_ops
routines which expect a device type which matches the real device, but
will see a VLAN device instead.

Fix this by providing a pass-thru set of header_ops which will arrange
to pass the proper real device instead.

To facilitate this add a dev_rebuild_header().  There are
implementations which provide a ->cache and ->create but not a
->rebuild (f.e. PLIP).  So we need a helper function just like
dev_hard_header() to avoid crashes.

Use this helper in the one existing place where the
header_ops->rebuild was being invoked, the neighbour code.

With lots of help from Florian Westphal.

Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 include/linux/netdevice.h |    9 +++++++++
 net/8021q/vlan_dev.c      |   19 ++++++++++++++++++-
 net/core/neighbour.c      |    2 +-
 3 files changed, 28 insertions(+), 2 deletions(-)

--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1772,6 +1772,15 @@ static inline int dev_parse_header(const
 	return dev->header_ops->parse(skb, haddr);
 }
 
+static inline int dev_rebuild_header(struct sk_buff *skb)
+{
+	const struct net_device *dev = skb->dev;
+
+	if (!dev->header_ops || !dev->header_ops->rebuild)
+		return 0;
+	return dev->header_ops->rebuild(skb);
+}
+
 typedef int gifconf_func_t(struct net_device * dev, char __user * bufptr, int len);
 extern int		register_gifconf(unsigned int family, gifconf_func_t * gifconf);
 static inline int unregister_gifconf(unsigned int family)
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -549,6 +549,23 @@ static const struct header_ops vlan_head
 	.parse	 = eth_header_parse,
 };
 
+static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev,
+				     unsigned short type,
+				     const void *daddr, const void *saddr,
+				     unsigned int len)
+{
+	struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
+	struct net_device *real_dev = vlan->real_dev;
+
+	return dev_hard_header(skb, real_dev, type, daddr, saddr, len);
+}
+
+static const struct header_ops vlan_passthru_header_ops = {
+	.create	 = vlan_passthru_hard_header,
+	.rebuild = dev_rebuild_header,
+	.parse	 = eth_header_parse,
+};
+
 static struct device_type vlan_type = {
 	.name	= "vlan",
 };
@@ -592,7 +609,7 @@ static int vlan_dev_init(struct net_devi
 
 	dev->needed_headroom = real_dev->needed_headroom;
 	if (real_dev->features & NETIF_F_HW_VLAN_CTAG_TX) {
-		dev->header_ops      = real_dev->header_ops;
+		dev->header_ops      = &vlan_passthru_header_ops;
 		dev->hard_header_len = real_dev->hard_header_len;
 	} else {
 		dev->header_ops      = &vlan_header_ops;
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1274,7 +1274,7 @@ int neigh_compat_output(struct neighbour
 
 	if (dev_hard_header(skb, dev, ntohs(skb->protocol), NULL, NULL,
 			    skb->len) < 0 &&
-	    dev->header_ops->rebuild(skb))
+	    dev_rebuild_header(skb))
 		return 0;
 
 	return dev_queue_xmit(skb);


Patches currently in stable-queue which might be from davem@xxxxxxxxxxxxx are

queue-3.10/ipv6-don-t-count-addrconf-generated-routes-against-gc-limit.patch
queue-3.10/drivers-net-hamradio-integer-overflow-in-hdlcdrv_ioctl.patch
queue-3.10/macvtap-update-file-current-position.patch
queue-3.10/net-unix-allow-set_peek_off-to-fail.patch
queue-3.10/vlan-fix-header-ops-passthru-when-doing-tx-vlan-offload.patch
queue-3.10/ipv6-always-set-the-new-created-dst-s-from-in-ip6_rt_copy.patch
queue-3.10/netvsc-don-t-flush-peers-notifying-work-during-setting-mtu.patch
queue-3.10/net-do-not-pretend-fraglist-support.patch
queue-3.10/net-loosen-constraints-for-recalculating-checksum-in-skb_segment.patch
queue-3.10/macvtap-signal-truncated-packets.patch
queue-3.10/net-rose-restore-old-recvmsg-behavior.patch
queue-3.10/net-inet_diag-zero-out-uninitialized-idiag_-src-dst-fields.patch
queue-3.10/virtio-net-make-all-rx-paths-handle-errors-consistently.patch
queue-3.10/virtio_net-fix-error-handling-for-mergeable-buffers.patch
queue-3.10/packet-fix-send-path-when-running-with-proto-0.patch
queue-3.10/tg3-initialize-reg_base_addr-at-pci-config-offset-120-to-0.patch
queue-3.10/net-drop_monitor-fix-the-value-of-maxattr.patch
queue-3.10/net-unix-allow-bind-to-fail-on-mutex-lock.patch
queue-3.10/macvtap-do-not-double-count-received-packets.patch
queue-3.10/hamradio-yam-fix-info-leak-in-ioctl.patch
queue-3.10/netpoll-fix-missing-txq-unlock-and-and-oops.patch
queue-3.10/tun-update-file-current-position.patch
queue-3.10/ip_gre-fix-msg_name-parsing-for-recvfrom-recvmsg.patch
queue-3.10/bridge-use-spin_lock_bh-in-br_multicast_set_hash_max.patch
queue-3.10/virtio-net-fix-refill-races-during-restore.patch
queue-3.10/virtio-delete-napi-structures-from-netdev-before-releasing-memory.patch
queue-3.10/net-llc-fix-use-after-free-in-llc_ui_recvmsg.patch
queue-3.10/net-fec-fix-potential-use-after-free.patch
queue-3.10/rds-prevent-dereference-of-a-null-device.patch
queue-3.10/rds-prevent-bug_on-triggered-on-congestion-update-to-loopback.patch
queue-3.10/ipv6-fixed-support-for-blackhole-and-prohibit-routes.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]