lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <870327e4-2391-4f42-82ad-2d9593a70ebe@bytedance.com>
Date: Sat, 12 Oct 2024 16:24:01 +0800
From: zhenwei pi <pizhenwei@...edance.com>
To: Markus Elfring <Markus.Elfring@....de>, Gonglei <arei.gonglei@...wei.com>
Cc: LKML <linux-kernel@...r.kernel.org>, linux-crypto@...r.kernel.org,
 "Michael S. Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
 Xuan Zhuo <xuanzhuo@...ux.alibaba.com>, Nathan Chancellor
 <nathan@...nel.org>, virtualization@...ts.linux.dev,
 lei he <helei.sig11@...edance.com>, Herbert Xu
 <herbert@...dor.apana.org.au>, Eugenio Pérez
 <eperezma@...hat.com>, "David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH] crypto: virtio/akcipher - Move a pointer assignment in
 virtio_crypto_rsa_set_key()



On 10/12/24 16:06, Markus Elfring wrote:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Sat, 12 Oct 2024 09:51:58 +0200
> 
> Move the reset of the data structure member “n” to a null pointer
> into an if branch so that this assignment will be performed only after
> a key parsing failure.
> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>   drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
> index 48fee07b7e51..56557d4778b0 100644
> --- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
> +++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c
> @@ -355,7 +355,6 @@ static int virtio_crypto_rsa_set_key(struct crypto_akcipher *tfm,
> 
>   	/* mpi_free will test n, just free it. */
>   	mpi_free(rsa_ctx->n);
> -	rsa_ctx->n = NULL;
> 
>   	if (private) {
>   		keytype = VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE;
> @@ -365,8 +364,10 @@ static int virtio_crypto_rsa_set_key(struct crypto_akcipher *tfm,
>   		ret = rsa_parse_pub_key(&rsa_key, key, keylen);
>   	}
> 
> -	if (ret)
> +	if (ret) {
> +		rsa_ctx->n = NULL;
>   		return ret;
> +	}
> 
>   	rsa_ctx->n = mpi_read_raw_data(rsa_key.n, rsa_key.n_sz);
>   	if (!rsa_ctx->n)
> --

Hi,

This change only reduces a single assignment on a key parsing failure, 
however it breaks the original "free a pointer, and set it to NULL".
I prefer the original style.

Lei, what's your opinion?


> 2.46.1
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ