From patchwork Mon Nov 13 14:00:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 118775 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1850430qgn; Mon, 13 Nov 2017 06:19:36 -0800 (PST) X-Google-Smtp-Source: AGs4zMa+V+i9F6B2v/2HkQpX0cLDO9z1A9qIARKraa1ZByDEn2cPUB8MCjKgW/bnGsNBQbHhh6eF X-Received: by 10.200.25.207 with SMTP id s15mr6965510qtk.94.1510582776774; Mon, 13 Nov 2017 06:19:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510582776; cv=none; d=google.com; s=arc-20160816; b=N6ywbqi0bUJ9Kqxk5CNoaT0DKWPkjCwWt6LFNs+gJEZnMvEPW15hX0w8wgzsikyQoc XdtxWXjfh8c4jvMCsf26k4chx4QMjzNSH28dS1rFr+TPbGojEWwd9kWVr4gLACiBgSf2 tmMHIYCjIV0J3eCzv9l3RcWjlZVKeRZWhn+WrNSN96uc5kww1+Ji2zvjgFOn1CDoL7xv hpItBP+xI68+K1OwitBFwYCTK2yf1BumGQqLGYyAzI1Ot7IuHcQerV0wXJ+xbc7rCNHg vvU+klLI+1rBv8MXSL5fKbMU0UOc41BcP6hmzDq6jOt2T09Hik15B9viDf6Y/9+2y4gr tzvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=6mX9WS22g55FieTHAcNqD/OVVLdqbVMA/FxneWoMbBY=; b=G6poWtWsyR+O1ldsQxZNkkkG/7qxYcDd1eKcR1d0IS6wCPApAcele6mTTo+qrTt1dv tQ57Z3QQcz5VISpjZBff/q4bPw36PpcxKWNq8SU4903ZlYkIdnVwvD1bgvcHtaGgCQV3 wXjnVkSEHcU5+XOTeVpNgQ2wtbVdqZ4/KZ3Mq9SkfYhUDeyQyidWIL9scN6Hr0F/aJwk mXlnPP5mjywi7lajJo1hxcV1aO9DTDt52q91Xct+gOg20XTIADlmE3r/8JgNPTxS+bao 6GbVnkyG3tWV03+PL3zz0GLmtvpBQa4cSb2txgPaL//Vm9EBWsM7bguw1byNzkm68NoC fJ2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id o77si11786610qka.115.2017.11.13.06.19.36; Mon, 13 Nov 2017 06:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 653BC6102F; Mon, 13 Nov 2017 14:19:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 03C5461105; Mon, 13 Nov 2017 14:02:58 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 371A861039; Mon, 13 Nov 2017 14:01:45 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id C16F360965 for ; Mon, 13 Nov 2017 14:00:38 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward101j.mail.yandex.net (Yandex) with ESMTP id B58851240ED2 for ; Mon, 13 Nov 2017 17:00:37 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id SHNOrkF1F6-0bLqCadQ; Mon, 13 Nov 2017 17:00:37 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 955rfAmciQ-0bk4IUJo; Mon, 13 Nov 2017 17:00:37 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Mon, 13 Nov 2017 17:00:26 +0300 Message-Id: <1510581630-13993-13-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510581630-13993-1-git-send-email-odpbot@yandex.ru> References: <1510581630-13993-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v16 12/16] linux-gen: ipsec: validate ip header total length X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Check that IP packet length from the header is not bogus. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 243 (lumag:ipsec-packet-impl-3) ** https://github.com/Linaro/odp/pull/243 ** Patch: https://github.com/Linaro/odp/pull/243.patch ** Base sha: a908a4dead95321e84d6a8a23de060051dcd8969 ** Merge commit sha: 845914564f2d99792452ac22a524279f44496a1d **/ platform/linux-generic/odp_ipsec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index f8085756f..aadc671f9 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -286,6 +286,11 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, ipsec_offset = ip_offset + ip_hdr_len; + if (odp_be_to_cpu_16(ip->tot_len) + ip_offset > odp_packet_len(pkt)) { + status->error.alg = 1; + goto err; + } + if (_ODP_IPV4HDR_IS_FRAGMENT(odp_be_to_cpu_16(ip->frag_offset))) { status->error.proto = 1; goto err; @@ -634,6 +639,11 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, goto err; } + if (odp_be_to_cpu_16(ip->tot_len) + ip_offset > odp_packet_len(pkt)) { + status->error.alg = 1; + goto err; + } + if (ODP_IPSEC_MODE_TUNNEL == ipsec_sa->mode) { _odp_ipv4hdr_t out_ip; uint16_t tot_len;