From patchwork Thu Oct 17 12:25:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 176574 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp847811ill; Thu, 17 Oct 2019 05:26:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVUgX7kiEeTK36MYlMeR/qbxwE/dTeMkkWz8aB4tnrqKbtcY76f1+HobVO5zkA3xIVyA4H X-Received: by 2002:aa7:dd0a:: with SMTP id i10mr3387474edv.189.1571315185566; Thu, 17 Oct 2019 05:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571315185; cv=none; d=google.com; s=arc-20160816; b=p4GI7a7tLa7u+dcinQjRbrSPcUF6KA+ccIfXqd2qmq0e+IDoc0Q9FXAdo83kKeHmn/ PnN2QErE+f7ogKNVVu3bL8f3L0SpEFYKF+d/kaW2O6a0OnnWUWBA7uXsPD17gW+0q4W5 vyGw19ZL1dLjNfDjkUEBbQKJ9P6HIezr2B/EqqcxrCtt/B73arKH3pYV/VEZyVuoNZrb 3Fr7xY4P3Uv5/5sCfEvUI1p0mdj7bO/irqjxWJMmLKAkMC+oV8vmRKVZYWWZEprRv9j5 sTzuyLwOnGmt54C1DajfvY43XXRumOtTH3V/wGlnbjfk+kDgHjza7Z/vclfrB7W2r0df iyoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=/548IYlsZzVpGFlUyLpuldMg6WhApejqtJF4qdDLFY8=; b=weVfJ/f9Gt8Vd7Gv+SAuJR3skBm9ySPL2Zx3tiM211BS9IHTWHvfNzz7Wnl2VgWg6N ZjADTlYuvAw/PHIsyTdMuCo5/A4+Q12zSRkxdYtDBtI7x26fJSC7YfUagfyZdLk40dXQ zb6C1aG8zGaL6OXr7ZkYO6/4eWwKziX8QHfP0R/wl9+HGBTQN1EyiwuASgSQGtcXWVtP 1f/6/JBshWF1qnSc91wXA7/qzu9YQ2z5XsF/5cvnDUMWs8wAoMPxao9a59M/AUQji9Cr mYE9hPh77eQi2NjONsrcSKSMeptrv3LXkovELaoD/W4B2/T0GzjxH2MWgqSFHy0pWACe 7A/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=FSCP1gxG; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ot22si1288436ejb.153.2019.10.17.05.26.25; Thu, 17 Oct 2019 05:26:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=FSCP1gxG; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502305AbfJQM0Y (ORCPT + 3 others); Thu, 17 Oct 2019 08:26:24 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:50398 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409377AbfJQM0X (ORCPT ); Thu, 17 Oct 2019 08:26:23 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9HCQE24084614; Thu, 17 Oct 2019 07:26:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1571315174; bh=/548IYlsZzVpGFlUyLpuldMg6WhApejqtJF4qdDLFY8=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=FSCP1gxGgF0OIz9XnlIfJWQr2ZVvUsB50V54Y+CK+gsqhBp3UnfAl/fUICNx/x7fM DFDLNW8+slMGMe3ZLaOaz62HUigsONZxBpH+ifQJCryxE5Qz1DWww6EOFotvaiCp6T fm+KNqka2JkfjYqdtkDwy1A60Tpl6JI5uXeuyQQ4= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9HCQEJp075376 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 Oct 2019 07:26:14 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 17 Oct 2019 07:26:06 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 17 Oct 2019 07:26:13 -0500 Received: from sokoban.bb.dnainternet.fi (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9HCPxNc073246; Thu, 17 Oct 2019 07:26:12 -0500 From: Tero Kristo To: , , , CC: , Subject: [PATCH 07/10] crypto: omap-aes-gcm: fix corner case with only auth data Date: Thu, 17 Oct 2019 15:25:46 +0300 Message-ID: <20191017122549.4634-8-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017122549.4634-1-t-kristo@ti.com> References: <20191017122549.4634-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Fix a corner case where only authdata is generated, without any provided assocdata / cryptdata. Passing the empty scatterlists to OMAP AES core driver in this case would confuse it, failing to map DMAs. Signed-off-by: Tero Kristo --- drivers/crypto/omap-aes-gcm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/crypto/omap-aes-gcm.c b/drivers/crypto/omap-aes-gcm.c index 9bbedbccfadf..dfd4d1cac421 100644 --- a/drivers/crypto/omap-aes-gcm.c +++ b/drivers/crypto/omap-aes-gcm.c @@ -148,12 +148,14 @@ static int omap_aes_gcm_copy_buffers(struct omap_aes_dev *dd, if (req->src == req->dst || dd->out_sg == sg_arr) flags |= OMAP_CRYPTO_FORCE_COPY; - ret = omap_crypto_align_sg(&dd->out_sg, cryptlen, - AES_BLOCK_SIZE, &dd->out_sgl, - flags, - FLAGS_OUT_DATA_ST_SHIFT, &dd->flags); - if (ret) - return ret; + if (cryptlen) { + ret = omap_crypto_align_sg(&dd->out_sg, cryptlen, + AES_BLOCK_SIZE, &dd->out_sgl, + flags, + FLAGS_OUT_DATA_ST_SHIFT, &dd->flags); + if (ret) + return ret; + } dd->in_sg_len = sg_nents_for_len(dd->in_sg, alen + clen); dd->out_sg_len = sg_nents_for_len(dd->out_sg, clen); @@ -287,8 +289,12 @@ static int omap_aes_gcm_handle_queue(struct omap_aes_dev *dd, return err; err = omap_aes_write_ctrl(dd); - if (!err) - err = omap_aes_crypt_dma_start(dd); + if (!err) { + if (dd->in_sg_len && dd->out_sg_len) + err = omap_aes_crypt_dma_start(dd); + else + omap_aes_gcm_dma_out_callback(dd); + } if (err) { omap_aes_gcm_finish_req(dd, err);