From: sashiko-bot@kernel.org
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
"David Howells" <dhowells@redhat.com>
Cc: bpf@vger.kernel.org, dm-devel@lists.linux.dev,
fsverity@lists.linux.dev, keyrings@vger.kernel.org,
linux-security-module@vger.kernel.org,
"Alasdair Kergon" <agk@redhat.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Alex Shi" <alexs@kernel.org>,
"Anastasia Eskova" <anastasia.eskova@ibm.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Benjamin Marzinski" <bmarzins@redhat.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Dongliang Mu" <dzm91@hust.edu.cn>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Eric Biggers" <ebiggers@kernel.org>,
"Ignat Korchagin" <ignat@linux.win>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"James Bottomley" <James.Bottomley@HansenPartnership.com>,
"James Morris" <jmorris@namei.org>,
"Jiri Olsa" <jolsa@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Mike Snitzer" <snitzer@kernel.org>,
"Mikulas Patocka" <mpatocka@redhat.com>,
"Mimi Zohar" <zohar@linux.ibm.com>,
"Paul Moore" <paul@paul-moore.com>,
"Peter Oberparleiter" <oberpar@linux.ibm.com>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Roberto Sassu" <roberto.sassu@huawei.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Song Liu" <song@kernel.org>,
"Sven Schnelle" <svens@linux.ibm.com>,
"Theodore Y. Ts'o" <tytso@mit.edu>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Yanteng Si" <si.yanteng@linux.dev>,
"Yonghong Song" <yonghong.song@linux.dev>
Subject: Re: [PATCH v12 3/6] s390/cert_store: Skip keys that disappeared during invalidation
Date: Sat, 14 Nov 2026 17:01:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-214809@kernel.org> (raw)
In-Reply-To: <20261114164139.429814-4-jarkko@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] s390/cert_store: incomplete handling of unlinked keys in
invalidate_keyring_keys()
- [Low] s390/cert_store: commit message claims key_lookup() returns NULL
--
commit 725043b976271178c0635971476e80ff473d9670
Author: Jarkko Sakkinen <jarkko@kernel.org>
s390/cert_store: Skip keys that disappeared during invalidation
This commit updates invalidate_keyring_keys() to initialize rc to 0 and
skip keys when key_lookup() returns an error pointer during keyring
invalidation.
> key_lookup() can return NULL for an unlinked key. Skip such keys instead.
[Severity: Low]
Is this commit message description accurate? CONFIG_CERT_STORE depends on
CONFIG_KEYS, and when CONFIG_KEYS is enabled, key_lookup() returns
ERR_PTR(-ENOKEY) rather than NULL (which matches the IS_ERR(current_key)
check in the diff).
> diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
> index 0a10b31d68af3..03391b379dad3 100644
> --- a/arch/s390/kernel/cert_store.c
> +++ b/arch/s390/kernel/cert_store.c
> @@ -331,8 +331,13 @@ static int invalidate_keyring_keys(struct key *keyring)
> goto out;
> }
>
> + rc = 0;
> +
> for (key_index = 0; key_index < num_keys; key_index++) {
> current_key = key_lookup(key_array[key_index]);
> + if (IS_ERR(current_key))
> + continue;
> +
> pr_dbf_msg("Invalidating key %08x", current_key->serial);
>
> key_invalidate(current_key);
[Severity: Medium]
Does skipping only key_lookup() failures still leave unlinked keys unhandled
later in invalidate_keyring_keys()?
When a key is unlinked from a keyring, dropping its reference is deferred to
an RCU callback (or another reference may exist), so key_lookup() still
succeeds; key_invalidate(current_key) also schedules keyring_gc(), which can
unlink current_key before key_unlink() runs:
arch/s390/kernel/cert_store.c:invalidate_keyring_keys() {
...
key_invalidate(current_key);
key_put(current_key);
rc = key_unlink(keyring, current_key);
if (rc) {
pr_dbf_msg("Couldn't unlink key %08x: %d", current_key->serial, rc);
break;
}
}
In either case, key_unlink() returns -ENOENT, aborting the loop before the
remaining keys in key_array are invalidated and causing cleanup_cs_keys() to
fall back to unregister_key_type(&key_type_cert_store_key). Note also that
key_put(current_key) drops the caller's reference before key_unlink() and
current_key->serial are used.
Similarly, if a key is unlinked between the two key_type_keyring.read() calls
earlier in invalidate_keyring_keys(), the second call returns a smaller byte
count than keyring_payload_len and jumps to out without invalidating the
remaining keys, returning 0 if the last key was unlinked or a positive byte
count otherwise.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261114164139.429814-1-jarkko@kernel.org?part=3
next prev parent reply other threads:[~2026-11-14 17:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 16:41 [PATCH v12 0/6] KEYS: Replace assoc_array with rhashtable Jarkko Sakkinen
2026-11-14 16:41 ` [PATCH v12 1/6] s390/cert_store: Pin the user session keyring Jarkko Sakkinen
2026-11-14 16:58 ` sashiko-bot
2026-11-14 16:41 ` [PATCH v12 2/6] s390/cert_store: Return an owned reference from find_cs_keyring() Jarkko Sakkinen
2026-11-14 16:53 ` sashiko-bot
2026-11-14 16:41 ` [PATCH v12 3/6] s390/cert_store: Skip keys that disappeared during invalidation Jarkko Sakkinen
2026-11-14 17:01 ` sashiko-bot [this message]
2026-11-14 16:41 ` [PATCH v12 4/6] KEYS: Introduce keyring_is_empty() Jarkko Sakkinen
2026-11-14 16:46 ` sashiko-bot
2026-11-14 16:41 ` [PATCH v12 5/6] KEYS: Replace assoc_array with rhashtable Jarkko Sakkinen
2026-11-14 17:01 ` sashiko-bot
2026-11-14 16:41 ` [PATCH v12 6/6] lib: Remove assoc_array Jarkko Sakkinen
2026-11-14 16:49 ` sashiko-bot
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=sashiko-outbox-214809@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=agk@redhat.com \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=alexs@kernel.org \
--cc=anastasia.eskova@ibm.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bmarzins@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=daniel@iogearbox.net \
--cc=dhowells@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=dzm91@hust.edu.cn \
--cc=ebiggers@kernel.org \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=fsverity@lists.linux.dev \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=ignat@linux.win \
--cc=ihor.solodrai@linux.dev \
--cc=jarkko@kernel.org \
--cc=jmorris@namei.org \
--cc=jolsa@kernel.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mpatocka@redhat.com \
--cc=oberpar@linux.ibm.com \
--cc=paul@paul-moore.com \
--cc=rdunlap@infradead.org \
--cc=roberto.sassu@huawei.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=serge@hallyn.com \
--cc=si.yanteng@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=snitzer@kernel.org \
--cc=song@kernel.org \
--cc=svens@linux.ibm.com \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=yonghong.song@linux.dev \
--cc=zohar@linux.ibm.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