crypto: shash - fix missed optimization in shash_ahash_digest()
authorEric Biggers <ebiggers@google.com>
Sun, 14 Apr 2019 23:23:33 +0000 (16:23 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 18 Apr 2019 14:15:04 +0000 (22:15 +0800)
shash_ahash_digest(), which is the ->digest() method for ahash tfms that
use an shash algorithm, has an optimization where crypto_shash_digest()
is called if the data is in a single page.  But an off-by-one error
prevented this path from being taken unless the user happened to provide
extra data in the scatterlist.  Fix it.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/shash.c

index 15b369c4745f6e6d7cfd10a5caaf17f20dc93c32..b85930e9a7a2e075fc332f80b56d0a70be918681 100644 (file)
@@ -307,7 +307,7 @@ int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
 
        if (nbytes &&
            (sg = req->src, offset = sg->offset,
-            nbytes < min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset))) {
+            nbytes <= min(sg->length, ((unsigned int)(PAGE_SIZE)) - offset))) {
                void *data;
 
                data = kmap_atomic(sg_page(sg));