From patchwork Wed Nov 8 18:00:35 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: 118323 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp5619529qgn; Wed, 8 Nov 2017 10:22:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMZPpjP85mBJnrDVwQWYFhqk6DW237XS1oPxgNDNfaCMDP2cpylZWVHKgbS2sY/WNaM3KuFd X-Received: by 10.55.132.133 with SMTP id g127mr2303700qkd.72.1510165340989; Wed, 08 Nov 2017 10:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510165340; cv=none; d=google.com; s=arc-20160816; b=AkYWKaCQwU6lf0f+GK4h8TP+MkiQrVloLegHD3pJkiAfJLYwEGtv476BInlsQ6hC4A cC3fTY4+A38h4WqIhMKbjixUwORqUQuR77i2il4GvX4yVaRmBWkMBuWroNUEmjFdvjjW 0AgNwcmArL9e1UgEu80GIyzKiyM4uF7/a80bleQk7iWOzgizoS31Uz1d8iEGclAXQcBI F+UQ0WTU3ud1f9YGHNCOZticvvW/me0mnc6jm1ZQ3eABQyp6VMJzsVKX4KNZakS9GSe0 VhtpJYNS9amSy2lhHzlhsXHYbNWUR3TgvQf0vw+yJIPrcmevPKG24zc7X+rf21LrSWvP XmPg== 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=dP5bKt/W+pqrFWPus/3NpK0d1x253KmMENbXczXUMuQ=; b=VWGk6O6Oq2eEw9T+RNskMzavfVV6uInO49NztBctArKueOaAFy/pgNF4uWnC+QMieg FnCQFT7NZQRyBkUdLc+0+fjyc5Cs+hDaYOPwDx/gJga5iUJBFCWgbBc6pcHGiZ5b9gZ+ dKZyDPkG+K561W/LYrVZ1bId1Xc2H2HE1aC7evlkXwvGjaGdGALe1zEY9XFD+bCJkB/O OEdFaWYoIOiNecY03SeLR5r5JJSdw92u676Uml0cey6kkglmEcPnnBEAwsP0Xg2V/cTW 8vUnhDRzHaohQJFTk6WC9wKVbIfXgHoqpKkKI5p0kBRpwlnQtC4g9AwzwmeTfEIKHJUU AkBQ== 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 v4si2862713qkv.171.2017.11.08.10.22.20; Wed, 08 Nov 2017 10:22:20 -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 ABD7260B4E; Wed, 8 Nov 2017 18:22:20 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 C687F61051; Wed, 8 Nov 2017 18:03:52 +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 876356104A; Wed, 8 Nov 2017 18:03:34 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id DE9EF60C3A for ; Wed, 8 Nov 2017 18:00:45 +0000 (UTC) Received: from mxback3o.mail.yandex.net (mxback3o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1d]) by forward103j.mail.yandex.net (Yandex) with ESMTP id CF97034C42CD for ; Wed, 8 Nov 2017 21:00:44 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback3o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id vqBO3LIMJS-0ipmlxKQ; Wed, 08 Nov 2017 21:00:44 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id TTdbkiNdyn-0i1iMeBp; Wed, 08 Nov 2017 21:00:44 +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: Wed, 8 Nov 2017 21:00:35 +0300 Message-Id: <1510164037-14458-15-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510164037-14458-1-git-send-email-odpbot@yandex.ru> References: <1510164037-14458-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v7 14/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: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: b87a669d1d701c336b19a9dd4f07b920a87132ed **/ 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 8101b00c6..e6fb276a6 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;