All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk
@ 2014-07-10 23:18 Tim Chen
  2014-07-23 13:09 ` Herbert Xu
  2014-08-25 12:40 ` Herbert Xu
  0 siblings, 2 replies; 7+ messages in thread
From: Tim Chen @ 2014-07-10 23:18 UTC (permalink / raw)
  To: Herbert Xu, H. Peter Anvin, David S.Miller
  Cc: Chandramouli Narayanan, Tim Chen, Jussi Kivilinna, linux-crypto

For the special case when we have a null input string, we want
to initialize the entry len to 0 for the hash/ahash walk, so
cyrpto_hash_walk_last will return the correct result indicating
that we have completed the scatter list walk.  Otherwise we may
keep walking the sg list and access bogus memory address.

Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
---
 crypto/ahash.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/crypto/ahash.c b/crypto/ahash.c
index f2a5d8f..f6a36a5 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -131,8 +131,10 @@ int crypto_hash_walk_first(struct ahash_request *req,
 {
 	walk->total = req->nbytes;
 
-	if (!walk->total)
+	if (!walk->total) {
+		walk->entrylen = 0;
 		return 0;
+	}
 
 	walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
 	walk->sg = req->src;
@@ -147,8 +149,10 @@ int crypto_ahash_walk_first(struct ahash_request *req,
 {
 	walk->total = req->nbytes;
 
-	if (!walk->total)
+	if (!walk->total) {
+		walk->entrylen = 0;
 		return 0;
+	}
 
 	walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
 	walk->sg = req->src;
@@ -167,8 +171,10 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
 {
 	walk->total = len;
 
-	if (!walk->total)
+	if (!walk->total) {
+		walk->entrylen = 0;
 		return 0;
+	}
 
 	walk->alignmask = crypto_hash_alignmask(hdesc->tfm);
 	walk->sg = sg;
-- 
1.7.11.7

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

* Re: [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk
  2014-07-10 23:18 [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk Tim Chen
@ 2014-07-23 13:09 ` Herbert Xu
  2014-07-23 16:07   ` Tim Chen
  2014-08-25 12:40 ` Herbert Xu
  1 sibling, 1 reply; 7+ messages in thread
From: Herbert Xu @ 2014-07-23 13:09 UTC (permalink / raw)
  To: Tim Chen
  Cc: H. Peter Anvin, David S.Miller, Chandramouli Narayanan,
	Jussi Kivilinna, linux-crypto

On Thu, Jul 10, 2014 at 04:18:08PM -0700, Tim Chen wrote:
> For the special case when we have a null input string, we want
> to initialize the entry len to 0 for the hash/ahash walk, so
> cyrpto_hash_walk_last will return the correct result indicating
> that we have completed the scatter list walk.  Otherwise we may
> keep walking the sg list and access bogus memory address.
> 
> Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>

Sorry but which driver is broken by this?

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk
  2014-07-23 13:09 ` Herbert Xu
@ 2014-07-23 16:07   ` Tim Chen
  2014-08-01 14:18     ` Herbert Xu
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Chen @ 2014-07-23 16:07 UTC (permalink / raw)
  To: Herbert Xu
  Cc: H. Peter Anvin, David S.Miller, Chandramouli Narayanan,
	Jussi Kivilinna, linux-crypto

On Wed, 2014-07-23 at 21:09 +0800, Herbert Xu wrote:
> On Thu, Jul 10, 2014 at 04:18:08PM -0700, Tim Chen wrote:
> > For the special case when we have a null input string, we want
> > to initialize the entry len to 0 for the hash/ahash walk, so
> > cyrpto_hash_walk_last will return the correct result indicating
> > that we have completed the scatter list walk.  Otherwise we may
> > keep walking the sg list and access bogus memory address.
> > 
> > Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
> 
> Sorry but which driver is broken by this?
> 

I haven't tested other driver, but I see this problem when
I was testing the new multi-buffer sha1 driver

Tim

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

* Re: [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk
  2014-07-23 16:07   ` Tim Chen
@ 2014-08-01 14:18     ` Herbert Xu
  2014-08-11 20:32       ` Tim Chen
  0 siblings, 1 reply; 7+ messages in thread
From: Herbert Xu @ 2014-08-01 14:18 UTC (permalink / raw)
  To: Tim Chen
  Cc: H. Peter Anvin, David S.Miller, Chandramouli Narayanan,
	Jussi Kivilinna, linux-crypto

On Wed, Jul 23, 2014 at 09:07:45AM -0700, Tim Chen wrote:
> On Wed, 2014-07-23 at 21:09 +0800, Herbert Xu wrote:
> > On Thu, Jul 10, 2014 at 04:18:08PM -0700, Tim Chen wrote:
> > > For the special case when we have a null input string, we want
> > > to initialize the entry len to 0 for the hash/ahash walk, so
> > > cyrpto_hash_walk_last will return the correct result indicating
> > > that we have completed the scatter list walk.  Otherwise we may
> > > keep walking the sg list and access bogus memory address.
> > > 
> > > Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
> > 
> > Sorry but which driver is broken by this?
> > 
> 
> I haven't tested other driver, but I see this problem when
> I was testing the new multi-buffer sha1 driver

OK, I'll add this patch along with the rest of your series then.
I thought it affected existing drivers but it seems that it's
only your driver that's affected.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk
  2014-08-01 14:18     ` Herbert Xu
@ 2014-08-11 20:32       ` Tim Chen
  2014-08-12 12:00         ` Herbert Xu
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Chen @ 2014-08-11 20:32 UTC (permalink / raw)
  To: Herbert Xu
  Cc: H. Peter Anvin, David S.Miller, Chandramouli Narayanan,
	Jussi Kivilinna, linux-crypto

On Fri, 2014-08-01 at 22:18 +0800, Herbert Xu wrote:
> On Wed, Jul 23, 2014 at 09:07:45AM -0700, Tim Chen wrote:
> > On Wed, 2014-07-23 at 21:09 +0800, Herbert Xu wrote:
> > > On Thu, Jul 10, 2014 at 04:18:08PM -0700, Tim Chen wrote:
> > > > For the special case when we have a null input string, we want
> > > > to initialize the entry len to 0 for the hash/ahash walk, so
> > > > cyrpto_hash_walk_last will return the correct result indicating
> > > > that we have completed the scatter list walk.  Otherwise we may
> > > > keep walking the sg list and access bogus memory address.
> > > > 
> > > > Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
> > > 
> > > Sorry but which driver is broken by this?
> > > 
> > 
> > I haven't tested other driver, but I see this problem when
> > I was testing the new multi-buffer sha1 driver
> 
> OK, I'll add this patch along with the rest of your series then.
> I thought it affected existing drivers but it seems that it's
> only your driver that's affected.
> 
> Thanks,

Thanks Herbert.  I was out on vacation for a while.  Wonder if
you are planning to pick up the multi-buffer SHA1 series for 3.17
kernel?

Tim

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

* Re: [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk
  2014-08-11 20:32       ` Tim Chen
@ 2014-08-12 12:00         ` Herbert Xu
  0 siblings, 0 replies; 7+ messages in thread
From: Herbert Xu @ 2014-08-12 12:00 UTC (permalink / raw)
  To: Tim Chen
  Cc: H. Peter Anvin, David S.Miller, Chandramouli Narayanan,
	Jussi Kivilinna, linux-crypto

On Mon, Aug 11, 2014 at 01:32:00PM -0700, Tim Chen wrote:
>
> Thanks Herbert.  I was out on vacation for a while.  Wonder if
> you are planning to pick up the multi-buffer SHA1 series for 3.17
> kernel?

Sorry it's too late for that but I'm planning in on putting it
into cryptodev as soon as rc1 is released.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk
  2014-07-10 23:18 [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk Tim Chen
  2014-07-23 13:09 ` Herbert Xu
@ 2014-08-25 12:40 ` Herbert Xu
  1 sibling, 0 replies; 7+ messages in thread
From: Herbert Xu @ 2014-08-25 12:40 UTC (permalink / raw)
  To: Tim Chen
  Cc: H. Peter Anvin, David S.Miller, Chandramouli Narayanan,
	Jussi Kivilinna, linux-crypto

On Thu, Jul 10, 2014 at 04:18:08PM -0700, Tim Chen wrote:
> For the special case when we have a null input string, we want
> to initialize the entry len to 0 for the hash/ahash walk, so
> cyrpto_hash_walk_last will return the correct result indicating
> that we have completed the scatter list walk.  Otherwise we may
> keep walking the sg list and access bogus memory address.
> 
> Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>

Patch applied.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2014-08-25 12:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-10 23:18 [PATCH] crypto: initialize entry len for null input in crypto hash sg list walk Tim Chen
2014-07-23 13:09 ` Herbert Xu
2014-07-23 16:07   ` Tim Chen
2014-08-01 14:18     ` Herbert Xu
2014-08-11 20:32       ` Tim Chen
2014-08-12 12:00         ` Herbert Xu
2014-08-25 12:40 ` Herbert Xu

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.