Skip to contentSkip to conversation

crypto: Fix scatterwalk_done() test.

PATCH In review David Miller 2 participants 3 messages May 18, 2010 – May 19, 2010 Crypto API

lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

PATCH 2/6 crypto: Fix scatterwalk_done() test.

We are done with the scattergather entry when the walk offset goes past sg->offset + sg->length, not when it crosses a page boundary.

There is a similarly queer test in the second half of scatterwalk_pagedone() that probably needs some scrutiny.

---
 crypto/scatterwalk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
crypto/scatterwalk.c +1 -1
index 3de89a4..b3acf4f 100644
@@ -68,7 +68,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
 
 void scatterwalk_done(struct scatter_walk *walk, int out, int more)
 {
-	if (!offset_in_page(walk->offset) || !more)
+	if (walk->offset >= walk->sg->offset + walk->sg->length || !more)
 		scatterwalk_pagedone(walk, out, more);
 }
 EXPORT_SYMBOL_GPL(scatterwalk_done);
Signature · 1 line
1.7.0.4
maintainer
#1 lore raw
Quoted 3 lines · David Miller

We are done with the scattergather entry when the walk offset goes past sg->offset + sg->length, not when it crosses a page boundary.

Thanks for catching this!

Quoted 2 lines

There is a similarly queer test in the second half of scatterwalk_pagedone() that probably needs some scrutiny.

I double-checked that one but can't see any problems yet.

crypto/scatterwalk.c static void scatterwalk_pagedone(struct scatter_walk *walk, int out, · line 72

Quoted 11 lines
crypto/scatterwalk.c +1 -1
index 3de89a4..b3acf4f 100644
@@ -68,7 +68,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
 
 void scatterwalk_done(struct scatter_walk *walk, int out, int more)
 {
-	if (!offset_in_page(walk->offset) || !more)
+	if (walk->offset >= walk->sg->offset + walk->sg->length || !more)
 		scatterwalk_pagedone(walk, out, more);

I think we need to keep the original test as well as otherwise if we hit a page boundary while the sg spans over a page (that can happen with a linearised jumbo skb->head for example) then we'd be screwed.

So I'm going to commit this patch instead. Let me know if you see any other issues with it.

crypto/scatterwalk.c +1 -1
index 3de89a4..41e529a 100644
@@ -68,7 +68,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
 
 void scatterwalk_done(struct scatter_walk *walk, int out, int more)
 {
-	if (!offset_in_page(walk->offset) || !more)
+	if (!(scatterwalk_pagelen(walk) & (PAGE_SIZE - 1)) || !more)
 		scatterwalk_pagedone(walk, out, more);
 }
 EXPORT_SYMBOL_GPL(scatterwalk_done);

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