From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227wudwS2ZWwElr5QPTzi6Wxl8WfcnwALsoGUdGn0foh5+0OQfcSi6q+WfEOxrrsMkphcDAR ARC-Seal: i=1; a=rsa-sha256; t=1517256259; cv=none; d=google.com; s=arc-20160816; b=PrXb1UJCJJ8AUV7r40nfV7dAGD4hsAzQcejBtMHcP1HJWjWkl6erPUbJT9PuDZJhof Rlu4945yoQ14RbmzT+1+ReA1eStZfz2schWk88nOgqALz36SyTPO/FoXveBqOTPiGozC bIO76wnq0lnGLXeA/ks3IcWLe4f4n3bMjXc2zt1KrzgAQjhe0cyU4dP9XJyrTpP+Za46 dWJOtkug1P46Hdkxxu6DcA6MIy9v+GaNAiwR5pK/QitGx32qClukY2mYdPKaVNJd4LNU eXZ8qSznIpXi2peJAEuvXKi0aEU/qJHr8dBELbraIDMe7aEqywQrYrNaQZ9fRGNhRHG0 7NIQ== 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=TitP+aA2vbXgY/ptMilRxj5nqiAGqEGVqqMP+vJ7MEM=; b=YzAGzxuXfHd+ukFSJc9b2xSh/iuvHK5n0dTq/hks1sshCYgLTs4pTrrUiPJ6I03ruZ 6JHpsToQ065aKE3NXJb7WVF66NvJKIi6cF4DEDsRmydmOkBLLhcSBoc1Ie8sqTa5A7fY Md2eeQz3WxrRd1tKPiNoeCEwyZiENohGv9WxEFwaIaCwe8e/ACeIbVXfL2Z81biuK+pJ iDTPf+gr8hM6XwVzT8/Xwoa8kShUP5+TaV9f0/X1UCH3qEI4vhFABiaJazKy90wW0ot7 /IticZ25lc+RyOlqLZ7iOjbjNRRVQ1Qws3InXI8VMmIs6F7A8UDWEJNcFWHB0BG98Rmr vlMg== 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 4.14 31/71] net: qdisc_pkt_len_init() should be more robust Date: Mon, 29 Jan 2018 13:56:59 +0100 Message-Id: <20180129123829.317677054@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@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?1590958498686278864?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-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 @@ -3128,10 +3128,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,