From patchwork Mon Jan 29 15:00:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 126167 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp2509990ljd; Mon, 29 Jan 2018 07:02:43 -0800 (PST) X-Google-Smtp-Source: AH8x226I59Y+Cuikpe+tQNLpP/9w1HaUqkhSPLE/FPbFWbkjsKMXITEnjn0H54CpvNGx0tzbuRuu X-Received: by 10.55.76.133 with SMTP id z127mr35820235qka.318.1517238163678; Mon, 29 Jan 2018 07:02:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517238163; cv=none; d=google.com; s=arc-20160816; b=h15Fjl2b8txviexAlVJt4hCzyMZLVyUwRq9VXCsR4K7FndxSZZBA4I5KZWhYl26OlV ycgi1h5mBXLF5i7AxyI/l78RarbEeDjPXhZ0t0TN8RXD07TsFMm+ZBNzgF2P42hWWHtw bVexZ6ctEdsxrYUETLdw+5rMHy1yrmfECqeB2L8cAGYNjrWAgwST+PHK+Pv0lXbwQeK2 n/Fy3/oVycd3DuNe9cFUP6Z9lybjfGYsfoXDXL892ey3Rf81IgGvNyINlLVd7zE9hIS4 kMspBw/yzG9cCVZPNwzhscvq9lWEGIK1/z8BHoL7P1HMd9KHLIQOyHKyP6QNJeoBC5fo x+vQ== 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=wMtU9fI5fi2iMKUapTIHhuOa5AVxi9DaAN0O37vjUKU=; b=L5q9vtb/GWjuBxZMEvg6f6nThzgEtfJutvFKvVXSH73cGwLi/Xk93RMAXPF19XDzVq grbzRyA9Zyk3gJccJ5bx/Ge1GUqsRdNiPT2jhfB/6v2tzWt0yT7u5AN1aiyQaFdrU3ow tqe5OW4A9IxHsWdhn2v4eiAOz4U+eFaCvY1+gBBNK+HMWwm/TtL50VaHtI9c7MLiR8Zj lKYUot39ciPFIk24kFEEf0ArFKow1mhxTkl46MmKLU6r5PpO9nXqe2lkYMAho7rswUZ+ D/5vR/awejBxfgV9DrHLWWzbKNKuMk4r2FAKJ10wiW4aOZa6h+2MnPNFqqpY4L9FaNIZ gMUw== 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 i58si5156354qtc.438.2018.01.29.07.02.43; Mon, 29 Jan 2018 07:02:43 -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 4005A61758; Mon, 29 Jan 2018 15:02:43 +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_H2 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 602ED6170D; Mon, 29 Jan 2018 15:00:44 +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 8D3AA60813; Mon, 29 Jan 2018 15:00:26 +0000 (UTC) Received: from forward102p.mail.yandex.net (forward102p.mail.yandex.net [77.88.28.102]) by lists.linaro.org (Postfix) with ESMTPS id 938A260852 for ; Mon, 29 Jan 2018 15:00:20 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward102p.mail.yandex.net (Yandex) with ESMTP id 1EB534301C85 for ; Mon, 29 Jan 2018 18:00:19 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 0SsajO8Xv2-0J00hf51; Mon, 29 Jan 2018 18:00:19 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZIlIkHp1bF-0IUq4gGJ; Mon, 29 Jan 2018 18:00:18 +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, 29 Jan 2018 18:00:12 +0300 Message-Id: <1517238014-22220-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517238014-22220-1-git-send-email-odpbot@yandex.ru> References: <1517238014-22220-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 427 Subject: [lng-odp] [PATCH v2 3/5] linux-gen: ipsec: fix SA leak in lookup case 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 SA lookup can leave SAs locked if multiple SAs matched the LOOKUP_SPI case. Follow that case if we have no 'best' option. Fixes: https://bugs.linaro.org/show_bug.cgi?id=3595 Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 427 (lumag:ipsec-fix-sad) ** https://github.com/Linaro/odp/pull/427 ** Patch: https://github.com/Linaro/odp/pull/427.patch ** Base sha: 27480d82bd93a881ae683a3c314c11042a68ce29 ** Merge commit sha: 67c9dbf28c41ea7a53782ba841276b03f154c4ef **/ platform/linux-generic/odp_ipsec_sad.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index 162626de0..ad229e754 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -575,9 +575,10 @@ ipsec_sa_t *_odp_ipsec_sa_lookup(const ipsec_sa_lookup_t *lookup) if (NULL != best) _odp_ipsec_sa_unuse(best); return ipsec_sa; - } else if (ODP_IPSEC_LOOKUP_SPI == ipsec_sa->in.lookup_mode && - lookup->proto == ipsec_sa->proto && - lookup->spi == ipsec_sa->spi) { + } else if (NULL == best && + ODP_IPSEC_LOOKUP_SPI == ipsec_sa->in.lookup_mode && + lookup->proto == ipsec_sa->proto && + lookup->spi == ipsec_sa->spi) { best = ipsec_sa; } else { _odp_ipsec_sa_unuse(ipsec_sa);