[Devel] [PATCH RHEL9 COMMIT] ms/crypto: iaa - Remove potential infinite loop in check_completion()

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 9 21:03:15 MSK 2025


The commit is pushed to "branch-rh9-5.14.0-427.77.1.vz9.86.x-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh9-5.14.0-427.77.1.vz9.86.12
------>
commit 305574a633712d50cbc03a2fd494f27933d24ef2
Author: Zanussi, Tom <tom.zanussi at linux.intel.com>
Date:   Fri Sep 27 13:46:49 2024 -0500

    ms/crypto: iaa - Remove potential infinite loop in check_completion()
    
    For iaa_crypto operations, it's assumed that if an operation doesn't
    make progress, the IAA watchdog timer will kick in and set the
    completion status bit to failure and the reason to completion timeout.
    
    Some systems may have broken hardware that doesn't even do that, which
    can result in an infinite status-checking loop. Add a check for that
    in the loop, and disable the driver if it occurs.
    
    Signed-off-by: Tom Zanussi <tom.zanussi at linux.intel.com>
    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
    
    https://virtuozzo.atlassian.net/browse/VSTOR-115785
    
    (cherry picked from commit 8c5459f1663ee689f94e69b25adb415cb95acb88)
    Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
    
    Feature: fix ms/drivers
---
 drivers/crypto/intel/iaa/iaa_crypto_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/intel/iaa/iaa_crypto_main.c
index 0d9e345af3a47..534a37d629c11 100644
--- a/drivers/crypto/intel/iaa/iaa_crypto_main.c
+++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c
@@ -947,12 +947,22 @@ static inline int check_completion(struct device *dev,
 				   bool only_once)
 {
 	char *op_str = compress ? "compress" : "decompress";
+	int status_checks = 0;
 	int ret = 0;
 
 	while (!comp->status) {
 		if (only_once)
 			return -EAGAIN;
 		cpu_relax();
+		if (status_checks++ >= IAA_COMPLETION_TIMEOUT) {
+			/* Something is wrong with the hw, disable it. */
+			dev_err(dev, "%s completion timed out - "
+				"assuming broken hw, iaa_crypto now DISABLED\n",
+				op_str);
+			iaa_crypto_enabled = false;
+			ret = -ETIMEDOUT;
+			goto out;
+		}
 	}
 
 	if (comp->status != IAX_COMP_SUCCESS) {


More information about the Devel mailing list