From patchwork Fri Nov 3 12:00:14 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: 117896 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3238166edm; Fri, 3 Nov 2017 05:13:10 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SaJ2MYnlrKSQWlioFH9LpP4C/L9qlFrvgAZgMeS7DgBk6EoEY+/VXHWP0ExUSa2U59ZmHs X-Received: by 10.55.212.80 with SMTP id l77mr9424670qki.82.1509711190449; Fri, 03 Nov 2017 05:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509711190; cv=none; d=google.com; s=arc-20160816; b=cnnpXq9tYFD9tig1OWNSJ92XmLXMxZWYNxry7g7JFwfoKsn0YBahZDa8wcnhGcGUHw JzSY4MogSbdZZpWnbod0z/VIHHxq9ZrOHQ1E5mkZtdzTBxPqIKvYTgqWZ1TQx+zi7yDq WnxqF661uZq5wmRckU6AV1TtAHtOPyweJgpAw4fmaF5plOWhIyGAwy2Qc8iZpeG07WpG JVhqueDcHwETWZ2DMGFfIJJIYAnzCn0SRfqnTxjfgauht727dZO11rKtbEnauRnwAdWL JjYUbG/WTY1Noq0ltnwi1gmCJ8Zm8gPHFEO2oPy0GyKggisuzBoMNB8KjbuzDXNpeynf RmIg== 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=Bbq1ZAt8WYHKFrY99ajVIRv+u1agVfeAyqSgsiCUMhA=; b=sYDPwNRCC3jQ/WI1fbod1pCxldIj8/egP7ZOyEPPGfGWJN0xKT1RAejzEO+FjjlihA o5xL2W2Pn3OewZ6vbADAwJ2uOr+9FosJTbe21zCq8jOH+LuedumtCxw5DFitItmpVeEZ OkJNeMBIOlSgH6DHAO0QB5Y3/v8wQ0TklyVDebSukWy6dOz42DTd5Y8t2ZtyElC/+mSk hBEjaris3/fToyydt/iEzDP4qVmu2FwNz16e3RnQ6J/xyb0sk3776ytxH/Oyy0yrqgs2 v8D9AWAbFLtjJ7kTErVPc0u6Rmo70RMeiJbQklh4BgiyuFWhxv0Ds2ZOYOC/A1DkFi1F 8nYA== 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 u37si891616qtk.309.2017.11.03.05.13.10; Fri, 03 Nov 2017 05:13:10 -0700 (PDT) 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 01A4360636; Fri, 3 Nov 2017 12:13:09 +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 9945461667; Fri, 3 Nov 2017 12:03:12 +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 A02886156E; Fri, 3 Nov 2017 12:02:53 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 7A7DE610AC for ; Fri, 3 Nov 2017 12:00:35 +0000 (UTC) Received: from mxback18j.mail.yandex.net (mxback18j.mail.yandex.net [IPv6:2a02:6b8:0:1619::94]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 945EA5884A98 for ; Fri, 3 Nov 2017 15:00:33 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback18j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id W3YgYb1TBX-0X7SqJCh; Fri, 03 Nov 2017 15:00:33 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 26Ifsfv15U-0XDCupGP; Fri, 03 Nov 2017 15:00:33 +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: Fri, 3 Nov 2017 15:00:14 +0300 Message-Id: <1509710415-8980-15-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509710415-8980-1-git-send-email-odpbot@yandex.ru> References: <1509710415-8980-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v6 14/15] 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: c7cf7a3e9184b27986b3ddb459d86081b1fca033 **/ 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;