Linux cryptographic layer development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eric Biggers" <ebiggers@kernel.org>
Cc: "David Howells" <dhowells@redhat.com>,
	"Marc Dionne" <marc.dionne@auristor.com>,
	linux-crypto@vger.kernel.org,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>
Subject: Re: [PATCH net-next 2/5] net/rxrpc: Use local FCrypt-PCBC implementation
Date: Fri, 30 Oct 2026 04:53:35 +0000	[thread overview]
Message-ID: <sashiko-outbox-190324@kernel.org> (raw)
In-Reply-To: <20260428024400.123337-3-ebiggers@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Stack-allocated `struct fcrypt_key` is not zeroized before returning in `rxkad_decrypt_response()`.
--

commit cab871c1c0eecff467a076e259b88fd1f8a50b0a
Author: Eric Biggers <ebiggers@kernel.org>

net/rxrpc: Use local FCrypt-PCBC implementation

This patch replaces the crypto API implementation of FCrypt-PCBC with a
local implementation. This improves performance, allows removing the crypto
API dependency, and simplifies the decryption code by linearizing the skb.

> diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
> index cba7935977f0..3c9e7f636b42 100644
> --- a/net/rxrpc/rxkad.c
> +++ b/net/rxrpc/rxkad.c

[ ... ]

> @@ -1095,39 +916,22 @@ static int rxkad_decrypt_ticket(struct rxrpc_connection *conn,
>  /*
>   * decrypt the response packet
>   */
> -static int rxkad_decrypt_response(struct rxrpc_connection *conn,
> -				  struct rxkad_response *resp,
> -				  const struct rxrpc_crypt *session_key)
> +static void rxkad_decrypt_response(struct rxrpc_connection *conn,
> +				   struct rxkad_response *resp,
> +				   const struct rxrpc_crypt *session_key)
>  {
> -	struct skcipher_request *req = rxkad_ci_req;
> -	struct scatterlist sg[1];
> -	struct rxrpc_crypt iv;
> -	int ret;
> +	struct fcrypt_key cipher;
>  
>  	_enter(",,%08x%08x",
>  	       ntohl(session_key->n[0]), ntohl(session_key->n[1]));
>  
> -	mutex_lock(&rxkad_ci_mutex);
> -	ret = crypto_sync_skcipher_setkey(rxkad_ci, session_key->x,
> -					  sizeof(*session_key));
> -	if (ret < 0)
> -		goto unlock;
> -
> -	memcpy(&iv, session_key, sizeof(iv));
> -
> -	sg_init_table(sg, 1);
> -	sg_set_buf(sg, &resp->encrypted, sizeof(resp->encrypted));
> -	skcipher_request_set_sync_tfm(req, rxkad_ci);
> -	skcipher_request_set_callback(req, 0, NULL, NULL);
> -	skcipher_request_set_crypt(req, sg, sg, sizeof(resp->encrypted), iv.x);
> -	ret = crypto_skcipher_decrypt(req);
> -	skcipher_request_zero(req);
> -
> -unlock:
> -	mutex_unlock(&rxkad_ci_mutex);
> +	fcrypt_preparekey(&cipher, session_key->x);
>  
> +	static_assert(sizeof(resp->encrypted) % FCRYPT_BSIZE == 0);
> +	fcrypt_pcbc_decrypt(&cipher, session_key->x, &resp->encrypted,
> +			    &resp->encrypted,
> +			    sizeof(resp->encrypted) / FCRYPT_BSIZE);
>  	_leave("");
> -	return ret;
>  }

Does this code leave the cryptographic key material on the stack?

The local struct fcrypt_key cipher is allocated on the stack and initialized
with the session key schedule via fcrypt_preparekey(). After the decryption is
complete, the function returns without securely erasing this key schedule from
the stack.

Could we call memzero_explicit(&cipher, sizeof(cipher)) before returning to
ensure the key material is cleared?

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

  parent reply	other threads:[~2026-10-30  4:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28  2:43 [PATCH net-next 0/5] Consolidate FCrypt and PCBC code into net/rxrpc/ Eric Biggers
2026-04-28  2:43 ` [PATCH net-next 1/5] net/rxrpc: Add local FCrypt-PCBC implementation Eric Biggers
2026-04-28  6:24   ` David Howells
2026-04-28  6:33   ` David Howells
2026-10-30  4:53   ` sashiko-bot
2026-10-30 18:13     ` Eric Biggers
2026-04-28  2:43 ` [PATCH net-next 2/5] net/rxrpc: Use " Eric Biggers
2026-05-08 18:02   ` David Howells
2026-05-08 18:23     ` Eric Biggers
2026-05-08 18:56       ` David Howells
2026-05-15 20:14         ` Eric Biggers
2026-05-15 20:58           ` David Howells
2026-10-30  4:53   ` sashiko-bot [this message]
2026-10-30 18:17     ` Eric Biggers
2026-04-28  2:43 ` [PATCH net-next 3/5] net/rxrpc: Reimplement DES-PCBC using DES library Eric Biggers
2026-10-30  4:53   ` sashiko-bot
2026-10-30 18:20     ` Eric Biggers
2026-04-28  2:43 ` [PATCH net-next 4/5] crypto: fcrypt - Remove support for FCrypt block cipher Eric Biggers
2026-04-28 10:03   ` Geert Uytterhoeven
2026-04-28  2:43 ` [PATCH net-next 5/5] crypto: pcbc - Remove support for PCBC mode Eric Biggers
2026-04-28 10:05   ` Geert Uytterhoeven
2026-04-28  7:53 ` [PATCH net-next 0/5] Consolidate FCrypt and PCBC code into net/rxrpc/ David Howells
2026-04-28 17:15 ` Marc Dionne

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-190324@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=ebiggers@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=marc.dionne@auristor.com \
    --cc=pabeni@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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