From patchwork Sun Nov 12 00:00:15 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: 118635 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp258521qgn; Sat, 11 Nov 2017 16:12:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMaYg5cWVNoyxIGHOHlq0QxZitnNOJiCgqPpzYyHtj2OVAyq5UE5yg4CqHacl92p8SdWzB4E X-Received: by 10.200.50.39 with SMTP id x36mr8454365qta.255.1510445554733; Sat, 11 Nov 2017 16:12:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510445554; cv=none; d=google.com; s=arc-20160816; b=0t3gRp8ZSCc0j3dYwJ/Lsl1lgKiSWxpyJlZy6zqFM04Ggdgq8C8dWLs9Fr13qvoHI8 m4cSOfz3FkijsQTbgkO7yr9Etp/BCQjLwd6t6uXwr5lYpAgG4veY21eHWMCa74hy1uKR eicmatHdMwm7Grvbtv7eL+cglISB5+p6eqiNRM5YlTwHNWtucYjw0AhkUugFacNnug+5 gCzfSqpLt6FT8q6FGnVMDQya9fOczzIo4Fz39DCtmn3Gr7rHbarcTzL3HrO6e0v8y8tf jllC3u/Q/5n5NKnL0563DPqVeDl4ao4myG4jdVCRY4BqwfFce5aMllSx4Fllt+6g6LZ1 Ju5w== 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=RVwwwmvIKD/qsGlGLufNH7lsVbwq3PHMLGkqxmqLS3I=; b=eoSFRGDsmZQdsXzM2T0tGUSLFlojcKzOoe+yy6lepcw0yw2CMzONP/4YjuNCt7L055 Fp7EXtYeJ7vSQb0pf2a+OIwSCJEGqAM0qq6QL//picUdFtzDDpsz/klREHSbS6RD/aC+ VA84HO3sY0cdFrTghVdmlhHsz8w9VM2nPZYbw3VYmVIz1sTJrkn/hwpbObjFsi8uxPBK 80X8Grc5bD4/AgSh1vw5eYqJzdvyOy7L7VUJzYWjIEwDuMV6VOMgdzoD4TejelWosN2+ PNF6xAJCpD7dsVUUCOupCR005e/kY/LHgVGJICoYMr342yZm6SIVy5mlqBu4DPTGjOFb q84A== 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 4si622645qke.380.2017.11.11.16.12.34; Sat, 11 Nov 2017 16:12: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 6A0E060A52; Sun, 12 Nov 2017 00:12: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=-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 4787060BEE; Sun, 12 Nov 2017 00:01:38 +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 E324060655; Sun, 12 Nov 2017 00:01:18 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id AD31F609D8 for ; Sun, 12 Nov 2017 00:00:26 +0000 (UTC) Received: from mxback8o.mail.yandex.net (mxback8o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::22]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 4A3D15A03748 for ; Sun, 12 Nov 2017 03:00:25 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback8o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Fe1EMzy726-0PXm82VS; Sun, 12 Nov 2017 03:00:25 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id VxCtJulSk2-0OWqT1X2; 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:15 +0300 Message-Id: <1510444815-25058-17-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 16/16] linux-gen: ipsec: don't leak SA on creation error 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 Some paths during odp_ipsec_sa_create() can lead to SA leakage. Fix them by always releasing SA in error case. 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_sad.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index 6a17a9172..ec2bd27e1 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -310,7 +310,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) ipsec_sa->icv_len = 16; break; default: - return ODP_IPSEC_SA_INVALID; + goto error; } switch (crypto_param.cipher_alg) { @@ -340,7 +340,7 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param) crypto_param.iv.length = 12; break; default: - return ODP_IPSEC_SA_INVALID; + goto error; } if (1 == ipsec_sa->use_counter_iv &&