From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756534AbcGHXbu (ORCPT ); Fri, 8 Jul 2016 19:31:50 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33813 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756299AbcGHXbo (ORCPT ); Fri, 8 Jul 2016 19:31:44 -0400 Message-ID: <1468020700.30694.38.camel@edumazet-glaptop3.roam.corp.google.com> Subject: Re: [PATCH net] udp: prevent bugcheck if filter truncates packet too much From: Eric Dumazet To: Michal Kubecek , Willem de Bruijn Cc: "David S. Miller" , samanthakumar , Marco Grassi , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Date: Sat, 09 Jul 2016 01:31:40 +0200 In-Reply-To: <20160708155233.C78AAA0ECC@unicorn.suse.cz> References: <20160708155233.C78AAA0ECC@unicorn.suse.cz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2016-07-08 at 17:52 +0200, Michal Kubecek wrote: > 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: e6afc8ace6dd ("udp: remove headers from UDP packets before queueing") > Reported-by: Marco Grassi > Signed-off-by: Michal Kubecek > --- > net/ipv4/udp.c | 2 ++ > net/ipv6/udp.c | 2 ++ > 2 files changed, 4 insertions(+) > > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c > index ca5e8ea29538..4aed8fc23d32 100644 > --- a/net/ipv4/udp.c > +++ b/net/ipv4/udp.c > @@ -1583,6 +1583,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) > > if (sk_filter(sk, skb)) > goto drop; > + if (unlikely(skb->len < sizeof(struct udphdr))) > + goto drop; > > udp_csum_pull_header(skb); > if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) { > diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c > index 005dc82c2138..acc09705618b 100644 > --- a/net/ipv6/udp.c > +++ b/net/ipv6/udp.c > @@ -620,6 +620,8 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) > > if (sk_filter(sk, skb)) > goto drop; > + if (unlikely(skb->len < sizeof(struct udphdr))) > + goto drop; > > udp_csum_pull_header(skb); > if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) { Arg :( Acked-by: Eric Dumazet Thanks !