From patchwork Thu Jul 30 13:39:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Horia_Geant=C4=83?= X-Patchwork-Id: 6902611 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 6FF219F39D for ; Thu, 30 Jul 2015 13:40:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7622A205B9 for ; Thu, 30 Jul 2015 13:39:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A12CD205B8 for ; Thu, 30 Jul 2015 13:39:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751888AbbG3Nj4 (ORCPT ); Thu, 30 Jul 2015 09:39:56 -0400 Received: from mail-by2on0110.outbound.protection.outlook.com ([207.46.100.110]:30421 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750910AbbG3Nj4 (ORCPT ); Thu, 30 Jul 2015 09:39:56 -0400 Received: from BY2PR03CA003.namprd03.prod.outlook.com (10.255.93.20) by BY2PR0301MB1607.namprd03.prod.outlook.com (10.163.28.25) with Microsoft SMTP Server (TLS) id 15.1.225.19; Thu, 30 Jul 2015 13:39:54 +0000 Received: from BL2FFO11FD037.protection.gbl (10.255.93.4) by BY2PR03CA003.outlook.office365.com (10.255.93.20) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Thu, 30 Jul 2015 13:39:53 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD037.mail.protection.outlook.com (10.173.161.133) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Thu, 30 Jul 2015 13:39:53 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t6UDdpRR010358; Thu, 30 Jul 2015 06:39:52 -0700 From: =?UTF-8?q?Horia=20Geant=C4=83?= To: Herbert Xu CC: , Tudor Ambarus Subject: [PATCH] crypto: caam - fix rfc4106 encap shared descriptor Date: Thu, 30 Jul 2015 16:39:26 +0300 Message-ID: <1438263566-22222-1-git-send-email-horia.geanta@freescale.com> X-Mailer: git-send-email 2.4.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD037; 1:YjqFqK3DtJEjEedOV+fPyFYGT4FddTPgbAnHislJkU+V9IFERX0HXlZ7zf2qu96Vj1vv/7FFx7obsLyyw0V59vg9xLx5ByLJk4oFF/tIoeueT4qjvaCD/YKd39dfts4UD0uPckCJPq9meQP+U4uq6EdDMe3wOviFWfxsH9pI88RedKbqzhdAq7hFfD9TB2jqTy/Wg69aTWh/GUIrYCnI9k5oxS4xHnx+t+H1aFD2v1dMZmkeR11o9OlBUTD7N7sJZ1aRK30ELOjYTF7uIDCs3DR2PmCevaDUAF/RBG77UFwVcuSISsbLhGDTS2rhR+RWDqg8g1fzQkZoaLBkPGpJNw== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(86362001)(36756003)(107886002)(50466002)(105606002)(33646002)(87936001)(47776003)(229853001)(19580395003)(46102003)(104016003)(85426001)(50986999)(6806004)(62966003)(23676002)(106466001)(19580405001)(189998001)(77096005)(5001960100002)(5820100001)(92566002)(110136002)(77156002)(50226001)(5001920100001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR0301MB1607; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1607; 2:T/G/mEhGdgjxx0w7k2B/CF5A0IhQGXTLGBusWIBTBAGY9ogfHWcC5cix5X7VpvAV5kuRZazdWZ00SdBLH1vDrcBw5mRbtwd8qhGki+EyEjn1Lo1KudT2MCsk91okujTa6jIY6y7Aw7OILeOwIuxCYGKrAedDA4HvTT1i4cbRkAU=; 3:IYqNvCOpiJZRZUvXDAZ0tDJLxu8ytIDViXAAiGvlFLLCAZ7i3FnpSbu/xqZHdd1ge6MWygXJxKqaZN3coA3p1W8TXsduCKBTmvjDWLeiy/swUnqZtOjGBOmy1B8/yWdRko6r5wgyEgkNKOcDR8VAhxRp7/xPgr3px/aEjJXMThtIm9y/pjT/6pY5k5KS6QVs+gvg09hP5mkiF9vGOq0bpBhCYLQqwC3bdV2ZxE5W+V4=; 25:aH5ppsWqMBUcUxTSVihXT6uXxVyaq14TuHQuSIBG1w7YzEUlZI4t6tsdOK1i9xuzSWVcqiAYR48PHs9NrSJZwfO5CHEGxxZlk/9KdO52PSqVo0gDWi8zR6jqjVrnyAJDYKYZ4iQZRQZ8gIIyyio/HifvnSgI/FP0H6aJeMURsk7V8+AyvEMHBYnARQvPTa/bITTLaGFa+K85iLfrrwh3B5yU5MpwyISlifNaqeW1jUt9V0Jl+WfLcpRxpshr81gjQdT4SNPON9/kGhDhyVGHhQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB1607; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1607; 20:7iPF4YBS5ARF9x77ZHzsGrRiW01Q5oF+gCQK53SfqcGSNz1VQahkP5pU14Q/3gutdqEEyskcPMuwwes5eXXO/TctsGRioSRtSMEQhkz+Wqv2KNgWdAiiu1aCTCzK5tRHVpokBiOD2sO6gnP21P2bKw1+odkpnc8SwimTztoiWOInjmfWYgO64hdAAoGaJrjjE1dJDu15XhM/bghxGFE1iSNRZn6kTPFTfgeES8VEbxxXLDshvhaV1BCEeM8IQ65pMvf+/iGLWEyAcma2Pwy077sWDsaOBWEVcrbvKUAmtmtxappzJfvvziE8Yeyp8eVGFRHIKGtFJfPs5vw7J7mlazjA778cUMO8W8Z9e0TJn/M=; 4:oa3FuZ6Jr/u0KF87sE6ZStGou+IBkH0iqseaYqkSK+AXNPyquZa2yVUWPOYC7vKI4OgXzBFpOaXkxbLTobTdRK0ydNHp16BDLe7CwRO+X4MiAVv39+P45G8fzG5DmPwImxxyPkBfmnJ4AIqrnckBQKysqB/81T9Prbd83Q2oVCBjJ7HsfpyACHCWSe5SouW2zQkFI4o8xoflmyau1Om+KNGu0U3mxTi8gp97IfBH/nugBe5TeGinalZ04m/nlD8nUVwNTNLc6D7SnWhZ3pdhWtcJRFP0YJtTuCyrYLrkzr4= BY2PR0301MB1607: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY2PR0301MB1607; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1607; X-Forefront-PRVS: 06530126A4 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1607; 23:tpzjMADwuwKx4t0/abANpEYpW9QKRrOKG/07Ky2hMeJ7d0J2wV8K/QEqQQY/JwOKQNAGXPIaa4gD1yyUcwfBvXNVclGFVcWzSgmEv78woGtMjvEIoV0JtRt286JsXspjzd9OQe39Kf7psU4TEXZ2sq2MuBvIc/bf1IUspuD7duOYOrb9N6DzHOGQazw136W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MgpDRwoZB9eCXNUeaRUjzjCUMqARoz3gbA7Hgkm5RGYT3A== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2015 13:39:53.9024 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1607 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 The encap shared descriptor was changed to use the new IV convention. In the process some commands were shifted, making the output length zero, caam effectively writing garbage in dst. While here, update the decap descriptor to execute the "write" commands before the "read"s (as it previously was). This makes sure the input fifo is drained before becoming full. Fixes: 46218750d523 ("crypto: caam - Use new IV convention") Signed-off-by: Horia Geant? Signed-off-by: Tudor Ambarus --- drivers/crypto/caam/caamalg.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 3c50a5082127..b08ae6983d1f 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -989,19 +989,19 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) /* Will read cryptlen bytes */ append_math_sub(desc, VARSEQINLEN, SEQINLEN, REG0, CAAM_CMD_SZ); - /* Read payload data */ - append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | - FIFOLD_TYPE_MSG | FIFOLD_TYPE_LAST1); - /* Skip assoc data */ append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); /* cryptlen = seqoutlen - assoclen */ - append_math_sub(desc, VARSEQOUTLEN, SEQINLEN, REG0, CAAM_CMD_SZ); + append_math_sub(desc, VARSEQOUTLEN, VARSEQINLEN, REG0, CAAM_CMD_SZ); /* Write encrypted data */ append_seq_fifo_store(desc, 0, FIFOST_TYPE_MESSAGE_DATA | FIFOLDST_VLF); + /* Read payload data */ + append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | + FIFOLD_TYPE_MSG | FIFOLD_TYPE_LAST1); + /* Write ICV */ append_seq_store(desc, ctx->authsize, LDST_CLASS_1_CCB | LDST_SRCDST_BYTE_CONTEXT); @@ -1060,10 +1060,6 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) /* Will read cryptlen bytes */ append_math_sub(desc, VARSEQINLEN, SEQOUTLEN, REG3, CAAM_CMD_SZ); - /* Read encrypted data */ - append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | - FIFOLD_TYPE_MSG | FIFOLD_TYPE_FLUSH1); - /* Skip assoc data */ append_seq_fifo_store(desc, 0, FIFOST_TYPE_SKIP | FIFOLDST_VLF); @@ -1073,6 +1069,10 @@ static int rfc4106_set_sh_desc(struct crypto_aead *aead) /* Store payload data */ append_seq_fifo_store(desc, 0, FIFOST_TYPE_MESSAGE_DATA | FIFOLDST_VLF); + /* Read encrypted data */ + append_seq_fifo_load(desc, 0, FIFOLD_CLASS_CLASS1 | FIFOLDST_VLF | + FIFOLD_TYPE_MSG | FIFOLD_TYPE_FLUSH1); + /* Read ICV */ append_seq_fifo_load(desc, ctx->authsize, FIFOLD_CLASS_CLASS1 | FIFOLD_TYPE_ICV | FIFOLD_TYPE_LAST1);