From: Jarkko Sakkinen <jarkko@kernel.org>
To: Guixiong Wei <weiguixiong@bytedance.com>
Cc: David Howells <dhowells@redhat.com>,
keyrings@vger.kernel.org, Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E . Hallyn" <serge@hallyn.com>,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] KEYS: do not let an unmatched key decide the search result
Date: Mon, 9 Nov 2026 17:02:45 +0200 [thread overview]
Message-ID: <avHglR4H-YNwCTpO@kernel.org> (raw)
In-Reply-To: <20261109032931.80406-2-weiguixiong@bytedance.com>
On Mon, Nov 09, 2026 at 11:29:20AM +0800, Guixiong Wei wrote:
> With the dns_resolver key type available, put a key named "foo" in a
> fresh session keyring, revoke it, and search for "bar":
>
> keyctl new_session >/dev/null
> A=$(printf '127.0.0.1\0' | keyctl padd dns_resolver foo @s)
> keyctl revoke "$A"
> keyctl search @s dns_resolver bar
>
> Results:
>
> keyctl_search: Key has been revoked
>
> The search returns -EKEYREVOKED even though there is no key named "bar".
> It should return -ENOKEY.
>
> A dns_resolver search walks the keys in the keyring and uses
> dns_resolver_cmp() to compare their descriptions with the requested
> name. When keyring_search_iterator() sees the revoked "foo" key, it
> records -EKEYREVOKED in ctx->result and skips the key before comparing
> its description. The search continues, but without a match it returns
> the error recorded for "foo".
>
> Call the match callback before checking for invalidated, revoked or
> expired keys. A nonmatching key then leaves ctx->result alone.
>
> Fixes: b2a4df200d57 ("KEYS: Expand the capacity of a keyring")
> Reported-by: Jarkko Sakkinen <jarkko@kernel.org>
> Closes: https://lore.kernel.org/lkml/avDG8G-Jl1YsmfCs@kernel.org/
> Signed-off-by: Guixiong Wei <weiguixiong@bytedance.com>
Sorry, I could not help complaining about reproducer last time because
it was at the surface :-) It's a great sanity check to do if it is
possible without huge effort (i.e. mainly with shell scripting and
keyutils)>
And since the bug is already out in the public there's nothing
secretive showing "how it is done".
Thank you!
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Br, Jarkko
prev parent reply other threads:[~2026-11-09 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 3:29 [PATCH v2] KEYS: do not let an unmatched key decide the search result Guixiong Wei
2026-11-09 3:38 ` sashiko-bot
2026-11-09 15:02 ` Jarkko Sakkinen [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=avHglR4H-YNwCTpO@kernel.org \
--to=jarkko@kernel.org \
--cc=dhowells@redhat.com \
--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=weiguixiong@bytedance.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 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.