From patchwork Thu May 18 13:29:24 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: 100103 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp721728qge; Thu, 18 May 2017 06:30:35 -0700 (PDT) X-Received: by 10.99.24.65 with SMTP id 1mr4657736pgy.49.1495114235126; Thu, 18 May 2017 06:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495114235; cv=none; d=google.com; s=arc-20160816; b=P6tqXq+LE/UGDa7vt3bnByWG3N2ClgxQI6l9G6QweJNFIaPr7sfL6BcNFRZTjFHfos 2L7b7gDc5DdDAFUGDFkVBKCVXZtvJhXK14IbXN2llP/1hFA1mfCn74Ezxd6/rTWxRwdQ e25RRzKevykyNwIQgzuRMHpIQON1S9Iz8aOHl5ZqjCUpBQfkYVfRNukO7gW7i3/9eun+ 9f/F+xnR4IuzYHNq6FVBGRmI8cu0gJP7cd4j7r8fw1VaT10YVdneP2HCReuDil3pYiC8 q5kqmaoS/x9fyTTP4N1KPkA7PyF9BaNDNRPWMaZkxLk/eOXpix8SsSLRYbTDBJHIN700 Nk6Q== 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=rgof3cZWB1QugZGIiLSlk9SbeoWjnmTLeDpGKolYQ7s=; b=MC5UTrRacIcFyhDk0ZOF8FHZv1rJH4y2OUNBO0efXNTXSj8hfUiHcFqVH6d54H2XUR Pf5qdZbxq6h/rfEVqHnIH0cIKUc8aAxvL6mYsU+SJtR9ydoxUyOEx3OIWfb/vdXE9q+L iW9+UNUVyDQpLXVCMqLi+gsvJSCpFUlfwxziglKpa108WyUnIidXyqcezyNATOwhcu7p qTKN31eMbVCab/JTsuWM15T4uJhOSrRVSeiHptrQONpQzBbnoWtt5kbN3C6KyQg0EX0O rNLLKQj56VVw0ddK19VqJhmoJvh2k9d1dxubbdAS8BL+r7uPiowzFD2QgGiB3cR04GFo w6+A== 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 33si5373150plb.270.2017.05.18.06.30.34; Thu, 18 May 2017 06:30:35 -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 S934900AbdERN35 (ORCPT + 25 others); Thu, 18 May 2017 09:29:57 -0400 Received: from foss.arm.com ([217.140.101.70]:60124 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932681AbdERN3q (ORCPT ); Thu, 18 May 2017 09:29:46 -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 E751B15BE; Thu, 18 May 2017 06:29:40 -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 080093F3E1; Thu, 18 May 2017 06:29:38 -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 2/4] crypto: drbg wait for crypto op not signal safe Date: Thu, 18 May 2017 16:29:24 +0300 Message-Id: <1495114167-3073-3-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 drbg_kcapi_sym_ctr() 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 output buffer. Resolve this by using wait_for_completion() instead. Reported-by: Eric Biggers Signed-off-by: Gilad Ben-Yossef CC: stable@vger.kernel.org --- crypto/drbg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.1.4 diff --git a/crypto/drbg.c b/crypto/drbg.c index fa749f4..cdb27ac 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1767,9 +1767,8 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg, break; case -EINPROGRESS: case -EBUSY: - ret = wait_for_completion_interruptible( - &drbg->ctr_completion); - if (!ret && !drbg->ctr_async_err) { + wait_for_completion(&drbg->ctr_completion); + if (!drbg->ctr_async_err) { reinit_completion(&drbg->ctr_completion); break; }