FAILED: patch "[PATCH] crypto: api - Demote BUG_ON() in crypto_unregister_alg() to a" failed to apply to 4.19-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-4.19.y
git checkout FETCH_HEAD
git cherry-pick -x a543ada7db729514ddd3ba4efa45f4c7b802ad85
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2023050702-hasty-matted-a47d@gregkh' --subject-prefix 'PATCH 4.19.y' HEAD^..
Possible dependencies:
a543ada7db72 ("crypto: api - Demote BUG_ON() in crypto_unregister_alg() to a WARN_ON()")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From a543ada7db729514ddd3ba4efa45f4c7b802ad85 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <[email protected]>
Date: Mon, 13 Mar 2023 10:17:24 +0100
Subject: [PATCH] crypto: api - Demote BUG_ON() in crypto_unregister_alg() to a
WARN_ON()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The crypto_unregister_alg() function expects callers to ensure that any algorithm that is unregistered has a refcnt of exactly 1, and issues a BUG_ON() if this is not the case. However, there are in fact drivers that will call crypto_unregister_alg() without ensuring that the refcnt has been lowered first, most notably on system shutdown. This causes the BUG_ON() to trigger, which prevents a clean shutdown and hangs the system.
To avoid such hangs on shutdown, demote the BUG_ON() in crypto_unregister_alg() to a WARN_ON() with early return. Cc stable because this problem was observed on a 6.2 kernel, cf the link below.
crypto/algapi.c +3 -1
@@ -491,7 +491,9 @@ void crypto_unregister_alg(struct crypto_alg *alg)if (WARN (ret,"Algorithm %s is not registered" , alg->cra_driver_name))return ; -BUG_ON (refcount_read (&alg->cra_refcnt) !=1 ); +if (WARN_ON (refcount_read (&alg->cra_refcnt) !=1 )) +return ; +if (alg->cra_destroy) alg->cra_destroy (alg);