From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "David Howells" <dhowells@redhat.com>,
"Petr Pavlu" <petr.pavlu@suse.com>
Cc: <keyrings@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] keys: Fix linking a duplicate key to a keyring's assoc_array
Date: Thu, 08 Jun 2023 22:03:30 +0300 [thread overview]
Message-ID: <CT7I3FSMNR0V.8DOJ8GZ6LPDK@suppilovahvero> (raw)
In-Reply-To: <2413881.1686233574@warthog.procyon.org.uk>
On Thu Jun 8, 2023 at 5:12 PM EEST, David Howells wrote:
> Apologies for missing this patch.
>
> Petr Pavlu <petr.pavlu@suse.com> wrote:
>
> > * Back on the first task, function construct_alloc_key() first runs
> > __key_link_begin() to determine an assoc_array_edit operation to
> > insert a new key. Index keys in the array are compared exactly as-is,
> > using keyring_compare_object(). The operation finds that "abcdef" is
> > not yet present in the destination keyring.
>
> Good catch, but I think it's probably the wrong solution.
>
> keyring_compare_object() needs to use the ->cmp() function from the key type.
>
> It's not just request_key() that might have a problem, but also key_link().
>
> There are also asymmetric keys which match against multiple criteria - though
> I'm fine with just matching the main description there (the important bit
> being to maintain the integrity of the tree inside assoc_array).
>
> I wonder, should I scrap the assoc_array approach and go to each keyring being
> a linked-list? It's slower, but a lot easier to manage - and more forgiving
> of problems.
>
> struct key_ptr {
> struct list_head link;
> struct key *key;
> unsigned long key_hash;
> };
>
> I'm also wondering if I should remove the key type from the matching criteria
> - i.e. there can only be one key with any particular description in a ring at
> once, regardless of type. Unfortunately, this is may be a UAPI breaker
> somewhere.
>
> Any thoughts?
If the amount of items stays at most in hundreds (or actually even like
few thousand items), there's very little gain of having the complexity
of associative array. In most cases it probably shoots back in many
ways.
I've been thinking this for a long time but have thought that since it
has been there, there must be good reasons to have it.
So yeah, definitely +1 for scraping assoc array.
BR, Jarkko
next prev parent reply other threads:[~2023-06-08 19:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 13:04 Petr Pavlu
2023-03-30 0:13 ` Jarkko Sakkinen
2023-06-08 9:55 ` Petr Pavlu
2023-06-08 13:18 ` Jarkko Sakkinen
2023-06-08 13:28 ` Jarkko Sakkinen
2023-04-21 2:39 ` joeyli
2023-06-08 14:12 ` David Howells
2023-06-08 19:03 ` Jarkko Sakkinen [this message]
2023-06-09 9:49 ` Petr Pavlu
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=CT7I3FSMNR0V.8DOJ8GZ6LPDK@suppilovahvero \
--to=jarkko@kernel.org \
--cc=dhowells@redhat.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=petr.pavlu@suse.com \
/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®