From patchwork Thu May 11 11:53:43 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: 99626 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp689774qge; Thu, 11 May 2017 04:55:05 -0700 (PDT) X-Received: by 10.98.141.16 with SMTP id z16mr11623317pfd.91.1494503705539; Thu, 11 May 2017 04:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494503705; cv=none; d=google.com; s=arc-20160816; b=GT5byWvcEds9URRsRzc3Bk4H8YaAVWN+Do58RxaQB89pcADHorKaKKEOIxQXuuzHKi DWPseE+fSPey+hyypvRfwLc+D7ZUqbOn1gEvCay13ee4+0cAC1xwywW/PguHTrSVgQxK spa0I8bOGsYGtnFzLLYOuHOQKSACyDJtk/o1Uwlfb0zXOd3sgoN6TZrXmMLFREysubOZ RsKBR6y0GSZcaZSS+o2StCfNtA7pLf9jke2I9OpykQTns6l8erbjiINjEq97Ogm/ppjL KZrOlWAygYuFEkuo1wz2OGfZg7lm27OUxO91ldEsgY644iJ1rzxNxczrhQczSF5MUKVD 1HaA== 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=aVKSmx3E7IAYachjEBB8lWApO1O1Re6MvtccUZ5m2+g=; b=Sjwf6jxurLuR1/4JCcPdfvPjrZMhtuPC5Xnc9aD+X+NNxIeeU2+rbwMP5107ZbME0G M47ja82LgZYFD2FdvLUMIkcsWqHCTMEmKanJsUNTcq6qL45VpQZgFo19GIzJGIJ9rZGq E/F04kg6ShgeC3YPVv7gMoJFbsHiJck42PexMcVfIiScivIQWt/4w1c6bYt63CVtrVsr 0rVu/dp9EjUUKoNdpPqxgCTf0CUop2Wah/lQKWoBkdAZlCZ+GfYhlNuoM6rgANCTxRhF +2diaospb6/JYubQ6l29y2KwGQ34QQOHkp8D8TWd6qqTntd75Sdg6FkbZpWV6WMXMwDg 9cSg== 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 i14si1672354plk.84.2017.05.11.04.55.05; Thu, 11 May 2017 04:55: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 S1755459AbdEKLyr (ORCPT + 25 others); Thu, 11 May 2017 07:54:47 -0400 Received: from foss.arm.com ([217.140.101.70]:46600 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932586AbdEKLyE (ORCPT ); Thu, 11 May 2017 07:54:04 -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 495E52B; Thu, 11 May 2017 04:54:04 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.150]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7463F3F4FF; Thu, 11 May 2017 04:54:01 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" , Jonathan Corbet , David Howells Cc: Ofir Drang , Gilad Ben-Yossef , Eric Biggers , 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 2/4] crypto: drbg wait for crypto op not signal safe Date: Thu, 11 May 2017 14:53:43 +0300 Message-Id: <1494503626-15877-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1494503626-15877-1-git-send-email-gilad@benyossef.com> References: <1494503626-15877-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 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.1.4 diff --git a/crypto/drbg.c b/crypto/drbg.c index fa749f4..fa9054d 100644 --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1767,8 +1767,7 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg, break; case -EINPROGRESS: case -EBUSY: - ret = wait_for_completion_interruptible( - &drbg->ctr_completion); + ret = wait_for_completion(&drbg->ctr_completion); if (!ret && !drbg->ctr_async_err) { reinit_completion(&drbg->ctr_completion); break;