From patchwork Sun Nov 12 23:00:13 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: 118682 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1157447qgn; Sun, 12 Nov 2017 15:10:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMZq2GNVTxtXVBWIkkku+oD0p/OuQGIoXV9Hz/CrDq+9CM+A7DB/VRnyQ3aY5H0t8MhJ05Ft X-Received: by 10.55.5.139 with SMTP id 133mr10665015qkf.220.1510528237767; Sun, 12 Nov 2017 15:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510528237; cv=none; d=google.com; s=arc-20160816; b=sIOe5jDUwSTDZlA/w8w0JdluD997HRn+MZTU+ujcTBD10Zjo/6sRqdz49eaMjPwNr8 ccD1p2l1Mri2iKAqqleuxlhZfgE3Bx9ebBtDeHHw285lpafpQ6Ohqg6DXacz0qS5M2tQ GePU6GjOUelkMOF3w73g6EzKyoOj9XUH3oI0I7dmW86ZhmxpImzPhy9+A2hZrLP/ez+v WApbmzHLpsNrgafn79Gg9WfIil7UPTCSL4b9enpQR2IOpl3r7UI8poJY/dctJ7bJSiBj gzkvPxBJfIHNSUWG+uxNocGEyN6yP829cmbJpAUafMOg4dOdlNylfUFT0VTMHA+GzAdt qArQ== 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=dIBUIPeqXkMyovnPM4PdpArPO8OdlK0ubOKyvc5pSoo=; b=SyFNYSZTLp5JTyoHcclI6ElWC1UrqP+VL+s+5oFe9TP2B+ffY9Ebkb1/sEICEBLiwf 9mogcTh+S3VdhM4sSvs+H49AT2q+8yRFoPJUPJ9X2PKF63kE6Zymr3neQ5Ln2G3smKtp iM/iBF1Ag92eTgh1CZR9X56NRduE55WeGcZZ7lMSm6dK4/GTlW9ASQWae/tEiGjQHxvY qpqfp7DUyLLwJmXSPLA5i4MR33UqFN1G7X7iss+rKaiVntzEBpx4bvJEgjkbiZYFn7Zs vWWaNOwgd6hz/lBA9R/M6bM4eJ8ladj8lq2GqHgVCAdDXTFrR8FEdIA7og2jOKieT4Ya CrPw== 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 c56si4597746qta.95.2017.11.12.15.10.37; Sun, 12 Nov 2017 15:10:37 -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 5DBB760A81; Sun, 12 Nov 2017 23:10:37 +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 DF16660C21; Sun, 12 Nov 2017 23:01:41 +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 036E760A1C; Sun, 12 Nov 2017 23:01:11 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id E9DAE60625 for ; Sun, 12 Nov 2017 23:00:25 +0000 (UTC) Received: from mxback7o.mail.yandex.net (mxback7o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::21]) by forward100o.mail.yandex.net (Yandex) with ESMTP id D2CFA2A2E06E for ; Mon, 13 Nov 2017 02:00:24 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback7o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id nAR2Vdriyh-0ONiSBtq; Mon, 13 Nov 2017 02:00:24 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 3gEL078gGO-0OjOI0U2; Mon, 13 Nov 2017 02: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: Mon, 13 Nov 2017 02:00:13 +0300 Message-Id: <1510527615-30536-17-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 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: 7261a0ce35cc31342937cb57dcc287aea0c59ede **/ 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 ac9132527..ca42838cd 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 &&