From patchwork Thu May 18 11:26:45 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: 100084 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp669948qge; Thu, 18 May 2017 04:27:22 -0700 (PDT) X-Received: by 10.84.224.1 with SMTP id r1mr4248724plj.78.1495106842810; Thu, 18 May 2017 04:27:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495106842; cv=none; d=google.com; s=arc-20160816; b=ighYOvrQGzup6tI15QC4RzmgWVheWg2IZzXh0cvgTN5hOnFZ5mEXPAMc7V7gSnRCFN 6IXw/FSRNrNT2ONUuIf8+GhqpWKNql/v+fqwgvatLOX2wXTtNqt3tcvOUzy/+bo/Cuym vIDDtD26IadcMlA/jFoSEep7LNwvKvOFTkN1Kf7FfNJiAtbJmkrouD8+h+CRBxQhzIKp RGvOgoNRXk1UIA2bQlRFeP8vbQdntpDeQmWAylFO1lPlSyLfNsvQDUEkasCG3F/LTcyo YXlWSL3vFXboXCPWfl4iFnTBJy79krr+MCMUjsXld+5HabzW7BkgRlyCm766svbpD4kV zcgA== 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=GQrkvLsBem/oggGVagrxg98NqwScC8PCEW29Mn97tFU//QojoAdmnPZ5TwrTH2ZHXF qm5oaWuMSKV1JmUVbGNVZ/WtzgXQd0D1LySYdBinEgUfDVwqpue2J8xYZSdWU00Nk03K PSUrZ9VjGtEd8jEKRQix5RJ6S4fPQckyOwrdnnAl8mB5Hvjff0AfAaG5xfyX+O9RecPR zFo87Y0UYzS/477KmYUmy2nq5rMS0/gCI6TQknpJutyMlU0BiK0A7MxTyp90pVWMQGvC G2ixSywwJqBdv7tcRV1FpjY/uVBL4CWzPaM80YlH6WnZwcAHsr5L478qSg5BC+seVTi3 AN9Q== 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 90si4980879pfh.200.2017.05.18.04.27.22; Thu, 18 May 2017 04:27:22 -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 S934025AbdERL1L (ORCPT + 25 others); Thu, 18 May 2017 07:27:11 -0400 Received: from foss.arm.com ([217.140.101.70]:58688 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933853AbdERL1D (ORCPT ); Thu, 18 May 2017 07:27:03 -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 1359715A2; Thu, 18 May 2017 04:27:03 -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 227DB3F3E1; Thu, 18 May 2017 04:27:00 -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 14:26:45 +0300 Message-Id: <1495106806-2292-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1495106806-2292-1-git-send-email-gilad@benyossef.com> References: <1495106806-2292-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)