Commit 033f46b3 authored by tadeusz.struk@intel.com's avatar tadeusz.struk@intel.com Committed by David S. Miller

crypto: algif - explicitly mark end of data

After the TX sgl is expanded we need to explicitly mark end of data
at the last buffer that contains data.

Changes in v2
 - use type 'bool' and true/false for 'mark'.
Signed-off-by: default avatarTadeusz Struk <tadeusz.struk@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 99949a74
...@@ -509,11 +509,11 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, ...@@ -509,11 +509,11 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
struct skcipher_async_req *sreq; struct skcipher_async_req *sreq;
struct ablkcipher_request *req; struct ablkcipher_request *req;
struct skcipher_async_rsgl *last_rsgl = NULL; struct skcipher_async_rsgl *last_rsgl = NULL;
unsigned int len = 0, tx_nents = skcipher_all_sg_nents(ctx); unsigned int txbufs = 0, len = 0, tx_nents = skcipher_all_sg_nents(ctx);
unsigned int reqlen = sizeof(struct skcipher_async_req) + unsigned int reqlen = sizeof(struct skcipher_async_req) +
GET_REQ_SIZE(ctx) + GET_IV_SIZE(ctx); GET_REQ_SIZE(ctx) + GET_IV_SIZE(ctx);
int i = 0;
int err = -ENOMEM; int err = -ENOMEM;
bool mark = false;
lock_sock(sk); lock_sock(sk);
req = kmalloc(reqlen, GFP_KERNEL); req = kmalloc(reqlen, GFP_KERNEL);
...@@ -555,7 +555,7 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, ...@@ -555,7 +555,7 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
iov_iter_count(&msg->msg_iter)); iov_iter_count(&msg->msg_iter));
used = min_t(unsigned long, used, sg->length); used = min_t(unsigned long, used, sg->length);
if (i == tx_nents) { if (txbufs == tx_nents) {
struct scatterlist *tmp; struct scatterlist *tmp;
int x; int x;
/* Ran out of tx slots in async request /* Ran out of tx slots in async request
...@@ -573,10 +573,11 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, ...@@ -573,10 +573,11 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
kfree(sreq->tsg); kfree(sreq->tsg);
sreq->tsg = tmp; sreq->tsg = tmp;
tx_nents *= 2; tx_nents *= 2;
mark = true;
} }
/* Need to take over the tx sgl from ctx /* Need to take over the tx sgl from ctx
* to the asynch req - these sgls will be freed later */ * to the asynch req - these sgls will be freed later */
sg_set_page(sreq->tsg + i++, sg_page(sg), sg->length, sg_set_page(sreq->tsg + txbufs++, sg_page(sg), sg->length,
sg->offset); sg->offset);
if (list_empty(&sreq->list)) { if (list_empty(&sreq->list)) {
...@@ -604,6 +605,9 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, ...@@ -604,6 +605,9 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg,
iov_iter_advance(&msg->msg_iter, used); iov_iter_advance(&msg->msg_iter, used);
} }
if (mark)
sg_mark_end(sreq->tsg + txbufs - 1);
ablkcipher_request_set_crypt(req, sreq->tsg, sreq->first_sgl.sgl.sg, ablkcipher_request_set_crypt(req, sreq->tsg, sreq->first_sgl.sgl.sg,
len, sreq->iv); len, sreq->iv);
err = ctx->enc ? crypto_ablkcipher_encrypt(req) : err = ctx->enc ? crypto_ablkcipher_encrypt(req) :
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment