aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2016-07-25 12:06:12 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-26 00:40:33 -0400
commitba66bbe5480a012108958a71cff88b23dce84956 (patch)
tree1896547dcd8bc441534f7ce2ca3b21f4911ec920
parentdeb1f45a2f8479ffa5a791e2c024a640a08f729e (diff)
udp: use sk_filter_trim_cap for udp{,6}_queue_rcv_skb
After a612769774a3 ("udp: prevent bugcheck if filter truncates packet too much"), there followed various other fixes for similar cases such as f4979fcea7fd ("rose: limit sk_filter trim to payload"). Latter introduced a new helper sk_filter_trim_cap(), where we can pass the trim limit directly to the socket filter handling. Make use of it here as well with sizeof(struct udphdr) as lower cap limit and drop the extra skb->len test in UDP's input path. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Cc: Willem de Bruijn <willemb@google.com> Acked-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/udp.c4
-rw-r--r--net/ipv6/udp.c4
2 files changed, 2 insertions, 6 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 4aed8fc23d32..e61f7cd65d08 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1581,9 +1581,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1581 udp_lib_checksum_complete(skb)) 1581 udp_lib_checksum_complete(skb))
1582 goto csum_error; 1582 goto csum_error;
1583 1583
1584 if (sk_filter(sk, skb)) 1584 if (sk_filter_trim_cap(sk, skb, sizeof(struct udphdr)))
1585 goto drop;
1586 if (unlikely(skb->len < sizeof(struct udphdr)))
1587 goto drop; 1585 goto drop;
1588 1586
1589 udp_csum_pull_header(skb); 1587 udp_csum_pull_header(skb);
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index ad5292be17bd..81e2f98b958d 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -618,9 +618,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
618 udp_lib_checksum_complete(skb)) 618 udp_lib_checksum_complete(skb))
619 goto csum_error; 619 goto csum_error;
620 620
621 if (sk_filter(sk, skb)) 621 if (sk_filter_trim_cap(sk, skb, sizeof(struct udphdr)))
622 goto drop;
623 if (unlikely(skb->len < sizeof(struct udphdr)))
624 goto drop; 622 goto drop;
625 623
626 udp_csum_pull_header(skb); 624 udp_csum_pull_header(skb);