From patchwork Wed Apr 1 20:53:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tadeusz Struk X-Patchwork-Id: 6142211 Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2E2FE9F1BE for ; Wed, 1 Apr 2015 20:56:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F2CF202C8 for ; Wed, 1 Apr 2015 20:55:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3675C20131 for ; Wed, 1 Apr 2015 20:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbbDAUzz (ORCPT ); Wed, 1 Apr 2015 16:55:55 -0400 Received: from mga14.intel.com ([192.55.52.115]:34226 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752220AbbDAUzy (ORCPT ); Wed, 1 Apr 2015 16:55:54 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 01 Apr 2015 13:55:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,506,1422950400"; d="scan'208";a="707578486" Received: from bjesteba-mobl1.amr.corp.intel.com (HELO [127.0.1.1]) ([10.252.207.181]) by orsmga002.jf.intel.com with ESMTP; 01 Apr 2015 13:55:54 -0700 Subject: [PATCH v2 net-next] crypto: algif - explicitly mark end of data To: davem@davemloft.net From: Tadeusz Struk Cc: netdev@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au Date: Wed, 01 Apr 2015 13:53:06 -0700 Message-ID: <20150401205305.22123.71178.stgit@tstruk-mobl1> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Tadeusz Struk --- crypto/algif_skcipher.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 8276f21..5eff93f 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c @@ -509,11 +509,11 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, struct skcipher_async_req *sreq; struct ablkcipher_request *req; 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) + GET_REQ_SIZE(ctx) + GET_IV_SIZE(ctx); - int i = 0; int err = -ENOMEM; + bool mark = false; lock_sock(sk); req = kmalloc(reqlen, GFP_KERNEL); @@ -555,7 +555,7 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, iov_iter_count(&msg->msg_iter)); used = min_t(unsigned long, used, sg->length); - if (i == tx_nents) { + if (txbufs == tx_nents) { struct scatterlist *tmp; int x; /* Ran out of tx slots in async request @@ -573,10 +573,11 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, kfree(sreq->tsg); sreq->tsg = tmp; tx_nents *= 2; + mark = true; } /* Need to take over the tx sgl from ctx * 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); if (list_empty(&sreq->list)) { @@ -604,6 +605,9 @@ static int skcipher_recvmsg_async(struct socket *sock, struct msghdr *msg, 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, len, sreq->iv); err = ctx->enc ? crypto_ablkcipher_encrypt(req) :