From patchwork Mon Nov 13 02:00:15 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: 118710 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1273764qgn; Sun, 12 Nov 2017 18:13:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMbXhNM1Gln02WH71I2Bm9CAc6FZ8YmRTUvzIRhoAoMfQAHlFYS89KCHukwc0QK++MIfVVrC X-Received: by 10.55.195.216 with SMTP id r85mr10982765qkl.218.1510539184522; Sun, 12 Nov 2017 18:13:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510539184; cv=none; d=google.com; s=arc-20160816; b=CLlPyyJ1pirloRTuPqOAKlC6FHMnQW6qw7e48JZhslHuddRJ0uKPFRuR1sT3NQQ655 3QeqriGbHsO+xYN3ZtKYvFCpa5Z4PJZYqU7bVqaH3SVE1mAQZz9yks8kwb5inZ/+lxon XD9fuW4oVZd7hm71AVugPA6xpjW2Z7t/s4b15m/QHx+AL3V3jW359LK4C46ztLng51jh zLzLuULir/GLqIv6sDnLv6S+0nzHyOHxL1G3fz7MP9T37/Yq/9XGShvi26yPD+cQiJpE 1h+OVdz1WZziRZgmoq9B+4d+bFPf7ynEhHkPJLnST4gKeSYzPGF+Du+4DDgMQmtnTLBn 6cFA== 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=UCdAV3h/BfmurQ0mVp+AobjFZTzgu4YkPjgbH/QO880=; b=Ojts4j1jlUEPCNHyWjxZLkMVYVnpQi9wLtvdT2GeH0+8yq1eNogEHWIFYbOjnsZ86H YBoMcJLutnsEDhW72mqs/RL/LcwjjlETh+xDmb4gboK+lJXPtXhbozx4qdsYTJynB9zj DyB+jBwAAU/NLfP8+QDM9fivj11V7SjXWj6a2urTOI4A8KIxiK1wkcyfx39yGGaQTSr+ 3nQZE5IH/Qc2peAPvW4d+KDFVU+5Qtkafj7FLNUIZQO3lSTttTfWCRe7PIPnQrgnmzfI flYLHUz19Gvmd4mZzFCQRbkHCQn5mkKJQ/eDsALKRNDsmTwfMOydLPhfVv1Z55N0UkVg g3zw== 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 b58si14141651qtb.246.2017.11.12.18.13.04; Sun, 12 Nov 2017 18:13:04 -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 0B8FD60DC1; Mon, 13 Nov 2017 02:13:04 +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 5050160C1B; Mon, 13 Nov 2017 02:03:43 +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 9FF8C60BFF; Mon, 13 Nov 2017 02:03:37 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id 7701D60BDF for ; Mon, 13 Nov 2017 02:00:51 +0000 (UTC) Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 4ADE734D35D6 for ; Mon, 13 Nov 2017 05:00:26 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 05KoknnTcM-0QC4dnjt; Mon, 13 Nov 2017 05:00:26 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id uZeq9OjDfk-0PvuoY9h; Mon, 13 Nov 2017 05:00:25 +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 05:00:15 +0300 Message-Id: <1510538419-566-11-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510538419-566-1-git-send-email-odpbot@yandex.ru> References: <1510538419-566-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v15 10/14] 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: 44a6636daa5f976c8aac76116e80e0c764352072 **/ 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 61f2dc51d..400ef2958 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;