From: Petr Pavlu <petr.pavlu@suse.com>
To: David Howells <dhowells@redhat.com>
Cc: jarkko@kernel.org, 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: Fri, 9 Jun 2023 11:49:07 +0200 [thread overview]
Message-ID: <db70b460-ae5f-5a8b-bab9-aae45ebc87d1@suse.com> (raw)
In-Reply-To: <2413881.1686233574@warthog.procyon.org.uk>
On 6/8/23 16:12, David Howells wrote:
> 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().
The way I view the current design is that it kind of consists of two
layers. Lower-level functions key_create(), key_link(), key_move(), etc.
are built directly on top of assoc_array, use the exact comparison and
benefit from the assoc_array speed.
Higher-level function request_key() then provides a callout
functionality and offers an option to do approximate search if a needed
key is already present. This gives a trade-off to potentially reduce
a number of callouts but on the other hand requires a linear search over
the underlying keyrings/assoc_arrays.
The patch tries to only provide a point fix where the request-key logic
in construct_alloc_key() wrongly interacted with the approximate
matching option. If my understanding of the current design is correct
then I think key_link() shouldn't require any change in this regard.
Just wanted to add this point, I can't really comment on whether the
whole thing should be designed differently in the first place.
Thanks,
Petr
prev parent reply other threads:[~2023-06-09 9:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 13:04 [PATCH] keys: Fix linking a duplicate key to a keyring's assoc_array 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
2023-06-09 9:49 ` Petr Pavlu [this message]
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=db70b460-ae5f-5a8b-bab9-aae45ebc87d1@suse.com \
--to=petr.pavlu@suse.com \
--cc=dhowells@redhat.com \
--cc=jarkko@kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.