From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 556D0C433DF for ; Tue, 23 Jun 2020 20:56:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2603D20724 for ; Tue, 23 Jun 2020 20:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945795; bh=SxyvSRQdP/oBsDW8DbXBAL6YdZBkaEfAOCB+Zzit6/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nsJacOQ2xQthFyJPr5HTlH/xKqWjQ+nuz66HQ2tGZpG4/9lrLchPKGmX7ONhhBKW3 +xZIAixdvohyCfJ/cWeDRg3J6BoRXJXaBboWV1aZyP3mFdfQ/tF5DivOBs26B5q8/y 5fr7BzppntD7gL9gD5gDq+UHEshZmOQPHwTsdQAA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391104AbgFWU4d (ORCPT ); Tue, 23 Jun 2020 16:56:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:40392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403914AbgFWUnb (ORCPT ); Tue, 23 Jun 2020 16:43:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C53E21BE5; Tue, 23 Jun 2020 20:43:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945011; bh=SxyvSRQdP/oBsDW8DbXBAL6YdZBkaEfAOCB+Zzit6/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ilmOqijePMdGh2TilnfALM0kvZ16SXviIzX+yh4YA9vwVoH1wU54XSLHvCdAQSLu3 9c2gvcU6UsgaqCDkqa9BMXTtKnT+KY00PIlxIGdvpdX5XzdYRYzIEP3KDJ2bWul32z rXxj4zhDXGoCx+km17DZB6T0Jr8tEiy85QUvesEA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Gerow , "Martin K. Petersen" , Eric Biggers , =?UTF-8?q?Kai=20L=C3=BCke?= , Herbert Xu Subject: [PATCH 4.19 199/206] crypto: algboss - dont wait during notifier callback Date: Tue, 23 Jun 2020 21:58:47 +0200 Message-Id: <20200623195326.828238315@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195316.864547658@linuxfoundation.org> References: <20200623195316.864547658@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Biggers commit 77251e41f89a813b4090f5199442f217bbf11297 upstream. When a crypto template needs to be instantiated, CRYPTO_MSG_ALG_REQUEST is sent to crypto_chain. cryptomgr_schedule_probe() handles this by starting a thread to instantiate the template, then waiting for this thread to complete via crypto_larval::completion. This can deadlock because instantiating the template may require loading modules, and this (apparently depending on userspace) may need to wait for the crc-t10dif module (lib/crc-t10dif.c) to be loaded. But crc-t10dif's module_init function uses crypto_register_notifier() and therefore takes crypto_chain.rwsem for write. That can't proceed until the notifier callback has finished, as it holds this semaphore for read. Fix this by removing the wait on crypto_larval::completion from within cryptomgr_schedule_probe(). It's actually unnecessary because crypto_alg_mod_lookup() calls crypto_larval_wait() itself after sending CRYPTO_MSG_ALG_REQUEST. This only actually became a problem in v4.20 due to commit b76377543b73 ("crc-t10dif: Pick better transform if one becomes available"), but the unnecessary wait was much older. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=207159 Reported-by: Mike Gerow Fixes: 398710379f51 ("crypto: algapi - Move larval completion into algboss") Cc: # v3.6+ Cc: Martin K. Petersen Signed-off-by: Eric Biggers Reported-by: Kai Lüke Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- crypto/algboss.c | 2 -- 1 file changed, 2 deletions(-) --- a/crypto/algboss.c +++ b/crypto/algboss.c @@ -193,8 +193,6 @@ static int cryptomgr_schedule_probe(stru if (IS_ERR(thread)) goto err_put_larval; - wait_for_completion_interruptible(&larval->completion); - return NOTIFY_STOP; err_put_larval: