Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753035AbdFLP2o (ORCPT ); Mon, 12 Jun 2017 11:28:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39590 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752987AbdFLP2j (ORCPT ); Mon, 12 Jun 2017 11:28:39 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 4.11 041/150] crypto: drbg - wait for crypto op not signal safe Date: Mon, 12 Jun 2017 17:24:08 +0200 Message-Id: <20170612152521.229720857@linuxfoundation.org> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20170612152519.404936272@linuxfoundation.org> References: <20170612152519.404936272@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1200 Lines: 39 4.11-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gilad Ben-Yossef commit a5dfefb1c3f3db81662556393fd9283511e08430 upstream. 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 Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/drbg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/crypto/drbg.c +++ b/crypto/drbg.c @@ -1768,9 +1768,8 @@ static int drbg_kcapi_sym_ctr(struct drb 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; }