Linux Security Modules development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Henry Martin" <bsdhenrymartin@gmail.com>,
	dhowells@redhat.com, jarkko@kernel.org, paul@paul-moore.com,
	jmorris@namei.org, serge@hallyn.com, Jason@zx2c4.com
Cc: keyrings@vger.kernel.org, linux-security-module@vger.kernel.org
Subject: Re: [PATCH] keys: fix crash on big_key read or revoke after a failed update
Date: Mon, 23 Nov 2026 17:04:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-229703@kernel.org> (raw)
In-Reply-To: <20261123165443.4092852-1-bsdhenrymartin@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] keys: inaccurate comment and changelog on quota handling in
  big_key_update()
--

commit 2c08313937317377d7723fd6ab0f42836903865d
Author: Henry Martin <bsdhenrymartin@gmail.com>

keys: fix crash on big_key read or revoke after a failed update

This commit changes big_key_update() to instantiate the new key payload
before releasing the old payload's path and data, and removes the prior
key_payload_reserve(key, prep->datalen) call.

> diff --git a/security/keys/big_key.c b/security/keys/big_key.c
> index 268f702df380e..3bf371f6c28d3 100644
> --- a/security/keys/big_key.c
> +++ b/security/keys/big_key.c
> @@ -193,16 +193,31 @@ void big_key_destroy(struct key *key)
>   */
>  int big_key_update(struct key *key, struct key_preparsed_payload *prep)
>  {
> +	struct big_key_payload old = { };
> +	bool positive = key_is_positive(key);
>  	int ret;
>  
> -	ret = key_payload_reserve(key, prep->datalen);
> +	if (positive)
> +		old = *to_big_key_payload(key->payload);
> +
> +	/*
> +	 * The quota for a big_key payload is a fixed 16 bytes that was
> +	 * already reserved when the key was instantiated, so the instantiate
> +	 * below does not change the reservation of a positive key.  Do not
> +	 * release it first: a concurrent allocation could take the quota and
> +	 * make the instantiate fail after the old payload was destroyed.
> +	 */
> +	ret = generic_key_instantiate(key, prep);

[Severity: Low]
Are this comment and the commit message accurate about what altered the
quota reservation before generic_key_instantiate()?

big_key_destroy() only drops payload->path and payload->data and never
touches key quota.  What changed the reservation was the removed
key_payload_reserve(key, prep->datalen) call, which passed the raw payload
length prep->datalen instead of prep->quotalen (16 bytes).  When
prep->datalen < 16 (or when prep->datalen >= 65536 and truncates to an
unsigned short key->datalen < 16), key_payload_reserve() left key->datalen
below 16, causing the subsequent key_payload_reserve(key, prep->quotalen)
inside generic_key_instantiate() to charge 16 - key->datalen bytes and
potentially fail with -EDQUOT after big_key_destroy() had already run.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123165443.4092852-1-bsdhenrymartin@gmail.com?part=1

      reply	other threads:[~2026-11-23 17:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 16:54 [PATCH] keys: fix crash on big_key read or revoke after a failed update Henry Martin
2026-11-23 17:04 ` sashiko-bot [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=sashiko-outbox-229703@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Jason@zx2c4.com \
    --cc=bsdhenrymartin@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=serge@hallyn.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