All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>
Cc: "David Howells" <dhowells@redhat.com>,
	keyrings@vger.kernel.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Sven Schnelle" <svens@linux.ibm.com>,
	"Kees Cook" <kees@kernel.org>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Anastasia Eskova" <anastasia.eskova@ibm.com>,
	"Peter Oberparleiter" <oberpar@linux.ibm.com>,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH] s390/cert_store: Hold the keyring->sem while invalidating keys
Date: Sat, 24 Oct 2026 14:58:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-183758@kernel.org> (raw)
In-Reply-To: <20261024144229.1546151-1-jarkko@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] s390/cert_store: scoped_guard() mixed with goto in invalidate_keyring_keys()
--

commit e2f24110a6a571c7bef25566a83aee22fb61ad5a
Author: Jarkko Sakkinen <jarkko@kernel.org>

s390/cert_store: Hold the keyring->sem while invalidating keys

This commit acquires keyring->sem for reading via scoped_guard() in
invalidate_keyring_keys() while querying the keyring payload length and
reading the key serial numbers.

> diff --git a/arch/s390/kernel/cert_store.c b/arch/s390/kernel/cert_store.c
> index 998f2da561750..d35b1ea22507d 100644
> --- a/arch/s390/kernel/cert_store.c
> +++ b/arch/s390/kernel/cert_store.c
[ ... ]
> @@ -320,13 +321,17 @@ static int invalidate_keyring_keys(struct key *keyring)
>  	struct key *current_key;
>  	int rc;
>  
> -	keyring_payload_len = key_type_keyring.read(keyring, NULL, 0);
> -	num_keys = keyring_payload_len / sizeof(key_serial_t);
> -	key_array = kzalloc_objs(key_serial_t, num_keys);
> -	if (!key_array)
> -		return -ENOMEM;
> +	scoped_guard(rwsem_read, &keyring->sem) {
> +		keyring_payload_len = key_type_keyring.read(keyring, NULL, 0);
> +		num_keys = keyring_payload_len / sizeof(key_serial_t);
> +
> +		key_array = kzalloc_objs(key_serial_t, num_keys);
> +		if (!key_array)
> +			return -ENOMEM;
> +
> +		rc = key_type_keyring.read(keyring, (char *)key_array, keyring_payload_len);
> +	}
>  
> -	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;

[Severity: Low]
In invalidate_keyring_keys() in arch/s390/kernel/cert_store.c, this patch
introduces scoped_guard(rwsem_read, &keyring->sem) while the function still
uses goto out to free key_array when key_type_keyring.read() returns a length
mismatch:

	if (rc != keyring_payload_len) {
		pr_dbf_msg("Couldn't read keyring payload");
		goto out;
	}
	...
out:
	kfree(key_array);
	return rc;

include/linux/cleanup.h notes that goto-based cleanup and scope-based cleanup
helpers should not be mixed within the same function. Could key_array also be
declared with __free(kfree) = NULL so the out label and goto can be dropped,
or should explicit down_read() and up_read() calls be used instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261024144229.1546151-1-jarkko@kernel.org?part=1

  reply	other threads:[~2026-10-24 14:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24 14:42 [PATCH] s390/cert_store: Hold the keyring->sem while invalidating keys Jarkko Sakkinen
2026-10-24 14:58 ` sashiko-bot [this message]
2026-10-24 16:15   ` Jarkko Sakkinen
2026-10-28 15:34 ` Heiko Carstens
2026-10-28 15:59   ` 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-183758@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=anastasia.eskova@ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=dhowells@redhat.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=jarkko@kernel.org \
    --cc=kees@kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=oberpar@linux.ibm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=svens@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 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.