Skip to contentSkip to conversation

crypto: Fix test in get_prng_bytes()

PATCH In review Roel Kluin 3 participants 7 messages Oct 12, 2009 – Oct 27, 2009 Crypto API

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 crypto: Fix test in get_prng_bytes()

size_t nbytes cannot be less than 0.

---
Or should this test be removed?

crypto/ansi_cprng.c +1 -1
index 3aa6e38..9162456 100644
@@ -192,7 +192,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
+	if ((ssize_t)nbytes < 0)
 		return -EINVAL;
 
 	spin_lock_bh(&ctx->prng_lock);
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Roel Kluin

size_t nbytes cannot be less than 0.

---
Or should this test be removed?

crypto/ansi_cprng.c +0 -0
index 3aa6e38..9162456 100644

crypto/ansi_cprng.c static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx) · line 198

Quoted 8 lines
crypto/ansi_cprng.c +1 -1
@@ -192,7 +192,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
+	if ((ssize_t)nbytes < 0)
 		return -EINVAL;
 
 	spin_lock_bh(&ctx->prng_lock);

No, you're quite right, its a harmless, but unneeded check. Herbert, could you pull this into cryptodev please? Thank you.

Thanks for the patch Roel.

Neil

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw

On Mon, Oct 12, 2009 at 09:51:42AM -0400, Neil Horman wrote:
.

Quoted 10 lines
Quoted 10 lines

Or should this test be removed?

crypto/ansi_cprng.c +0 -0
index 3aa6e38..9162456 100644
@@ -192,7 +192,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
Quoted 7 lines

crypto/ansi_cprng.c static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx) · line 198

Quoted 5 lines
crypto/ansi_cprng.c +1 -1
-	if (nbytes < 0)
+	if ((ssize_t)nbytes < 0)
 		return -EINVAL;
 
 	spin_lock_bh(&ctx->prng_lock);

No, you're quite right, its a harmless, but unneeded check. Herbert, could you pull this into cryptodev please? Thank you.

Hmm, if it's unneeded why don't we just kill it instead?

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author Acked-by Neil Horman
#3 lore raw

Op 12-10-09 16:07, Herbert Xu schreef:

Quoted 16 lines · Neil Horman

.

Quoted 14 lines
Quoted 14 lines

Or should this test be removed?

crypto/ansi_cprng.c +1 -1
index 3aa6e38..9162456 100644
@@ -192,7 +192,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
+	if ((ssize_t)nbytes < 0)
 		return -EINVAL;
 
Quoted 5 lines
Quoted 3 lines

crypto/ansi_cprng.c static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx) · line 198

Quoted 1 line
crypto/ansi_cprng.c +0 -0
 	spin_lock_bh(&ctx->prng_lock);

No, you're quite right, its a harmless, but unneeded check. Herbert, could you pull this into cryptodev please? Thank you.

Hmm, if it's unneeded why don't we just kill it instead?

In that case:
-------------------------->8------------------8<------------------------- size_t nbytes cannot be less than 0 and the test was redundant.

---

crypto/ansi_cprng.c +0 -2
index 3aa6e38..47995ae 100644
@@ -192,9 +192,6 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
-		return -EINVAL;
Acked-by
#4 lore raw
Quoted 36 lines · Roel Kluin

Op 12-10-09 16:07, Herbert Xu schreef:

Quoted 16 lines · Neil Horman

.

Quoted 14 lines
Quoted 14 lines

Or should this test be removed?

crypto/ansi_cprng.c +1 -1
index 3aa6e38..9162456 100644
@@ -192,7 +192,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
+	if ((ssize_t)nbytes < 0)
 		return -EINVAL;
 
Quoted 5 lines
Quoted 3 lines

crypto/ansi_cprng.c static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx) · line 198

Quoted 1 line
crypto/ansi_cprng.c +0 -0
 	spin_lock_bh(&ctx->prng_lock);

No, you're quite right, its a harmless, but unneeded check. Herbert, could you pull this into cryptodev please? Thank you.

Hmm, if it's unneeded why don't we just kill it instead?

In that case:
-------------------------->8------------------8<------------------------- size_t nbytes cannot be less than 0 and the test was redundant.

---

crypto/ansi_cprng.c +0 -0
index 3aa6e38..47995ae 100644

crypto/ansi_cprng.c static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx) · line 197

Quoted 9 lines
crypto/ansi_cprng.c +0 -3
@@ -192,9 +192,6 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
-		return -EINVAL;
-
 	spin_lock_bh(&ctx->prng_lock);
 
 	err = -EINVAL;

There you go, yes :)

Neil

maintainer
#5 lore raw
Quoted 2 lines · Neil Horman

Patch applied to cryptodev. Thanks!

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#6 lore raw
In reply to Herbert Xu
Quoted 16 lines · Herbert Xu

On Mon, Oct 12, 2009 at 09:51:42AM -0400, Neil Horman wrote:
.

Quoted 14 lines
Quoted 14 lines

Or should this test be removed?

crypto/ansi_cprng.c +1 -1
index 3aa6e38..9162456 100644
@@ -192,7 +192,7 @@ static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx)
 	int err;
 
 
-	if (nbytes < 0)
+	if ((ssize_t)nbytes < 0)
 		return -EINVAL;
 
Quoted 6 lines
Quoted 3 lines

crypto/ansi_cprng.c static int get_prng_bytes(char *buf, size_t nbytes, struct prng_context *ctx) · line 198

Quoted 1 line
crypto/ansi_cprng.c +0 -0
 	spin_lock_bh(&ctx->prng_lock);

No, you're quite right, its a harmless, but unneeded check. Herbert, could you pull this into cryptodev please? Thank you.

Hmm, if it's unneeded why don't we just kill it instead?

Sorry, thats what I mean't to say. Can you kill it, or do you want a patch for it?
Neil

Quoted 7 lines

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt