2009-10-12 13:00:30

by Roel Kluin

[permalink] [raw]
Subject: [PATCH] crypto: Fix test in get_prng_bytes()

size_t nbytes cannot be less than 0.

Signed-off-by: Roel Kluin <[email protected]>
---
Or should this test be removed?

diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 3aa6e38..9162456 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -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);


2009-10-12 13:52:29

by Neil Horman

[permalink] [raw]
Subject: Re: [PATCH] crypto: Fix test in get_prng_bytes()

On Mon, Oct 12, 2009 at 03:09:09PM +0200, Roel Kluin wrote:
> size_t nbytes cannot be less than 0.
>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> Or should this test be removed?
>
> diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
> index 3aa6e38..9162456 100644
> --- a/crypto/ansi_cprng.c
> +++ b/crypto/ansi_cprng.c
> @@ -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.

Acked-by: Neil Horman <[email protected]>

Neil

> --
> 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
>

2009-10-12 14:08:41

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: Fix test in get_prng_bytes()

On Mon, Oct 12, 2009 at 09:51:42AM -0400, Neil Horman wrote:
.
> > Or should this test be removed?
> >
> > diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
> > index 3aa6e38..9162456 100644
> > --- a/crypto/ansi_cprng.c
> > +++ b/crypto/ansi_cprng.c
> > @@ -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.

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

Thanks,
--
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

2009-10-12 14:13:28

by Roel Kluin

[permalink] [raw]
Subject: Re: [PATCH] crypto: Fix test in get_prng_bytes()

Op 12-10-09 16:07, Herbert Xu schreef:
> On Mon, Oct 12, 2009 at 09:51:42AM -0400, Neil Horman wrote:
> .
>>> Or should this test be removed?
>>>
>>> diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
>>> index 3aa6e38..9162456 100644
>>> --- a/crypto/ansi_cprng.c
>>> +++ b/crypto/ansi_cprng.c
>>> @@ -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.
>
> 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.

Acked-by: Neil Horman <[email protected]>
Signed-off-by: Roel Kluin <[email protected]>
---
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index 3aa6e38..47995ae 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -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;

2009-10-12 14:29:16

by Neil Horman

[permalink] [raw]
Subject: Re: [PATCH] crypto: Fix test in get_prng_bytes()

On Mon, Oct 12, 2009 at 11:07:53PM +0900, Herbert Xu wrote:
> On Mon, Oct 12, 2009 at 09:51:42AM -0400, Neil Horman wrote:
> .
> > > Or should this test be removed?
> > >
> > > diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
> > > index 3aa6e38..9162456 100644
> > > --- a/crypto/ansi_cprng.c
> > > +++ b/crypto/ansi_cprng.c
> > > @@ -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.
>
> 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

> Thanks,
> --
> 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
>

2009-10-12 14:29:53

by Neil Horman

[permalink] [raw]
Subject: Re: [PATCH] crypto: Fix test in get_prng_bytes()

On Mon, Oct 12, 2009 at 04:22:05PM +0200, Roel Kluin wrote:
> Op 12-10-09 16:07, Herbert Xu schreef:
> > On Mon, Oct 12, 2009 at 09:51:42AM -0400, Neil Horman wrote:
> > .
> >>> Or should this test be removed?
> >>>
> >>> diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
> >>> index 3aa6e38..9162456 100644
> >>> --- a/crypto/ansi_cprng.c
> >>> +++ b/crypto/ansi_cprng.c
> >>> @@ -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.
> >
> > 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.
>
> Acked-by: Neil Horman <[email protected]>
> Signed-off-by: Roel Kluin <[email protected]>
> ---
> diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
> index 3aa6e38..47995ae 100644
> --- a/crypto/ansi_cprng.c
> +++ b/crypto/ansi_cprng.c
> @@ -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 :)
Acked-by: Neil Horman <[email protected]>
Neil


2009-10-27 10:52:09

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: Fix test in get_prng_bytes()

On Mon, Oct 12, 2009 at 10:29:08AM -0400, Neil Horman wrote:
>
> Acked-by: Neil Horman <[email protected]>

Patch applied to cryptodev. Thanks!
--
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