[PATCH v8 2/3] KEYS: Replace assoc_array with rhashtable

Jarkko Sakkinen jarkko at kernel.org
Tue Nov 10 05:21:27 UTC 2026


On Tue, Nov 10, 2026 at 05:03:58AM +0000, sashiko-bot at kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential
> issues to consider:
> - [Critical] keys: uninitialized return value in __key_link_begin() on
>   link replacement
> - [Critical] keys: goto jumps past __free(kfree) initialization in
>   __key_link_begin()

I'll retract using cleanup.h shenanigans i.e.

diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 60309f18e3a5..04d9a98c0f31 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -1185,6 +1185,7 @@ int __key_link_begin(struct key *keyring,
 		     const struct keyring_index_key *index_key,
 		     struct keyring_edit *edit)
 {
+	struct keyring_link *link = NULL;
 	struct keyring_link *replace;
 	struct keyring_index *links;
 	int ret;
@@ -1211,7 +1212,7 @@ int __key_link_begin(struct key *keyring,
 		goto out;
 	}

-	struct keyring_link *link __free(kfree) = kzalloc_obj(struct keyring_link);
+	link = kzalloc_obj(struct keyring_link);
 	if (!link) {
 		ret = -ENOMEM;
 		goto out;
@@ -1239,10 +1240,13 @@ int __key_link_begin(struct key *keyring,
 		}
 	}

-	edit->new = no_free_ptr(link);
+	edit->new = link;
 	edit->old = replace;
+	ret = 0;

 out:
+	if (ret && link)
+		kfree(link);
 	kleave(" = %d", ret);
 	return ret;
 }

I went clearly over the top with the cleanup.h macros (lessons learned).

Br, Jarkko



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