From patchwork Sun Nov 12 23:00:11 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: 118681 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1157122qgn; Sun, 12 Nov 2017 15:10:08 -0800 (PST) X-Google-Smtp-Source: AGs4zMYrEqt6hTmOKhWTXG13PfkRYjYIb2tlLEAIYJ4p4NviRGDx0OfWpEhnV2JyHS/6bs0HJ5uJ X-Received: by 10.55.100.141 with SMTP id y135mr10625290qkb.242.1510528208171; Sun, 12 Nov 2017 15:10:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510528208; cv=none; d=google.com; s=arc-20160816; b=gA2jG2/ZDr9nJrvCwWEwhkNvLo8fDfdxvjfT0Mz9GuBJF4VGDGpVn4u1VNliYhZ6Ek dRvvyuWAKYbrzbL8lDVI4QDASh2a7SPdLH00cpguZoJv8LGF/fmkZiHhkFD7N5Es7oIa hWzg3npq01O8xMdeXUd+aaqjZoozY1L4WBlQ8bRp4ipdLkde7VdbGR+FHGfY+DqHdvwM 6GDVBuG5fUw0qxmB50olyjjQClyrzXdIB5GmbYtnnfS7BA86ZManxyXNu9jPOquFqffS 9cZqz7mqd7ZrF3OeDMU7bXdl2UchApIm3SHeMrbUbvHN5Iau+lanhoQJVh1cGjeCY+HK F3kQ== 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=fNlj4xhVUABRYTSJAgvuAk4YgCjMcnXAB13Ydxn64hc=; b=rMPK+H3PfTiTJGd0dOVuZ0tbpZHrRc1uvX62TgCZkCv8Fn1dTaDJsSgmR5PByS2cyY Ny2xgPux/EX7nfz0BDL4S7D6LG4xY8nBZDNDPpwA/MRqsv2Fkvp7XRBwnJeLuzsFzM8r Yay+0SU9/Job8VukCL4CPzE+2fwi3hF+PwCKI+TKwZlzHelUOW7zw7ncc2yPIq7l2yrc 5nEAwhCtylLw0dSHYwuQxSnWzd5R78hlfAhaD0PA8B0l4ad4i7xOV6KlQtmte3OZpNc3 zoVmdrp1Mu2NLtiYR5nDNwRayg/v08d3/2Dm9jQ0VncY2rh5Pce3auComZW7t+fPDjhd 1WFw== 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 d19si164168qkg.484.2017.11.12.15.10.07; Sun, 12 Nov 2017 15:10:08 -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 D4E3F60B54; Sun, 12 Nov 2017 23:10:07 +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 9A29C60C0F; Sun, 12 Nov 2017 23:01:37 +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 CF2C760BE0; Sun, 12 Nov 2017 23:01:10 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 81DE660A1C for ; Sun, 12 Nov 2017 23:00:25 +0000 (UTC) Received: from mxback20j.mail.yandex.net (mxback20j.mail.yandex.net [IPv6:2a02:6b8:0:1619::114]) by forward102p.mail.yandex.net (Yandex) with ESMTP id D46FF430E64B for ; Mon, 13 Nov 2017 02:00:23 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback20j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id pHgZ5Zj2aa-0NEWtTbW; Mon, 13 Nov 2017 02:00:23 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 3gEL078gGO-0NjuLgQs; Mon, 13 Nov 2017 02:00:23 +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 02:00:11 +0300 Message-Id: <1510527615-30536-15-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510527615-30536-1-git-send-email-odpbot@yandex.ru> References: <1510527615-30536-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v13 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: 7261a0ce35cc31342937cb57dcc287aea0c59ede **/ 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;