mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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>,
	Andrew Morton <akpm@linux-foundation.org>,
	Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	open list <linux-kernel@vger.kernel.org>,
	"open list:SECURITY SUBSYSTEM"
	<linux-security-module@vger.kernel.org>
Subject: Re: [PATCH v2 5/6] KEYS: Replace assoc_array with rhashtable
Date: Sat, 24 Oct 2026 07:58:13 +0300	[thread overview]
Message-ID: <atw65V6xfUJpUsN8@kernel.org> (raw)
In-Reply-To: <20261023120953.1206778-6-jarkko@kernel.org>

I'll just run through three issues that I forgot to update for this
patch set version. I think it was good because probably these could
use some feedback.

On Fri, Oct 23, 2026 at 03:09:25PM +0300, Jarkko Sakkinen wrote:
> +	WARN_ON(rhashtable_remove_fast(&links->ht, &link->node,
> +				       keyring_link_params));
> +	list_del_rcu(&link->list);
> +	WRITE_ONCE(links->nr, links->nr - 1);
> +	call_rcu(&link->rcu, keyring_link_free_rcu);

keyring_remove_link() is called by __key_unlink() and keyring_gc(),
which are infallible operations.

At minimum this should be changed as:

	if (WARN_ON(rhashtable_remove_fast(/* ... */))
		return;
	
	/* ... */

Alternatively, keyring_remove_link() could be fallible operation,
and leave that decision up to the callers.

> +		WARN_ON(rhashtable_replace_fast(&links->ht, &old->node,
> +						&link->node,
> +						keyring_link_params));
> +		list_replace_rcu(&old->list, &link->list);
> +		call_rcu(&old->rcu, keyring_link_free_rcu);

__key_link() is called by __key_instantiate_and_link(), key_link(),
key_move(), construct_alloc_key() and key_reject_and_link() i.e.,
by majority fallible functions.

Are all of these call sites such that if __key_link() was a fallible
operation it would be impossible roll back, or is this something that
could be addressed better?

> +			WARN_ON(rhashtable_remove_fast(&keyring_index_locked(keyring)->ht,
> +						       &link->node,
> +						       keyring_link_params));
> +			call_rcu(&link->rcu, keyring_link_free_rcu);

__key_link_end() goes along the lines of keyring_link_remove().

However these are decided I will remove keyring_link_remove(). There's
enough symbols to get confused already, it has only two call sites and
frankly I'd just want to see its contents open-coded in those sites.
And it makes the level symmetric with __key_link_end().

keyring_link_remove() is type of slop that needs to be wiped away
constantly from any LLM sourced code, at least in my experience as models
tend to build on top of that design, and soon you have a nest.

Br, Jarkko

  parent reply	other threads:[~2026-10-24  4:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 12:09 [PATCH v2 0/6] KEYS: From assoc_array to rhashtable migration Jarkko Sakkinen
2026-10-23 12:09 ` [PATCH v2 1/6] KEYS: Expand key->{datalen,quotalen} to unsigned int Jarkko Sakkinen
2026-10-23 12:09 ` [PATCH v2 2/6] KEYS: Reject descriptions larger than KEY_MAX_DESC_SIZE Jarkko Sakkinen
2026-10-23 12:09 ` [PATCH v2 3/6] KEYS: Verify the key identity in __key_unlink_begin Jarkko Sakkinen
2026-10-23 12:09 ` [PATCH v2 4/6] KEYS: Introduce keyring_is_empty() Jarkko Sakkinen
2026-10-23 12:09 ` [PATCH v2 5/6] KEYS: Replace assoc_array with rhashtable Jarkko Sakkinen
2026-10-23 13:22   ` Jarkko Sakkinen
2026-10-24  4:58   ` Jarkko Sakkinen [this message]
2026-10-24 14:28   ` Jarkko Sakkinen
2026-10-24 16:26     ` Jarkko Sakkinen
2026-10-23 12:09 ` [PATCH v2 6/6] lib: Remove assoc_array Jarkko Sakkinen
2026-10-23 12:36 ` [PATCH v2 0/6] KEYS: From assoc_array to rhashtable migration 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=atw65V6xfUJpUsN8@kernel.org \
    --to=jarkko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=ebiggers@kernel.org \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    --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®