Re: [PATCH] crypto: use two-argument strscpy where destination size is known
From: Tom Lendacky
Date: Tue Jun 02 2026 - 16:59:09 EST
On 6/2/26 15:50, Thorsten Blum wrote:
> Hi Tom,
>
> On Tue, Jun 02, 2026 at 03:24:06PM -0500, Tom Lendacky wrote:
>> On 5/25/26 05:30, Thorsten Blum wrote:
>>> To simplify the code, drop explicit and hard-coded size arguments from
>>> strscpy() where the destination buffer has a fixed size and strscpy()
>>> can automatically determine it using sizeof().
>>>
>>> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxx>
>>
>> For the CCP driver changes:
>>
>> Reviewed-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
>
> Thanks.
>
>> But I noticed that there are a few other places in the driver that I think
>> can be changed to use the two argument strscpy - essentially the strscpy's
>> that involve "cra_name" and "cra_driver_name" in
>> drivers/crypto/ccp/{ccp-crypto-aes-galois.c,ccp-crypto-aes-xts.c,ccp-crypto-aes.c,ccp-crypto-des3.c,ccp-crypto-rsa.c,ccp-crypto-sha.c}.
>
> They already use the 2-arg strscpy(), except for the one in this patch:
>
> $ git grep -n strscpy drivers/crypto/ccp/
> drivers/crypto/ccp/ccp-crypto-aes-galois.c:227: strscpy(alg->base.cra_name, def->name);
> drivers/crypto/ccp/ccp-crypto-aes-galois.c:228: strscpy(alg->base.cra_driver_name, def->driver_name);
> drivers/crypto/ccp/ccp-crypto-aes-xts.c:243: strscpy(alg->base.cra_name, def->name);
> drivers/crypto/ccp/ccp-crypto-aes-xts.c:244: strscpy(alg->base.cra_driver_name, def->drv_name);
> drivers/crypto/ccp/ccp-crypto-aes.c:311: strscpy(alg->base.cra_name, def->name);
> drivers/crypto/ccp/ccp-crypto-aes.c:312: strscpy(alg->base.cra_driver_name, def->driver_name);
> drivers/crypto/ccp/ccp-crypto-des3.c:196: strscpy(alg->base.cra_name, def->name);
> drivers/crypto/ccp/ccp-crypto-des3.c:197: strscpy(alg->base.cra_driver_name, def->driver_name);
> drivers/crypto/ccp/ccp-crypto-rsa.c:261: strscpy(alg->base.cra_name, def->name);
> drivers/crypto/ccp/ccp-crypto-rsa.c:262: strscpy(alg->base.cra_driver_name, def->driver_name);
> drivers/crypto/ccp/ccp-crypto-sha.c:429: strscpy(ccp_alg->child_alg, def->name, CRYPTO_MAX_ALG_NAME);
> drivers/crypto/ccp/ccp-crypto-sha.c:487: strscpy(base->cra_name, def->name);
> drivers/crypto/ccp/ccp-crypto-sha.c:488: strscpy(base->cra_driver_name, def->drv_name);
Gah, I was looking at an old tree. Sorry for the noise.
Thanks,
Tom