]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.7.1/udp-use-sk_filter_trim_cap-for-udp-6-_queue_rcv_skb.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.7.1 / udp-use-sk_filter_trim_cap-for-udp-6-_queue_rcv_skb.patch
CommitLineData
af47e471
GKH
1From foo@baz Fri Aug 12 09:34:44 CEST 2016
2From: Daniel Borkmann <daniel@iogearbox.net>
3Date: Mon, 25 Jul 2016 18:06:12 +0200
4Subject: udp: use sk_filter_trim_cap for udp{,6}_queue_rcv_skb
5
6From: Daniel Borkmann <daniel@iogearbox.net>
7
8[ Upstream commit ba66bbe5480a012108958a71cff88b23dce84956 ]
9
10After a612769774a3 ("udp: prevent bugcheck if filter truncates packet
11too much"), there followed various other fixes for similar cases such
12as f4979fcea7fd ("rose: limit sk_filter trim to payload").
13
14Latter introduced a new helper sk_filter_trim_cap(), where we can pass
15the trim limit directly to the socket filter handling. Make use of it
16here as well with sizeof(struct udphdr) as lower cap limit and drop the
17extra skb->len test in UDP's input path.
18
19Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
20Cc: Willem de Bruijn <willemb@google.com>
21Acked-by: Willem de Bruijn <willemb@google.com>
22Signed-off-by: David S. Miller <davem@davemloft.net>
23Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24---
25 net/ipv4/udp.c | 4 +---
26 net/ipv6/udp.c | 4 +---
27 2 files changed, 2 insertions(+), 6 deletions(-)
28
29--- a/net/ipv4/udp.c
30+++ b/net/ipv4/udp.c
31@@ -1581,9 +1581,7 @@ int udp_queue_rcv_skb(struct sock *sk, s
32 udp_lib_checksum_complete(skb))
33 goto csum_error;
34
35- if (sk_filter(sk, skb))
36- goto drop;
37- if (unlikely(skb->len < sizeof(struct udphdr)))
38+ if (sk_filter_trim_cap(sk, skb, sizeof(struct udphdr)))
39 goto drop;
40
41 udp_csum_pull_header(skb);
42--- a/net/ipv6/udp.c
43+++ b/net/ipv6/udp.c
44@@ -618,9 +618,7 @@ int udpv6_queue_rcv_skb(struct sock *sk,
45 udp_lib_checksum_complete(skb))
46 goto csum_error;
47
48- if (sk_filter(sk, skb))
49- goto drop;
50- if (unlikely(skb->len < sizeof(struct udphdr)))
51+ if (sk_filter_trim_cap(sk, skb, sizeof(struct udphdr)))
52 goto drop;
53
54 udp_csum_pull_header(skb);