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 v11 3/6] s390/cert_store: Skip keys that disappeared during invalidation
Date: Sat, 14 Nov 2026 16:24:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-214746@kernel.org> (raw)
In-Reply-To: <20261114161211.376859-4-jarkko@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] s390/cert_store: error pointer dereference in
invalidate_keyring_keys()
- [Medium] s390/cert_store: stale positive return value in
invalidate_keyring_keys()
--
commit ec7f40e3c2123cec6e6be32d5977d8c112a6da55
Author: Jarkko Sakkinen <jarkko@kernel.org>
s390/cert_store: Skip keys that disappeared during invalidation
This commit adds a NULL check after key_lookup() in
invalidate_keyring_keys() to skip keys that were unlinked before lookup.
> diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
> index 0a10b31d68af3..bc682216fa7fd 100644
> --- a/arch/s390/kernel/cert_store.c
> +++ b/arch/s390/kernel/cert_store.c
> @@ -333,6 +333,9 @@ static int invalidate_keyring_keys(struct key *keyring)
>
> for (key_index = 0; key_index < num_keys; key_index++) {
> current_key = key_lookup(key_array[key_index]);
> + if (!current_key)
> + continue;
> +
> pr_dbf_msg("Invalidating key %08x", current_key->serial);
>
> key_invalidate(current_key);
[Severity: High]
Should this check IS_ERR(current_key) instead of !current_key? When a key
is not found or its usage count has dropped to zero, key_lookup() returns
ERR_PTR(-ENOKEY) rather than NULL, so current_key->serial and
key_invalidate(current_key) will still dereference an error pointer.
[Severity: Medium]
Can skipping keys via continue cause invalidate_keyring_keys() to return a
positive byte count on success? Before the loop, rc is set to
keyring_payload_len by key_type_keyring.read() and is only updated by
key_unlink():
arch/s390/kernel/cert_store.c:invalidate_keyring_keys() {
...
rc = key_type_keyring.read(keyring, (char *)key_array, keyring_payload_len);
if (rc != keyring_payload_len) {
pr_dbf_msg("Couldn't read keyring payload");
goto out;
}
for (key_index = 0; key_index < num_keys; key_index++) {
...
rc = key_unlink(keyring, current_key);
...
out:
kfree(key_array);
return rc;
}
If all keys in key_array have disappeared and are skipped, rc remains
keyring_payload_len, causing cleanup_cs_keys() to treat the call as a
failure and unregister key_type_cert_store_key.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261114161211.376859-1-jarkko@kernel.org?part=3
next prev parent reply other threads:[~2026-11-14 16:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-14 16:12 [PATCH v11 0/6] KEYS: Replace assoc_array with Jarkko Sakkinen
2026-11-14 16:12 ` [PATCH v11 1/6] s390/cert_store: Pin the user session keyring Jarkko Sakkinen
2026-11-14 16:51 ` bot+bpf-ci
2026-11-14 16:12 ` [PATCH v11 2/6] s390/cert_store: Return an owned reference from find_cs_keyring() Jarkko Sakkinen
2026-11-14 16:51 ` bot+bpf-ci
2026-11-14 16:12 ` [PATCH v11 3/6] s390/cert_store: Skip keys that disappeared during invalidation Jarkko Sakkinen
2026-11-14 16:24 ` sashiko-bot [this message]
2026-11-14 16:12 ` [PATCH v11 4/6] KEYS: Introduce keyring_is_empty() Jarkko Sakkinen
2026-11-14 16:12 ` [PATCH v11 5/6] KEYS: Replace assoc_array with rhashtable Jarkko Sakkinen
2026-11-14 17:04 ` bot+bpf-ci
2026-11-14 16:12 ` [PATCH v11 6/6] lib: Remove assoc_array 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=sashiko-outbox-214746@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