From patchwork Sun Nov 12 00:00:13 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: 118632 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp257304qgn; Sat, 11 Nov 2017 16:10:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMb9Yu88zUIMcKxb+CO+9HRwxWR5lY3p5hnFI8u980ysRBObloztovWvBlPIsF7HDZxkMBDc X-Received: by 10.55.183.134 with SMTP id h128mr7684041qkf.258.1510445434512; Sat, 11 Nov 2017 16:10:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510445434; cv=none; d=google.com; s=arc-20160816; b=GjO5ArzyxREllCQPnOMY6rjPsHgEEtMTu1RY6J4V09pHMNm2PQ8vMxvhPa1W5mZUou dKiUPV7YzCYgN2yy6QGDHf3p25h/R66Wc8silv8BY5gU1GiYKK5eu844j5HCF649hDXJ v3eLXJ4V0gTRp6PP/A+b1n/NiHcPZREw5XPSgBblDhSGOzdkXcQRzPk5qku8olbBoyty V70NO7ZGu+S0olsTdZosSh2V5r40ip3S1Hhas2k2ii1buGE+ZqD0T2Aq364CsCheFuKn 2aRIiNX1PVNiZZrMyHFbxopa+vFoSR6SyAD2VobdbIKD8FiZChqV0ZEcuagx33iQ//vc yMdw== 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=xweZz2Db876XQUy9ymk2xhwfaJGP1+3WcaPyvfVMpN8=; b=RIPnoWKE+CMAo1p3u84a1tPF3WFv8kWVxCrgi7YHA+e0Yu/LPbJiMGpdszDMEAvNGl Wo9u0HPV3KVxIexvbGs+oT2lDljBFylUhBfRHcqKclJlSftwt2u58a3waZSOPlhQk0CF 2+69hHpXDj/B/ygPfVTSLL43hN+VL+Q326yTd4bXqCho8qJPVdh32Exqh3ho+bwwOv7R KJeWM5nTNiL7gzwbPRBkRwFQQNzkP+zQOZI5rPS7BI28DcvHUA7fYTwh7i+vv1D1hO1P 0/oMKt1GCrNt3DvV9RuMh+q1ejZ3CO/h8ZZzEMidbVwYmsIW3IQCqxGWNJ4CwcoQfh/k m2IQ== 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 k124si4774054qke.408.2017.11.11.16.10.34; Sat, 11 Nov 2017 16:10:34 -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 17D2C60A31; Sun, 12 Nov 2017 00:10:34 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 63F8E60ACA; Sun, 12 Nov 2017 00:01:27 +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 E343760804; Sun, 12 Nov 2017 00:01:16 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 2569660594 for ; Sun, 12 Nov 2017 00:00:26 +0000 (UTC) Received: from mxback6o.mail.yandex.net (mxback6o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::20]) by forward106o.mail.yandex.net (Yandex) with ESMTP id 884F27832C3 for ; Sun, 12 Nov 2017 03:00:24 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback6o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id cPsDlYv2ak-0OtqdkSp; Sun, 12 Nov 2017 03:00:24 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id VxCtJulSk2-0OWerrrr; Sun, 12 Nov 2017 03:00:24 +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 03:00:13 +0300 Message-Id: <1510444815-25058-15-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510444815-25058-1-git-send-email-odpbot@yandex.ru> References: <1510444815-25058-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v8 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: 9ff682c8d0315f3f1921d5b9fe13d62897c78710 ** Merge commit sha: 38c770f1444aeb3ede5313b7304a1161277ae0b5 **/ 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;