From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226uxPyoiLWeIvAhVcffC1Bd83PFiEmhwwvRhw3Gwulyg7W3FLRV5Cmcgk7jj55boNoebzI1 ARC-Seal: i=1; a=rsa-sha256; t=1517256598; cv=none; d=google.com; s=arc-20160816; b=RKRCDbheVXcZbkQkgMxATvUCa48vdK8unEpo2z9vKD1LSYvR6o7F3Cxsic4gH2AGnr 3ji23rnhVS1wzuWGTxZ/csKmNUr4/SwmeEENiekeOtRxxCbSf42qAmMkZdAorpTOeJOp PU1SVec50zBWlC0LOD37Fqk+wqqmvfIQuFssdHYthpkJMZhgYoX8bRAnwia7vrvjeQkw A7kjfQJoklOTIelQKeaZj/t0JTyFeemii1deVi3p0ZviKVjtLsrHg/TZZvSZ9xCByVqv w4zDRnGt3bSzGI15tuVuuagYqIOeJTlmKeAOGRC83WtzikiHv2LBxNaVDesySUzSDcue S6jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=FJjL5KIKVc00/bNAF2XFtsnRaiqsm7KRmX0kYX/mV3Y=; b=aZ+lgedXDDU++yESagvntfhG9VJRDdOlw4n4hoGCTvxS27NJ6BBs7WPI9cKA8RxfkU 4t2G6aH7tfc86cGMs9ql03mB0DbeW7EvxKOdN7J2SjYTXe++mQRNOwrdaX316Y2ElC8F +vFuiee09oyw7STwY8VnB9hQ6tE/tSQFo+FzZl+7PKzVSz8DqO/UYmlEEWZXCOrHRwgR yMGdiFOWqvslG+aW7dD966dhDhTJ086MZ8RMsOE6qJg3a5/YpVzlKyOyMgNIPOPDx7ax dSsCAhuTU7F/wKG9aNYhDTocyc8+LDLjSrMX0M3NVgRZodIS9mZRGee3rxoIf8cbuM9/ XgUw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Willem de Bruijn , Jason Wang , syzbot+9da69ebac7dddd804552@syzkaller.appspotmail.com, "David S. Miller" Subject: [PATCH 3.18 45/52] net: qdisc_pkt_len_init() should be more robust Date: Mon, 29 Jan 2018 13:57:03 +0100 Message-Id: <20180129123630.151216006@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123628.168904217@linuxfoundation.org> References: <20180129123628.168904217@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958498686278864?= X-GMAIL-MSGID: =?utf-8?q?1590958855406562543?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit 7c68d1a6b4db9012790af7ac0f0fdc0d2083422a ] Without proper validation of DODGY packets, we might very well feed qdisc_pkt_len_init() with invalid GSO packets. tcp_hdrlen() might access out-of-bound data, so let's use skb_header_pointer() and proper checks. Whole story is described in commit d0c081b49137 ("flow_dissector: properly cap thoff field") We have the goal of validating DODGY packets earlier in the stack, so we might very well revert this fix in the future. Signed-off-by: Eric Dumazet Cc: Willem de Bruijn Cc: Jason Wang Reported-by: syzbot+9da69ebac7dddd804552@syzkaller.appspotmail.com Acked-by: Jason Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/core/dev.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2772,10 +2772,21 @@ static void qdisc_pkt_len_init(struct sk hdr_len = skb_transport_header(skb) - skb_mac_header(skb); /* + transport layer */ - if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) - hdr_len += tcp_hdrlen(skb); - else - hdr_len += sizeof(struct udphdr); + if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) { + const struct tcphdr *th; + struct tcphdr _tcphdr; + + th = skb_header_pointer(skb, skb_transport_offset(skb), + sizeof(_tcphdr), &_tcphdr); + if (likely(th)) + hdr_len += __tcp_hdrlen(th); + } else { + struct udphdr _udphdr; + + if (skb_header_pointer(skb, skb_transport_offset(skb), + sizeof(_udphdr), &_udphdr)) + hdr_len += sizeof(struct udphdr); + } if (shinfo->gso_type & SKB_GSO_DODGY) gso_segs = DIV_ROUND_UP(skb->len - hdr_len,