From patchwork Mon Nov 13 14:00:01 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: 118747 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1830367qgn; Mon, 13 Nov 2017 06:03:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMY+n9/I+d6o61CamZvBhl5u7h3uzucEZ9A2gOL4sUi35wpJSoyBOjyMtHAObkCwyQJGDFZD X-Received: by 10.55.215.70 with SMTP id m67mr13336526qki.225.1510581785090; Mon, 13 Nov 2017 06:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510581785; cv=none; d=google.com; s=arc-20160816; b=TnigVecZ1nnaEhmO6o+xSy4vP0q/q69VvUuvalAlmasULNDh2YYqDi5Z/jZeU4nRzB OiaPGcjC3jBMQEmhsUtQPpfVtNSnmbQd04U0lyYClIkpDAI6PdTKcNY1KdcJViMpvPWa XE5dl7PzeFC372nXkYdjSTkrNFRpVv4HoDlcO8W7I/ItTrMjYzpGrcUxZGLB5uykbcq9 JyPcbmG+RwVH+yQHpEumKDsJReJn5lZIWnzhWtD7SLWL57e/X1fvC0YUb6Lg1YE8node 15t/DtejpToiRjJOBzMqmksz4omZfujDg2o90I/IUz1BSKhvQcv0vJ7EK4H1Whv/8xJM cseQ== 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=Q3jSDfN6q/6dY4DlbPclvpsRgYYS1kNkphykOfeXfBA=; b=IFxvSF0qwBsdduZKjucT1yymKpwIdaKBDNiLCNpR/8WOvtbHPUBTW15jTJqSukKRP1 3sK94UfjNccsFH1QyNBc/Qs1+YKuN0GdjC+bwlOuLCOmswC+u9HqscJVn5lGyze+BUYZ ouDODUqiHV/Nircm041PTz8wcZuOPV0Bqua+UsYLykbspa1a+WYfnSCS7EyE0AyMLP2k b+9kITyXaF3J9yozkTkNKQYBj17ygKP5cS71NPGTqHk2RXc27juALiM1Wk8BozPJNtgX AeOzrlYV6hvST70tsOJBCoyYcNmyF2xa9kAFyE/jhMPMqE/nMV2t99KxYE8dTGcu6pR/ KY0w== 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 i18si170941qti.80.2017.11.13.06.03.04; Mon, 13 Nov 2017 06:03:05 -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 2AE7C61204; Mon, 13 Nov 2017 14:03:04 +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 19FE061015; Mon, 13 Nov 2017 14:00:46 +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 EF42860DC1; Mon, 13 Nov 2017 14:00:22 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id EAAFD60991 for ; Mon, 13 Nov 2017 14:00:15 +0000 (UTC) Received: from mxback20j.mail.yandex.net (mxback20j.mail.yandex.net [IPv6:2a02:6b8:0:1619::114]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 278DC2181009 for ; Mon, 13 Nov 2017 17:00:14 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback20j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id nBbdWO7pDE-0DB8Wacb; Mon, 13 Nov 2017 17:00:14 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id eBFPNklri7-0D80WDtK; Mon, 13 Nov 2017 17:00:13 +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 17:00:01 +0300 Message-Id: <1510581611-13870-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510581611-13870-1-git-send-email-odpbot@yandex.ru> References: <1510581611-13870-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 288 Subject: [lng-odp] [PATCH API-NEXT v6 2/12] 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 288 (lumag:gmac) ** https://github.com/Linaro/odp/pull/288 ** Patch: https://github.com/Linaro/odp/pull/288.patch ** Base sha: a908a4dead95321e84d6a8a23de060051dcd8969 ** Merge commit sha: 60f2c36c67f6b216666f85876af63f7091b1bff0 **/ 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 dc338bfcd..b2d12eada 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -292,7 +292,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) { @@ -325,7 +325,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 &&