[PATCH v13 3/7] s390/cert_store: Skip keys that disappeared during invalidation

Jarkko Sakkinen jarkko at kernel.org
Sat Nov 14 19:36:27 UTC 2026


key_lookup() can return ERR_PTR(-ENOKEY) for an unlinked key. Skip such
keys instead.

Cc: David Howells <dhowells at redhat.com>
Cc: stable at vger.kernel.org # v6.6+
Fixes: 8cf57d7217c3 ("s390: add support for user-defined certificates")
Signed-off-by: Jarkko Sakkinen <jarkko at kernel.org>
---
 arch/s390/kernel/cert_store.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
index 0a10b31d68af..bec95991edae 100644
--- a/arch/s390/kernel/cert_store.c
+++ b/arch/s390/kernel/cert_store.c
@@ -331,17 +331,25 @@ static int invalidate_keyring_keys(struct key *keyring)
 		goto out;
 	}
 
+	rc = 0;
+
 	for (key_index = 0; key_index < num_keys; key_index++) {
 		current_key = key_lookup(key_array[key_index]);
+		if (IS_ERR(current_key))
+			continue;
+
 		pr_dbf_msg("Invalidating key %08x", current_key->serial);
 
 		key_invalidate(current_key);
-		key_put(current_key);
 		rc = key_unlink(keyring, current_key);
+		if (rc == -ENOENT)
+			rc = 0;
 		if (rc) {
 			pr_dbf_msg("Couldn't unlink key %08x: %d", current_key->serial, rc);
+			key_put(current_key);
 			break;
 		}
+		key_put(current_key);
 	}
 out:
 	kfree(key_array);
-- 
2.47.3




More information about the Linux-security-module-archive mailing list