Skip to content

Commit a612769

Browse files
mkubecekdavem330
authored andcommitted
udp: prevent bugcheck if filter truncates packet too much
If socket filter truncates an udp packet below the length of UDP header in udpv6_queue_rcv_skb() or udp_queue_rcv_skb(), it will trigger a BUG_ON in skb_pull_rcsum(). This BUG_ON (and therefore a system crash if kernel is configured that way) can be easily enforced by an unprivileged user which was reported as CVE-2016-6162. For a reproducer, see http://seclists.org/oss-sec/2016/q3/8 Fixes: e6afc8a ("udp: remove headers from UDP packets before queueing") Reported-by: Marco Grassi <[email protected]> Signed-off-by: Michal Kubecek <[email protected]> Acked-by: Eric Dumazet <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f3ea311 commit a612769

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

net/ipv4/udp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
15831583

15841584
if (sk_filter(sk, skb))
15851585
goto drop;
1586+
if (unlikely(skb->len < sizeof(struct udphdr)))
1587+
goto drop;
15861588

15871589
udp_csum_pull_header(skb);
15881590
if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {

net/ipv6/udp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
620620

621621
if (sk_filter(sk, skb))
622622
goto drop;
623+
if (unlikely(skb->len < sizeof(struct udphdr)))
624+
goto drop;
623625

624626
udp_csum_pull_header(skb);
625627
if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {

0 commit comments

Comments
 (0)