From patchwork Sun Nov 12 12:00:19 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: 118657 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp688730qgn; Sun, 12 Nov 2017 04:17:41 -0800 (PST) X-Google-Smtp-Source: AGs4zMapzBZ+jC8S4hU1AGb3qVL7+La8dNKvFwpBHJ0QjkxcUP0IXonb/RVHAdnIML6gIONm0XLM X-Received: by 10.55.175.135 with SMTP id y129mr512734qke.128.1510489061596; Sun, 12 Nov 2017 04:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510489061; cv=none; d=google.com; s=arc-20160816; b=tJZaWpP5acx7O2F2Ck8V7jZG3TOMwNmW0eIF3Z/SCyrm6BcwPeKVhn6O4KTrPhkG2V FUGOZDHZM+kVi1BMdQLcg/1GUZjmyON36PLFJs1EObtt6DDA52XH3rKEFPHpInTmeA+n 99vmKq1LgbZho2RAUV7MeuSEZegCcFR4eR7F6CNEAYeX1rYT6Na/ShOAKsEJUWPxsr/u qFzGOTD5MrEvK/HD6NUxxAEGU/qBRq6YnpDE63oHSHdyfKf66RkcCljs+6S1s+Gmv1Qu 8CvqV2aOiwqh5Ty9kg6rZ/hEETcPdWCG48RpIDSSQ8Ihti/XcqoDGhxM/XJr4TgbQG+3 0gjA== 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=vqhZq8f2bViyKVbnN2/6Rq4keJLLw/nlYF+e74jaxA8=; b=vZmMRXs3t7fDcf7NWovSZS9UW7LaiLOMPeDHKttxrK1XT6+qDCcwVf9GEuw8eMwsNN w1HuxFi9kgxtzzHBs0NQC6jkGNNChxMIM78JOYmbgqJjDnRDg2tNx22RAjsSk2f16p8j uJzIC3yzwDLma2XHIjT0RJTvl02JdR9htbaxXjDlg8YgT1Ft4ssb3anfavo0RTNtu8lw YLVCcUtzmV+sZAh93HBojmeEshaScXnbBQbTGx/ihcb30ois32kBqPiA1mHaKz+B/Swh akVgvHsYiRHqm/q1JIpSZQWyS0YMU5qrlxjgXrYbmf43LqDg4ldMCAT+D0zEjeRyn22H wfzQ== 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 g16si3491557qtk.436.2017.11.12.04.17.41; Sun, 12 Nov 2017 04:17:41 -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 3B31860609; Sun, 12 Nov 2017 12:17:41 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 1F1B160A12; Sun, 12 Nov 2017 12:02:39 +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 6CD1F60C0F; Sun, 12 Nov 2017 12:02:14 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 4A2DA60A76 for ; Sun, 12 Nov 2017 12:00:32 +0000 (UTC) Received: from mxback14g.mail.yandex.net (mxback14g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:93]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 3CCE52D86BD0 for ; Sun, 12 Nov 2017 15:00:31 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback14g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id hc0lTRJJur-0VBqx4nN; Sun, 12 Nov 2017 15:00:31 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 3w91frotLT-0UvmCCOD; Sun, 12 Nov 2017 15:00:30 +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: Sun, 12 Nov 2017 15:00:19 +0300 Message-Id: <1510488023-21204-15-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510488023-21204-1-git-send-email-odpbot@yandex.ru> References: <1510488023-21204-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v12 14/18] 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: e8722a0cdda227e01e7d308573aec08112d3c5b0 **/ 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 524ed728f..49bacae01 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -300,6 +300,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; @@ -648,6 +653,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;