From: Tadeusz Struk <tadeusz.struk@intel.com>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, davem@davemloft.net
Subject: [PATCH] crypto: algif - Mark sgl end at the end of data.
Date: Fri, 21 Nov 2014 09:14:06 -0800 [thread overview]
Message-ID: <20141121171406.1147.31491.stgit@tstruk-mobl1> (raw)
Hi,
algif_skcipher sends 127 sgl buffers for encryption regardless of how many
buffers acctually have data to process, where the few first with valid len
and the rest with zero len. This is not very eficient and may cause problems
when algs do something like this without checking the buff lenght:
for_each_sg(sgl, sg, sg_nents, i)
sg_virt(sg)
This patch marks the last one with data as the last one to process.
Also removed some unneeded code.
Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com>
---
crypto/algif_skcipher.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 85e3bdb..e393c71 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -359,8 +359,6 @@ static int skcipher_sendmsg(struct kiocb *unused, struct socket *sock,
err = 0;
ctx->more = msg->msg_flags & MSG_MORE;
- if (!ctx->more && !list_empty(&ctx->tsgl))
- sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
unlock:
skcipher_data_wakeup(sk);
@@ -408,9 +406,6 @@ static ssize_t skcipher_sendpage(struct socket *sock, struct page *page,
done:
ctx->more = flags & MSG_MORE;
- if (!ctx->more && !list_empty(&ctx->tsgl))
- sgl = list_entry(ctx->tsgl.prev, struct skcipher_sg_list, list);
-
unlock:
skcipher_data_wakeup(sk);
release_sock(sk);
@@ -469,6 +464,7 @@ static int skcipher_recvmsg(struct kiocb *unused, struct socket *sock,
if (!used)
goto free;
+ sg_mark_end(&sg[sgl->cur - 1]);
ablkcipher_request_set_crypt(&ctx->req, sg,
ctx->rsgl.sg, used,
ctx->iv);
next reply other threads:[~2014-11-21 17:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-21 17:14 Tadeusz Struk [this message]
2014-11-25 14:42 ` [PATCH] crypto: algif - Mark sgl end at the end of data Herbert Xu
2014-11-25 15:53 ` Tadeusz Struk
-- strict thread matches above, loose matches on Subject: below --
2014-11-28 18:40 Tadeusz Struk
2014-12-01 14:40 ` Herbert Xu
2014-12-01 14:53 ` Tadeusz Struk
2014-12-01 15:00 ` Herbert Xu
2014-12-01 15:03 ` Tadeusz Struk
2014-12-02 14:33 ` Herbert Xu
2014-12-02 15:06 ` Tadeusz Struk
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=20141121171406.1147.31491.stgit@tstruk-mobl1 \
--to=tadeusz.struk@intel.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@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