]>
Commit | Line | Data |
---|---|---|
af47e471 GKH |
1 | From foo@baz Fri Aug 12 09:34:44 CEST 2016 |
2 | From: Daniel Borkmann <daniel@iogearbox.net> | |
3 | Date: Mon, 25 Jul 2016 18:06:12 +0200 | |
4 | Subject: udp: use sk_filter_trim_cap for udp{,6}_queue_rcv_skb | |
5 | ||
6 | From: Daniel Borkmann <daniel@iogearbox.net> | |
7 | ||
8 | [ Upstream commit ba66bbe5480a012108958a71cff88b23dce84956 ] | |
9 | ||
10 | After a612769774a3 ("udp: prevent bugcheck if filter truncates packet | |
11 | too much"), there followed various other fixes for similar cases such | |
12 | as f4979fcea7fd ("rose: limit sk_filter trim to payload"). | |
13 | ||
14 | Latter introduced a new helper sk_filter_trim_cap(), where we can pass | |
15 | the trim limit directly to the socket filter handling. Make use of it | |
16 | here as well with sizeof(struct udphdr) as lower cap limit and drop the | |
17 | extra skb->len test in UDP's input path. | |
18 | ||
19 | Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> | |
20 | Cc: Willem de Bruijn <willemb@google.com> | |
21 | Acked-by: Willem de Bruijn <willemb@google.com> | |
22 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
23 | Signed-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); |