From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "David Gstir" <david@sigma-star.at>, <parthiban@linumiz.com>,
"James Bottomley" <James.Bottomley@HansenPartnership.com>,
"Mimi Zohar" <zohar@linux.ibm.com>,
"David Howells" <dhowells@redhat.com>,
"Paul Moore" <paul@paul-moore.com>,
"James Morris" <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>
Cc: "sigma star Kernel Team" <upstream+dcp@sigma-star.at>,
<linux-integrity@vger.kernel.org>, <keyrings@vger.kernel.org>,
<linux-security-module@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH] KEYS: trusted: dcp: fix NULL dereference in AEAD crypto operation
Date: Wed, 30 Oct 2024 00:37:55 +0200 [thread overview]
Message-ID: <D58NEWOJP8YY.CXZB4F73W284@kernel.org> (raw)
In-Reply-To: <20241029113401.90539-1-david@sigma-star.at>
On Tue Oct 29, 2024 at 1:34 PM EET, David Gstir wrote:
> When sealing or unsealing a key blob we currently do not wait for
> the AEAD cipher operation to finish and simply return after submitting
> the request. If there is some load on the system we can exit before
> the cipher operation is done and the buffer we read from/write to
> is already removed from the stack. This will e.g. result in NULL
> pointer dereference errors in the DCP driver during blob creation.
>
> Fix this by waiting for the AEAD cipher operation to finish before
> resuming the seal and unseal calls.
>
> Cc: stable@vger.kernel.org # v6.10+
> Fixes: 0e28bf61a5f9 ("KEYS: trusted: dcp: fix leak of blob encryption key")
> Reported-by: Parthiban N <parthiban@linumiz.com>
> Closes: https://lore.kernel.org/keyrings/254d3bb1-6dbc-48b4-9c08-77df04baee2f@linumiz.com/
> Signed-off-by: David Gstir <david@sigma-star.at>
> ---
> security/keys/trusted-keys/trusted_dcp.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/security/keys/trusted-keys/trusted_dcp.c b/security/keys/trusted-keys/trusted_dcp.c
> index 4edc5bbbcda3..e908c53a803c 100644
> --- a/security/keys/trusted-keys/trusted_dcp.c
> +++ b/security/keys/trusted-keys/trusted_dcp.c
> @@ -133,6 +133,7 @@ static int do_aead_crypto(u8 *in, u8 *out, size_t len, u8 *key, u8 *nonce,
> struct scatterlist src_sg, dst_sg;
> struct crypto_aead *aead;
> int ret;
> + DECLARE_CRYPTO_WAIT(wait);
>
> aead = crypto_alloc_aead("gcm(aes)", 0, CRYPTO_ALG_ASYNC);
> if (IS_ERR(aead)) {
> @@ -163,8 +164,8 @@ static int do_aead_crypto(u8 *in, u8 *out, size_t len, u8 *key, u8 *nonce,
> }
>
> aead_request_set_crypt(aead_req, &src_sg, &dst_sg, len, nonce);
> - aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_SLEEP, NULL,
> - NULL);
> + aead_request_set_callback(aead_req, CRYPTO_TFM_REQ_MAY_SLEEP,
> + crypto_req_done, &wait);
> aead_request_set_ad(aead_req, 0);
>
> if (crypto_aead_setkey(aead, key, AES_KEYSIZE_128)) {
> @@ -174,9 +175,9 @@ static int do_aead_crypto(u8 *in, u8 *out, size_t len, u8 *key, u8 *nonce,
> }
>
> if (do_encrypt)
> - ret = crypto_aead_encrypt(aead_req);
> + ret = crypto_wait_req(crypto_aead_encrypt(aead_req), &wait);
> else
> - ret = crypto_aead_decrypt(aead_req);
> + ret = crypto_wait_req(crypto_aead_decrypt(aead_req), &wait);
>
> free_req:
> aead_request_free(aead_req);
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
next prev parent reply other threads:[~2024-10-29 22:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-10 15:02 Trusted keys: DCP: Unable to handle paging request Parthiban
2024-09-11 11:46 ` David Gstir
2024-10-29 11:34 ` [PATCH] KEYS: trusted: dcp: fix NULL dereference in AEAD crypto operation David Gstir
2024-10-29 22:37 ` Jarkko Sakkinen [this message]
2024-10-29 22:38 ` 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=D58NEWOJP8YY.CXZB4F73W284@kernel.org \
--to=jarkko@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=david@sigma-star.at \
--cc=dhowells@redhat.com \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=parthiban@linumiz.com \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=stable@vger.kernel.org \
--cc=upstream+dcp@sigma-star.at \
--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 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.