]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.36.2/vlan-avoid-hwaccel-vlan-packets-when-vid-not-used.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.36.2 / vlan-avoid-hwaccel-vlan-packets-when-vid-not-used.patch
CommitLineData
bcd4f083
GKH
1From jesse@nicira.com Tue Dec 7 11:49:39 2010
2From: Jesse Gross <jesse@nicira.com>
3Date: Mon, 8 Nov 2010 13:23:01 -0800
4Subject: [stable] [PATCH 2.6.36 stable] vlan: Avoid hwaccel vlan packets when vid not used.
5To: stable@kernel.org
6Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>
7Message-ID: <1289251381-6671-1-git-send-email-jesse@nicira.com>
8
9From: Jesse Gross <jesse@nicira.com>
10
11[This patch applies only to 2.6.36 stable. The problem was introduced
12in that release and is already fixed by larger changes to the vlan
13code in 2.6.37.]
14
15Normally hardware accelerated vlan packets are quickly dropped if
16there is no corresponding vlan device configured. The one exception
17is promiscuous mode, where we allow all of these packets through so
18they can be picked up by tcpdump. However, this behavior causes a
19crash if we actually try to receive these packets. This fixes that
20crash by ignoring packets with vids not corresponding to a configured
21device in the vlan hwaccel routines and then dropping them before they
22get to consumers in the network stack.
23
24
25Reported-by: Ben Greear <greearb@candelatech.com>
26Tested-by: Nikola Ciprich <extmaillist@linuxbox.cz>
27Signed-off-by: Jesse Gross <jesse@nicira.com>
28Acked-by: David Miller <davem@davemloft.net>
29Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
30
31---
32 net/8021q/vlan_core.c | 3 +++
2d4e186d
GKH
33 net/core/dev.c | 10 ++++++++++
34 2 files changed, 13 insertions(+)
bcd4f083
GKH
35
36--- a/net/8021q/vlan_core.c
37+++ b/net/8021q/vlan_core.c
38@@ -43,6 +43,9 @@ int vlan_hwaccel_do_receive(struct sk_bu
39 struct net_device *dev = skb->dev;
40 struct vlan_rx_stats *rx_stats;
41
42+ if (unlikely(!is_vlan_dev(dev)))
43+ return 0;
44+
45 skb->dev = vlan_dev_info(dev)->real_dev;
46 netif_nit_deliver(skb);
47
48--- a/net/core/dev.c
49+++ b/net/core/dev.c
2d4e186d 50@@ -2891,6 +2891,15 @@ static int __netif_receive_skb(struct sk
bcd4f083
GKH
51 ncls:
52 #endif
53
54+ /* If we got this far with a hardware accelerated VLAN tag, it means
55+ * that we were put in promiscuous mode but nobody is interested in
2d4e186d 56+ * this vid. Drop the packet now to prevent it from getting propagated
bcd4f083
GKH
57+ * to other parts of the stack that won't know how to deal with packets
58+ * tagged in this manner.
59+ */
2d4e186d
GKH
60+ if (unlikely(vlan_tx_tag_present(skb)))
61+ goto bypass;
bcd4f083
GKH
62+
63 /* Handle special case of bridge or macvlan */
64 rx_handler = rcu_dereference(skb->dev->rx_handler);
65 if (rx_handler) {
2d4e186d
GKH
66@@ -2927,6 +2936,7 @@ ncls:
67 }
68 }
69
70+bypass:
71 if (pt_prev) {
72 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
73 } else {