]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.14/udp-prevent-skbs-lingering-in-tunnel-socket-queues.patch
drop queue-4.14/mips-make-sure-dt-memory-regions-are-valid.patch
[thirdparty/kernel/stable-queue.git] / releases / 4.4.14 / udp-prevent-skbs-lingering-in-tunnel-socket-queues.patch
1 From foo@baz Fri Jun 17 11:18:18 PDT 2016
2 From: Hannes Frederic Sowa <hannes@stressinduktion.org>
3 Date: Thu, 19 May 2016 15:58:33 +0200
4 Subject: udp: prevent skbs lingering in tunnel socket queues
5
6 From: Hannes Frederic Sowa <hannes@stressinduktion.org>
7
8 [ Upstream commit e5aed006be918af163eb397e45aa5ea6cefd5e01 ]
9
10 In case we find a socket with encapsulation enabled we should call
11 the encap_recv function even if just a udp header without payload is
12 available. The callbacks are responsible for correctly verifying and
13 dropping the packets.
14
15 Also, in case the header validation fails for geneve and vxlan we
16 shouldn't put the skb back into the socket queue, no one will pick
17 them up there. Instead we can simply discard them in the respective
18 encap_recv functions.
19
20 Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
21 Signed-off-by: David S. Miller <davem@davemloft.net>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23 ---
24 drivers/net/geneve.c | 10 +++-------
25 drivers/net/vxlan.c | 10 ++--------
26 net/ipv4/udp.c | 2 +-
27 net/ipv6/udp.c | 2 +-
28 4 files changed, 7 insertions(+), 17 deletions(-)
29
30 --- a/drivers/net/geneve.c
31 +++ b/drivers/net/geneve.c
32 @@ -310,15 +310,15 @@ static int geneve_udp_encap_recv(struct
33
34 /* Need Geneve and inner Ethernet header to be present */
35 if (unlikely(!pskb_may_pull(skb, GENEVE_BASE_HLEN)))
36 - goto error;
37 + goto drop;
38
39 /* Return packets with reserved bits set */
40 geneveh = geneve_hdr(skb);
41 if (unlikely(geneveh->ver != GENEVE_VER))
42 - goto error;
43 + goto drop;
44
45 if (unlikely(geneveh->proto_type != htons(ETH_P_TEB)))
46 - goto error;
47 + goto drop;
48
49 opts_len = geneveh->opt_len * 4;
50 if (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len,
51 @@ -336,10 +336,6 @@ drop:
52 /* Consume bad packet */
53 kfree_skb(skb);
54 return 0;
55 -
56 -error:
57 - /* Let the UDP layer deal with the skb */
58 - return 1;
59 }
60
61 static struct socket *geneve_create_sock(struct net *net, bool ipv6,
62 --- a/drivers/net/vxlan.c
63 +++ b/drivers/net/vxlan.c
64 @@ -1254,7 +1254,7 @@ static int vxlan_udp_encap_recv(struct s
65
66 /* Need Vxlan and inner Ethernet header to be present */
67 if (!pskb_may_pull(skb, VXLAN_HLEN))
68 - goto error;
69 + goto drop;
70
71 vxh = (struct vxlanhdr *)(udp_hdr(skb) + 1);
72 flags = ntohl(vxh->vx_flags);
73 @@ -1344,13 +1344,7 @@ drop:
74 bad_flags:
75 netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n",
76 ntohl(vxh->vx_flags), ntohl(vxh->vx_vni));
77 -
78 -error:
79 - if (tun_dst)
80 - dst_release((struct dst_entry *)tun_dst);
81 -
82 - /* Return non vxlan pkt */
83 - return 1;
84 + goto drop;
85 }
86
87 static int arp_reduce(struct net_device *dev, struct sk_buff *skb)
88 --- a/net/ipv4/udp.c
89 +++ b/net/ipv4/udp.c
90 @@ -1531,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, s
91
92 /* if we're overly short, let UDP handle it */
93 encap_rcv = ACCESS_ONCE(up->encap_rcv);
94 - if (skb->len > sizeof(struct udphdr) && encap_rcv) {
95 + if (encap_rcv) {
96 int ret;
97
98 /* Verify checksum before giving to encap */
99 --- a/net/ipv6/udp.c
100 +++ b/net/ipv6/udp.c
101 @@ -647,7 +647,7 @@ int udpv6_queue_rcv_skb(struct sock *sk,
102
103 /* if we're overly short, let UDP handle it */
104 encap_rcv = ACCESS_ONCE(up->encap_rcv);
105 - if (skb->len > sizeof(struct udphdr) && encap_rcv) {
106 + if (encap_rcv) {
107 int ret;
108
109 /* Verify checksum before giving to encap */