From: Clay Haapala <chaapala@cisco.com>
To: linux-kernel@vger.kernel.org
Cc: "David S. Miller" <davem@redhat.com>, James Morris <jmorris@redhat.com>
Subject: [PATCH] Fix Crypto digest.c kmapping sg entries > page in length
Date: Mon, 07 Jun 2004 15:43:27 -0500 [thread overview]
Message-ID: <yqujwu2jm74g.fsf@chaapala-lnx2.cisco.com> (raw)
In-Reply-To: <Xine.LNX.4.44.0406041921180.14838-100000@thoron.boston.redhat.com> (James Morris's message of "Fri, 4 Jun 2004 19:21:30 -0400 (EDT)")
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>.
--
Clay Haapala (chaapala@cisco.com) Cisco Systems SRBU +1 763-398-1056
6450 Wedgwood Rd, Suite 130 Maple Grove MN 55311 PGP: C89240AD
"We're serious about this campaign now! The training wheels are coming off!"
- a high White Horse Souse
Signed-off-by: Clay Haapala <chaapala@cisco.com>
diff -uNr --exclude=SCCS --exclude '*.mod.c' --exclude='*.o' --exclude='*.ko' --exclude '.*' linux-2.6.6-bk.orig/crypto/digest.c linux-2.6.6-bk/crypto/digest.c
--- linux-2.6.6-bk.orig/crypto/digest.c 2004-06-07 10:58:36.000000000 -0500
+++ linux-2.6.6-bk/crypto/digest.c 2004-06-07 15:21:05.000000000 -0500
@@ -27,13 +27,28 @@
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);
}
}
next prev parent reply other threads:[~2004-06-07 20:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-04 18:50 Crypto digests and kmapping sg entries larger than a page, with [PATCH] Clay Haapala
2004-06-04 23:21 ` James Morris
2004-06-07 20:43 ` Clay Haapala [this message]
2004-06-11 4:57 ` [PATCH] Fix Crypto digest.c kmapping sg entries > page in length David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yqujwu2jm74g.fsf@chaapala-lnx2.cisco.com \
--to=chaapala@cisco.com \
--cc=davem@redhat.com \
--cc=jmorris@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®