diff options
author | Clay Haapala <chaapala@cisco.com> | 2004-06-10 07:58:26 -0700 |
---|---|---|
committer | David S. Miller <davem@nuts.davemloft.net> | 2004-06-10 07:58:26 -0700 |
commit | 1e4b22635d69586d49c7e2fa2b24fd991b4c3922 (patch) | |
tree | 59bb72335778fa708566815c8bbaad2096fc7b34 /crypto | |
parent | 65cfd02740fa2081c27ba778ff0bfabdbebb1b89 (diff) | |
download | history-1e4b22635d69586d49c7e2fa2b24fd991b4c3922.tar.gz |
[CRYPTO]: Fix digest.c kmapping sg entries > page in length.
Below is the patch, against 2.6.7-rc2, to fix crypto/digest.c to do
multiple kmap()/kunmap() for scatterlist entries which have a size
greater than a single page, originally found and fixed by
N.C.Krishna Murthy <krmurthy@cisco.com>.
Signed-off-by: Clay Haapala <chaapala@cisco.com>
Signed-off-by: David S. Miller <davem@redhat.com>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/digest.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/crypto/digest.c b/crypto/digest.c index 30dabe203d30e7..d9b6ac9dbf8d08 100644 --- a/crypto/digest.c +++ b/crypto/digest.c @@ -27,13 +27,28 @@ static void update(struct crypto_tfm *tfm, struct scatterlist *sg, unsigned int nsg) { unsigned int i; - + for (i = 0; i < nsg; i++) { - char *p = crypto_kmap(sg[i].page, 0) + sg[i].offset; - tfm->__crt_alg->cra_digest.dia_update(crypto_tfm_ctx(tfm), - p, sg[i].length); - crypto_kunmap(p, 0); - crypto_yield(tfm); + + struct page *pg = sg[i].page; + unsigned int offset = sg[i].offset; + unsigned int l = sg[i].length; + + do { + unsigned int bytes_from_page = min(l, ((unsigned int) + (PAGE_SIZE)) - + offset); + char *p = crypto_kmap(pg, 0) + offset; + + tfm->__crt_alg->cra_digest.dia_update + (crypto_tfm_ctx(tfm), p, + bytes_from_page); + crypto_kunmap(p, 0); + crypto_yield(tfm); + offset = 0; + pg++; + l -= bytes_from_page; + } while (l > 0); } } |