From patchwork Sun Nov 12 12:00:21 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: 118660 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp690175qgn; Sun, 12 Nov 2017 04:19:34 -0800 (PST) X-Google-Smtp-Source: AGs4zMbXzIUHu/4y+Q6DqaNWqtEQCiyeK2nD7k1e0/++4+1GnoYdjq7cYySWwWR32x/ei+bCf4tV X-Received: by 10.200.43.146 with SMTP id m18mr8877208qtm.99.1510489174662; Sun, 12 Nov 2017 04:19:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510489174; cv=none; d=google.com; s=arc-20160816; b=xF5EuGZ+3C7bRCHP/gJtQSaJFMhTH3g1fp+HFPsprousdrIIrsJxsQNRcIxhJEexE4 0OZZiu6mc59dvf1ZpMsrpD9chOJH2MRXdJ4iinp/uQlWDI/O0PB8Ph3RzNO/vhP46hNL gbH+Z4otaGKgZ3SYzBcUlfX8TrwzFoDhRZK5fN9DaQjnj3Zcj3/yGyT6riabJL9oiEeS kAykyXaDrTM25OeXIUuYDBWaG89MrlDT1ih/m+UiJx9x4JeXNIn3mbWvUqMTe7dOyXN6 G7Aq8AuNDdHFfqFra36OUH4vkys3OxMWISPC5YG+Zq85BHhSq0eOUFy4+jckkeyJ1EIJ s8DA== 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=8nv605DPDIIZyo7hPw/ahQD0XpMFZFOnP1nyaDc0xyY=; b=bTeb3sTLMFDyvm9q6j+rexkzG0eemTdqLRiobD7cFJ7q+gXtH2TsRGd311y3E5O59C 3T6bzW6/ndvT6/WgwewEl02GmGriE9cY7rv2LC4V3gK826nte70H5EXtmcH7PRN1Tue3 0AXRPqO7QD0KKXqVzWFJnbUQL79CyEJnyMSKzTaqcQ5KgnFmLfDOVxZQJh+N0wp19XDD EgS/UruJXxL8i9Gb3kL6A1Db4ij5MUVovz7n/LRDr2t7vnluLG1Rqvlor2/C/c0QiwLJ KqzdNt4EGBS1+XFKN+yJakEbaI9wB+BFtat4HUAOwbDbuDO1hCuFhzXsWIs2s/I1uOK2 lgLA== 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 t126si7604543qkc.467.2017.11.12.04.19.34; Sun, 12 Nov 2017 04:19: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 5460D60BD7; Sun, 12 Nov 2017 12:19: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,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 EE11860C4E; Sun, 12 Nov 2017 12:02:47 +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 56E8460C10; Sun, 12 Nov 2017 12:02:16 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 56D5A60AC0 for ; Sun, 12 Nov 2017 12:00:33 +0000 (UTC) Received: from mxback18j.mail.yandex.net (mxback18j.mail.yandex.net [IPv6:2a02:6b8:0:1619::94]) by forward102j.mail.yandex.net (Yandex) with ESMTP id ED26F56088CB for ; Sun, 12 Nov 2017 15:00:31 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback18j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id PiRlFrqLu7-0VZu5KvR; Sun, 12 Nov 2017 15:00:31 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 3w91frotLT-0Vv0O8YH; Sun, 12 Nov 2017 15:00:31 +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 15:00:21 +0300 Message-Id: <1510488023-21204-17-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510488023-21204-1-git-send-email-odpbot@yandex.ru> References: <1510488023-21204-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v12 16/18] 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: a908a4dead95321e84d6a8a23de060051dcd8969 ** Merge commit sha: e8722a0cdda227e01e7d308573aec08112d3c5b0 **/ 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 0bcc20b86..4e867c797 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) { @@ -343,7 +343,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 &&