]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jun 2020 12:24:01 +0000 (14:24 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jun 2020 12:24:01 +0000 (14:24 +0200)
added patches:
crypto-algboss-don-t-wait-during-notifier-callback.patch

queue-4.4/crypto-algboss-don-t-wait-during-notifier-callback.patch [new file with mode: 0644]
queue-4.4/series

diff --git a/queue-4.4/crypto-algboss-don-t-wait-during-notifier-callback.patch b/queue-4.4/crypto-algboss-don-t-wait-during-notifier-callback.patch
new file mode 100644 (file)
index 0000000..88e532d
--- /dev/null
@@ -0,0 +1,58 @@
+From 77251e41f89a813b4090f5199442f217bbf11297 Mon Sep 17 00:00:00 2001
+From: Eric Biggers <ebiggers@google.com>
+Date: Thu, 4 Jun 2020 11:52:53 -0700
+Subject: crypto: algboss - don't wait during notifier callback
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Eric Biggers <ebiggers@google.com>
+
+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 <gerow@google.com>
+Fixes: 398710379f51 ("crypto: algapi - Move larval completion into algboss")
+Cc: <stable@vger.kernel.org> # v3.6+
+Cc: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Eric Biggers <ebiggers@google.com>
+Reported-by: Kai Lüke <kai@kinvolk.io>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ crypto/algboss.c |    2 --
+ 1 file changed, 2 deletions(-)
+
+--- a/crypto/algboss.c
++++ b/crypto/algboss.c
+@@ -194,8 +194,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:
index 76a5f91143f76a6ff53ab297466a397f3f845660..415316afb8e56507e60e6a91e869fcdb799cb232 100644 (file)
@@ -68,3 +68,4 @@ ext4-fix-partial-cluster-initialization-when-splitti.patch
 drm-dp_mst-increase-act-retry-timeout-to-3s.patch
 sparc64-fix-misuses-of-access_process_vm-in-genregs3.patch
 block-nr_sects_write-disable-preemption-on-seqcount-.patch
+crypto-algboss-don-t-wait-during-notifier-callback.patch