From: Jarkko Sakkinen <jarkko@kernel.org>
To: David Howells <dhowells@redhat.com>
Cc: keyrings@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Eric Biggers <ebiggers@kernel.org>,
Jarkko Sakkinen <jarkko@kernel.org>, Thomas Graf <tgraf@suug.ch>,
Herbert Xu <herbert@gondor.apana.org.au>,
Andrew Morton <akpm@linux-foundation.org>,
linux-crypto@vger.kernel.org (open list:RHASHTABLE),
linux-kernel@vger.kernel.org (open list:LIBRARY CODE)
Subject: [PATCH v3 0/6] KEYS: Replace assoc_array with rhashtable
Date: Sun, 25 Oct 2026 03:10:08 +0300 [thread overview]
Message-ID: <20261025001105.1824178-1-jarkko@kernel.org> (raw)
The keyring subsystem depends on assoc_array for searching keys by their
description, type and domain. It is the sole user of this data structure,
which has during the age of LLMs transformed into a maintenance nightmare.
assoc_array needs to be replaced with a data structure meeting the
following criteria:
1. Must be suitable for a sparse key-value store.
2. Must have multiple in-kernel users.
3. Would be nice if it had dedicated maintainers.
rhashtable is likely the best pick from the available options as it is
designed for a sparse key space, has dedicated maintainers, and multiple
in-kernel users.
CHANGES
=======
v3:
- Since David is away for the next week I decided to address the
low hanging fruit that I reported myself.
- Unified and sanitized function and variable naming and removed
unnecessary asymmetry e.g., by renaming keyring_remove_all_links
as keyring_index_free, 'links' as 'index' and '_edit' as 'edit'.
- Flattened the implementation by refactoring out some useless
wrappers and other constructs.
- Addressed continuation after triggered WARN_ON() on at the three
sites that I've described in my email response to the previous
patch set version.
- Reworked keyring_read() so that it triggers the scheduler between
the iterations.
- Dropped "Assisted-by: LLM" tag because checkpatch.pl told me so.
v2:
- Tried to address all the issues pointed out by David and Eric. Tell me
if something was ignored, as that would be an unintentional mishap.
- Updated and trimmed the source code comments.
- For assoc_array_edit I decided to go with two-element pointer array,
which shifts a bit what David suggested.
- Dropped is_keyring flag. It was so obvious call so I mention it here
just in case because too obvious maxes out my self-doubt ;-)
- Used cleanup.h primitives where I possibly could especially in order
to make fallible initializations more bug-resistant.
- The already-ack'd bug fixes are included but will be dropped as soon
as I've sent them over to Linus.
VERSIONS
========
- v2: https://lore.kernel.org/keyrings/20261023120953.1206778-1-jarkko@kernel.org/
- v1: https://lore.kernel.org/keyrings/20261016215326.4110064-1-jarkko@kernel.org/
Jarkko Sakkinen (6):
KEYS: Expand key->{datalen,quotalen} to unsigned int
KEYS: Reject descriptions larger than KEY_MAX_DESC_SIZE
KEYS: Verify the key identity in __key_unlink_begin
KEYS: Introduce keyring_is_empty()
KEYS: Replace assoc_array with rhashtable
lib: Remove assoc_array
Documentation/core-api/assoc_array.rst | 564 ------
Documentation/core-api/index.rst | 1 -
.../zh_CN/core-api/assoc_array.rst | 473 -----
.../translations/zh_CN/core-api/index.rst | 1 -
drivers/md/dm-verity-verify-sig.c | 2 +-
fs/smb/client/cifsacl.c | 6 +-
fs/verity/signature.c | 2 +-
include/keys/keyring-type.h | 1 -
include/linux/assoc_array.h | 88 -
include/linux/assoc_array_priv.h | 178 --
include/linux/key.h | 27 +-
lib/Kconfig | 14 -
lib/Makefile | 1 -
lib/assoc_array.c | 1724 -----------------
security/keys/Kconfig | 1 -
security/keys/internal.h | 9 +-
security/keys/key.c | 32 +-
security/keys/keyctl.c | 2 -
security/keys/keyring.c | 940 +++++----
security/keys/request_key.c | 24 +-
.../dm-verity/test-dm-verity-keyring.sh | 2 +-
21 files changed, 491 insertions(+), 3601 deletions(-)
delete mode 100644 Documentation/core-api/assoc_array.rst
delete mode 100644 Documentation/translations/zh_CN/core-api/assoc_array.rst
delete mode 100644 include/linux/assoc_array.h
delete mode 100644 include/linux/assoc_array_priv.h
delete mode 100644 lib/assoc_array.c
--
2.47.3
next reply other threads:[~2026-10-25 0:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 0:10 Jarkko Sakkinen [this message]
2026-10-25 0:10 ` [PATCH v3 1/6] KEYS: Expand key->{datalen,quotalen} to unsigned int Jarkko Sakkinen
2026-10-25 0:10 ` [PATCH v3 2/6] KEYS: Reject descriptions larger than KEY_MAX_DESC_SIZE Jarkko Sakkinen
2026-10-25 0:10 ` [PATCH v3 3/6] KEYS: Verify the key identity in __key_unlink_begin Jarkko Sakkinen
2026-10-25 0:10 ` [PATCH v3 4/6] KEYS: Introduce keyring_is_empty() Jarkko Sakkinen
2026-10-25 0:10 ` [PATCH v3 5/6] KEYS: Replace assoc_array with rhashtable Jarkko Sakkinen
2026-10-25 0:10 ` [PATCH v3 6/6] lib: Remove assoc_array Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261025001105.1824178-1-jarkko@kernel.org \
--to=jarkko@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=keyrings@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tgraf@suug.ch \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®