All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] s390/crypto: unlock on error in prng_tdes_read()
@ 2016-11-18 11:11 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-11-18 11:11 UTC (permalink / raw)
  To: Herbert Xu, Harald Freudenberger
  Cc: David S. Miller, Martin Schwidefsky, Heiko Carstens,
	linux-crypto, linux-s390, kernel-janitors

We added some new locking but forgot to unlock on error.

Fixes: 57127645d79d ("s390/zcrypt: Introduce new SHA-512 based Pseudo Random Generator.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index 9cc050f..1113389 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -507,8 +507,10 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
 		prng_data->prngws.byte_counter += n;
 		prng_data->prngws.reseed_counter += n;
 
-		if (copy_to_user(ubuf, prng_data->buf, chunk))
-			return -EFAULT;
+		if (copy_to_user(ubuf, prng_data->buf, chunk)) {
+			ret = -EFAULT;
+			break;
+		}
 
 		nbytes -= chunk;
 		ret += chunk;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] s390/crypto: unlock on error in prng_tdes_read()
@ 2016-11-18 11:11 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-11-18 11:11 UTC (permalink / raw)
  To: Herbert Xu, Harald Freudenberger
  Cc: David S. Miller, Martin Schwidefsky, Heiko Carstens,
	linux-crypto, linux-s390, kernel-janitors

We added some new locking but forgot to unlock on error.

Fixes: 57127645d79d ("s390/zcrypt: Introduce new SHA-512 based Pseudo Random Generator.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
index 9cc050f..1113389 100644
--- a/arch/s390/crypto/prng.c
+++ b/arch/s390/crypto/prng.c
@@ -507,8 +507,10 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
 		prng_data->prngws.byte_counter += n;
 		prng_data->prngws.reseed_counter += n;
 
-		if (copy_to_user(ubuf, prng_data->buf, chunk))
-			return -EFAULT;
+		if (copy_to_user(ubuf, prng_data->buf, chunk)) {
+			ret = -EFAULT;
+			break;
+		}
 
 		nbytes -= chunk;
 		ret += chunk;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] s390/crypto: unlock on error in prng_tdes_read()
  2016-11-18 11:11 ` Dan Carpenter
@ 2016-11-18 12:12   ` Martin Schwidefsky
  -1 siblings, 0 replies; 4+ messages in thread
From: Martin Schwidefsky @ 2016-11-18 12:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Herbert Xu, Harald Freudenberger, David S. Miller,
	Heiko Carstens, linux-crypto, linux-s390, kernel-janitors

On Fri, 18 Nov 2016 14:11:00 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> We added some new locking but forgot to unlock on error.
> 
> Fixes: 57127645d79d ("s390/zcrypt: Introduce new SHA-512 based Pseudo Random Generator.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
> index 9cc050f..1113389 100644
> --- a/arch/s390/crypto/prng.c
> +++ b/arch/s390/crypto/prng.c
> @@ -507,8 +507,10 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
>  		prng_data->prngws.byte_counter += n;
>  		prng_data->prngws.reseed_counter += n;
> 
> -		if (copy_to_user(ubuf, prng_data->buf, chunk))
> -			return -EFAULT;
> +		if (copy_to_user(ubuf, prng_data->buf, chunk)) {
> +			ret = -EFAULT;
> +			break;
> +		}
> 
>  		nbytes -= chunk;
>  		ret += chunk;
> 

Nice spotting, I will add this to my fixes tree. Thank you..

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] s390/crypto: unlock on error in prng_tdes_read()
@ 2016-11-18 12:12   ` Martin Schwidefsky
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Schwidefsky @ 2016-11-18 12:12 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Herbert Xu, Harald Freudenberger, David S. Miller,
	Heiko Carstens, linux-crypto, linux-s390, kernel-janitors

On Fri, 18 Nov 2016 14:11:00 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> We added some new locking but forgot to unlock on error.
> 
> Fixes: 57127645d79d ("s390/zcrypt: Introduce new SHA-512 based Pseudo Random Generator.")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c
> index 9cc050f..1113389 100644
> --- a/arch/s390/crypto/prng.c
> +++ b/arch/s390/crypto/prng.c
> @@ -507,8 +507,10 @@ static ssize_t prng_tdes_read(struct file *file, char __user *ubuf,
>  		prng_data->prngws.byte_counter += n;
>  		prng_data->prngws.reseed_counter += n;
> 
> -		if (copy_to_user(ubuf, prng_data->buf, chunk))
> -			return -EFAULT;
> +		if (copy_to_user(ubuf, prng_data->buf, chunk)) {
> +			ret = -EFAULT;
> +			break;
> +		}
> 
>  		nbytes -= chunk;
>  		ret += chunk;
> 

Nice spotting, I will add this to my fixes tree. Thank you..

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-11-18 12:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-18 11:11 [patch] s390/crypto: unlock on error in prng_tdes_read() Dan Carpenter
2016-11-18 11:11 ` Dan Carpenter
2016-11-18 12:12 ` Martin Schwidefsky
2016-11-18 12:12   ` Martin Schwidefsky

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.