From patchwork Thu May 18 13:29:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 100100 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp721490qge; Thu, 18 May 2017 06:30:06 -0700 (PDT) X-Received: by 10.98.61.207 with SMTP id x76mr4496999pfj.170.1495114205824; Thu, 18 May 2017 06:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495114205; cv=none; d=google.com; s=arc-20160816; b=dRqnbm2vgrYe9P0tyhcHdJteJBsnFl9YwqoTYYWDMdF+dX4z8jJUkgIaeRYcWp0Uw6 EAUowGCQRhQcLdcr4pUNPJMXxsB9Lj+3nqr++gTIOz28izRjbXjqia0w1u5wNKx+EhPY cftHrcY5IGd9PctIU7Jknp0aH4geD9lJv4higtmSaREb39fsUuWlO1SA5VYfF5kfzk5S xnUwv4ZgXYdABrhR0BOgINCBQJ16ZxVAMcybs2ot6++r7km62vDo4ycSosoapQ+Nd+yz /kw873GkqdInezKNUA7DCxEZOk+7m/vVbYQx0v5ICRHIkW6LzZ/W2iAbMDBTGOGdK1U5 QRnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=5OBDhj7pC+gLrYrwe+c1TVXAQFma5geo+aMKtWMiSQs=; b=iA+WsRi+G9eUuRxAjV6le4CbKRR2uIOdGrN47DbchPXIIHI+IHmaB7KDBiXKua8yiB zGmJvEIXu9Kg4Ie3kA1RVXrh+D7pfKyXMcQAlYkJ4vQ1CmGA1JHQFMwfZDA31weRd/LO g5Kf+yvDucpPBDl1flotHG7ASxkR1y+/7UkhLEbp60LAGM15d6dtwj6PNGN+KMn+0hCO vv0ahlUNnx+lKbIgf4Nvqo3gA4wA3VNTy1Z2SDNq3n6+VpDTA5fGCROoVHKd3QwPB/wR VdZXhXPKWdXA1w0yt2NtMxJAumIDiEMfnHgOT/54Txxi7kixrQ1wvba9NE7543C5UFCP VD+g== ARC-Authentication-Results: i=1; mx.google.com; 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 c19si5231671pfe.59.2017.05.18.06.30.05; Thu, 18 May 2017 06:30:05 -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; 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 S964794AbdERN3z (ORCPT + 25 others); Thu, 18 May 2017 09:29:55 -0400 Received: from foss.arm.com ([217.140.101.70]:60136 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934080AbdERN3o (ORCPT ); Thu, 18 May 2017 09:29:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E16871650; Thu, 18 May 2017 06:29:43 -0700 (PDT) Received: from gby.emea.arm.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE7723F3E1; Thu, 18 May 2017 06:29:41 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells Cc: Ofir Drang , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, keyrings@vger.kernel.org Subject: [PATCH v2 3/4] crypto: gcm wait for crypto op not signal safe Date: Thu, 18 May 2017 16:29:25 +0300 Message-Id: <1495114167-3073-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1495114167-3073-1-git-send-email-gilad@benyossef.com> References: <1495114167-3073-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org crypto_gcm_setkey() was using wait_for_completion_interruptible() to wait for completion of async crypto op but if a signal occurs it may return before DMA ops of HW crypto provider finish, thus corrupting the data buffer that is kfree'ed in this case. Resolve this by using wait_for_completion() instead. Reported-by: Eric Biggers Signed-off-by: Gilad Ben-Yossef CC: stable@vger.kernel.org --- crypto/gcm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.1.4 diff --git a/crypto/gcm.c b/crypto/gcm.c index b7ad808..3841b5e 100644 --- a/crypto/gcm.c +++ b/crypto/gcm.c @@ -152,10 +152,8 @@ static int crypto_gcm_setkey(struct crypto_aead *aead, const u8 *key, err = crypto_skcipher_encrypt(&data->req); if (err == -EINPROGRESS || err == -EBUSY) { - err = wait_for_completion_interruptible( - &data->result.completion); - if (!err) - err = data->result.err; + wait_for_completion(&data->result.completion); + err = data->result.err; } if (err)