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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180529163400.GA166256@gmail.com>
Date:   Tue, 29 May 2018 09:34:00 -0700
From:   Eric Biggers <ebiggers3@...il.com>
To:     Nick Desaulniers <nick.desaulniers@...il.com>
Cc:     herbert@...dor.apana.org.au, davem@...emloft.net,
        linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] crypto: blkcipher: prefer strlcpy to strncpy

On Mon, May 28, 2018 at 10:44:43PM -0700, Nick Desaulniers wrote:
> Fixes stringop-truncation warnings from gcc-8.
> 
> Signed-off-by: Nick Desaulniers <nick.desaulniers@...il.com>
> ---
>  crypto/ablkcipher.c | 8 ++++----
>  crypto/blkcipher.c  | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
> index d880a48..e38867f 100644
> --- a/crypto/ablkcipher.c
> +++ b/crypto/ablkcipher.c
> @@ -370,8 +370,8 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
>  {
>  	struct crypto_report_blkcipher rblkcipher;
>  
> -	strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type));
> -	strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<default>",
> +	strlcpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type));
> +	strlcpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<default>",
>  		sizeof(rblkcipher.geniv));
>  
>  	rblkcipher.blocksize = alg->cra_blocksize;
> @@ -444,8 +444,8 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
>  {
>  	struct crypto_report_blkcipher rblkcipher;
>  
> -	strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type));
> -	strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>",
> +	strlcpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type));
> +	strlcpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>",
>  		sizeof(rblkcipher.geniv));
>  
>  	rblkcipher.blocksize = alg->cra_blocksize;
> diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
> index 01c0d4a..ee88e48 100644
> --- a/crypto/blkcipher.c
> +++ b/crypto/blkcipher.c
> @@ -509,8 +509,8 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
>  {
>  	struct crypto_report_blkcipher rblkcipher;
>  
> -	strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type));
> -	strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "<default>",
> +	strlcpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type));
> +	strlcpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "<default>",
>  		sizeof(rblkcipher.geniv));
>  
>  	rblkcipher.blocksize = alg->cra_blocksize;
> -- 
> 2.7.4
> 

Hi Nick, this patch is wrong.  The 'struct crypto_report_blkcipher' is being
copied to userspace via netlink, so all bytes of it must be initialized.
strncpy() does this but strlcpy() does not.

I noticed that you're sending out some other patches replacing strncpy() with
strlcpy() too.  Can you please double check them for this same bug?

Thanks,

- Eric

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ