Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1942272imm; Thu, 24 May 2018 03:19:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpFFSOP/vjx3vCExWL/cFayNYoahOE/FZszSbdkdQFa9VE/PaNYD5qiSyVCYulYhlONPvOk X-Received: by 2002:a17:902:6bca:: with SMTP id m10-v6mr6740591plt.6.1527157178122; Thu, 24 May 2018 03:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157178; cv=none; d=google.com; s=arc-20160816; b=sh2rpu1AGqFcgjcjvU5FXLd7X84xHYX8Zt9/ZvO37F25U4C9A/VfLzV+6evqrWgvbx HqmQceqKI9sYCk84fIS5lK8P6JV3djF9lL53HED6b834qfyN1f+DA/oBrmctH6lszs80 AqGy6FGxmq5pXy1StXN8SzR5cjwiSBfFxLDxr2bE8VIWcsb01tUuCspx69VXkpP/rUEh wjmvpvMI9fbuwKQd/KOQItVkK7TxN88JEYiKZFy/pmA/30QHEhbeQZ9HXpgnTqxxFYe/ Mtr4VR2sbShK0aaW5Wf3Vql/FCnk0YsAgsSNZZZ/32OwyVxHJZYv0lIfvMH8bGkcQ56M 7T5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=LGFpVT2dXtvWt4R8FXz7mC4nnENvPXT/lS8Lpszo6qo=; b=yhpR3nDDjblrpp83+OdKsZG7tAHpFyliBfCFeVYk4RGs7cYoL8Uy1QIqAA7NTilvER a4dOPYLCewRkzAdNTGbV16o119MlVAT/HHkczkLmJIYRKJ77hL37wWB3mQZhtYxfmIZ1 nJfIxdkfXsPEsCmsJwD1KQlLwC20heCYiUuKMgZ2pSYXRjYFSrX/IscZw+zdRBJB/z8Q rWSB+IYgoO9W/m4BgbF3fbmpjJOOaKV0wbgU2JGPeMZ/u1Lf5dUMAjJS97zD+ofWAmAX DZovOASR22iJybasFbGakW+lSKVnlUQHNdNTTa9s5T4okkA9cXwbB3bdlqyVjHNBqTbB 2qJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q5Oln3H2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9-v6si16645340pgo.340.2018.05.24.03.19.23; Thu, 24 May 2018 03:19:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q5Oln3H2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031309AbeEXKDj (ORCPT + 99 others); Thu, 24 May 2018 06:03:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:52704 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030922AbeEXKDf (ORCPT ); Thu, 24 May 2018 06:03:35 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6676920891; Thu, 24 May 2018 10:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527156214; bh=P79JuxQ5zptGybiJs56g0Rm/wpg04iCKoqGUkpmf/KI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5Oln3H27RWXw/aKNTrrNnXSojAcc4tTd7I59HDOdqQFIx3dy89JIr5spcnOKnU6q ia4XK1LR6308DpWkhjD2RjF6npDQa34nIH9bqnpoCqsRqKoSo2GYP+EaMdhJImSmmi aPEIYtAEa7twTvDaJoEaDmqK9OtsfRds9JvoEdSc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antoine Tenart , Herbert Xu , Sasha Levin Subject: [PATCH 4.16 106/161] crypto: inside-secure - fix the invalidation step during cra_exit Date: Thu, 24 May 2018 11:38:51 +0200 Message-Id: <20180524093031.098530213@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Antoine Tenart [ Upstream commit b7007dbccd92f7b8c00e590020bee542a48c6a2c ] When exiting a transformation, the cra_exit() helper is called in each driver providing one. The Inside Secure SafeXcel driver has one, which is responsible of freeing some areas and of sending one invalidation request to the crypto engine, to invalidate the context that was used during the transformation. We could see in some setups (when lots of transformations were being used with a short lifetime, and hence lots of cra_exit() calls) NULL pointer dereferences and other weird issues. All these issues were coming from accessing the tfm context. The issue is the invalidation request completion is checked using a wait_for_completion_interruptible() call in both the cipher and hash cra_exit() helpers. In some cases this was interrupted while the invalidation request wasn't processed yet. And then cra_exit() returned, and its caller was freeing the tfm instance. Only then the request was being handled by the SafeXcel driver, which lead to the said issues. This patch fixes this by using wait_for_completion() calls in these specific cases. Fixes: 1b44c5a60c13 ("crypto: inside-secure - add SafeXcel EIP197 crypto engine driver") Signed-off-by: Antoine Tenart Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/inside-secure/safexcel_cipher.c | 2 +- drivers/crypto/inside-secure/safexcel_hash.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c @@ -456,7 +456,7 @@ static int safexcel_cipher_exit_inv(stru queue_work(priv->ring[ring].workqueue, &priv->ring[ring].work_data.work); - wait_for_completion_interruptible(&result.completion); + wait_for_completion(&result.completion); if (result.error) { dev_warn(priv->dev, --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -496,7 +496,7 @@ static int safexcel_ahash_exit_inv(struc queue_work(priv->ring[ring].workqueue, &priv->ring[ring].work_data.work); - wait_for_completion_interruptible(&result.completion); + wait_for_completion(&result.completion); if (result.error) { dev_warn(priv->dev, "hash: completion error (%d)\n",