From patchwork Thu May 18 11:26:44 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: 100087 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp670317qge; Thu, 18 May 2017 04:28:25 -0700 (PDT) X-Received: by 10.84.212.8 with SMTP id d8mr4375086pli.112.1495106904985; Thu, 18 May 2017 04:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495106904; cv=none; d=google.com; s=arc-20160816; b=OWPkBU7vwApJ7ZkQm1jzD689VUVl2a1EPvSYeDH1MM7Ug8Q45LqEixnpocepfoHR/G lNCUuF/SdKp34R6cALkY2y5txCncYPhLnAsrqqbf3kR2vHlM0gKl98WTCKFWunoEiwIo eu0J7bM+VS8PUsabAX5b8Nu3qVjOUSZfi5PlayII7k03PgrgdYVNcDOZLPVXSzKdppTS 1ukPZes2QVTlEm6z5eZwfZwuJpuDE7+r6u+NC0tREsIR7n10pmcnmpJlzM2hMpNhlSR1 7zqhbSKc87O9iKXzb13/8+VfPIUQ0gBGBduOGLumuzw3TQFikn+0KBFwgpPVppeSLsyI NFVQ== 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=soARZGOks3u4lnzNZjbaDK8svamPfFVWlBm90+1eUHcWpTeqiI9rt/4PvG6CS0jzQF ODCRH+iDppEkrvhBApbZ2VrHq+KpxYA0vmAehD9xZqALedD5MojIqCDIFPO4T60pONte pcGm7eP4mUNdVtnZEIbIir3vrNwgOb8HZaWdKUe3/nlWac4Q6beRbRFNqeLyep1HlVj+ teTm1drqo1uMK2mtILWVO6xlzOCVUyR8HQDdrhuTPzlgKwN5RENeSkTN60rxcoyGfJZv r8IZo8PLs6qYzwh8S/H9jBrN4jJeVHVDmwSLyfDM1XSzPMJ8JDuz1q0dAYEf2XKngGqI o0Lg== 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 8si4935253pfy.378.2017.05.18.04.28.24; Thu, 18 May 2017 04:28:24 -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 S934164AbdERL2B (ORCPT + 25 others); Thu, 18 May 2017 07:28:01 -0400 Received: from foss.arm.com ([217.140.101.70]:58682 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934024AbdERL1A (ORCPT ); Thu, 18 May 2017 07:27:00 -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 1ECC415A1; Thu, 18 May 2017 04:27:00 -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 362113F3E1; Thu, 18 May 2017 04:26:58 -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 14:26:44 +0300 Message-Id: <1495106806-2292-3-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 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; }