From patchwork Wed Aug 5 18:28:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6952481 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A4811C05AC for ; Wed, 5 Aug 2015 18:44:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0893E205D1 for ; Wed, 5 Aug 2015 18:44:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEB7B205DD for ; Wed, 5 Aug 2015 18:44:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753384AbbHESoj (ORCPT ); Wed, 5 Aug 2015 14:44:39 -0400 Received: from mail-bn1bon0148.outbound.protection.outlook.com ([157.56.111.148]:26115 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753140AbbHESoU (ORCPT ); Wed, 5 Aug 2015 14:44:20 -0400 Received: from CH1PR03CA008.namprd03.prod.outlook.com (10.255.156.153) by DM2PR03MB574.namprd03.prod.outlook.com (10.141.84.150) with Microsoft SMTP Server (TLS) id 15.1.225.19; Wed, 5 Aug 2015 18:28:52 +0000 Received: from BL2FFO11FD030.protection.gbl (10.255.156.132) by CH1PR03CA008.outlook.office365.com (10.255.156.153) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Wed, 5 Aug 2015 18:28:51 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; kernel.org; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD030.mail.protection.outlook.com (10.173.161.40) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Wed, 5 Aug 2015 18:28:51 +0000 Received: from stc-hedley.am.freescale.net (stc-hedley.am.freescale.net [10.67.70.12]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t75ISmA9019320; Wed, 5 Aug 2015 11:28:50 -0700 From: Victoria Milhoan To: CC: , , , , , , Subject: [PATCH v2 05/14] crypto: caam - Change kmalloc to kzalloc to avoid residual data Date: Wed, 5 Aug 2015 11:28:39 -0700 Message-ID: <1438799328-10757-6-git-send-email-vicki.milhoan@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438799328-10757-1-git-send-email-vicki.milhoan@freescale.com> References: <1438228709-27650-1-git-send-email-vicki.milhoan@freescale.com> <1438799328-10757-1-git-send-email-vicki.milhoan@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD030; 1:FenEPIIxEv/q1RtGdUiwR09lVK/lc26r2MXPsICA9hT0PQA7n0lRzIBdB3ltreTRWpKK7xJ5LieROcaurvt6V6FGdsa8N+FNkQLs+bgMdNuYWI7pLthhGcqj/IgCwbuY1NJFnFzwUqid1biyZTVxOaCp3POS2Ai8XnJrq5RJ2+RvSieD64LBmZ1q0dIeurQ6/zBPkK/c1E7Pn/cSk+P9wS1eYX03/yOlFMJA2J6upaeZeUV2CgB0REJInzR5FOvB/VZX6gVc/6nQG2ozUROuiwqBNeNrLrWFUmyyetkfATwULbjbmx9dJA5zcZWjF4En0fmAdnxx1Ig0JvLPaeBYWQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(62966003)(77156002)(5003940100001)(97736004)(4001540100001)(36756003)(81156007)(104016003)(105606002)(106466001)(33646002)(189998001)(50466002)(2950100001)(46102003)(2351001)(85426001)(68736005)(229853001)(92566002)(50986999)(77096005)(86362001)(50226001)(47776003)(48376002)(5001860100001)(5001830100001)(110136002)(5001960100002)(19580405001)(87936001)(6806004)(76176999)(19580395003)(64706001)(69596002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR03MB574; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB574; 2:/S1XHgPPsk18GszNoYFqqnp/ixxFH/dVlGZEAArtVmU+3v9UTyFn+lOQoQLX1fbBV/RcM6ZB/iqchzlEwWt6jTrpljYwMLkJZM1iYF8OCoY2WTrT4dfr2ajgW/n4gUjIGN6QjcIsyZf1T4AKhBrPfh7zks7Swl1Dmq38QTsDOa4=; 3:RzVKV0Zlm+eE73GVanXKNcK1RXGJ7SJhDZUPoUK3C8Y3s2DpRaSt9HFHrY5gait8HymXzRkSiKtSF10+PM+yrOBYWNETOWvPU6chb4mXp5Xx0sz1l4gC80tITIbrQ2rOvL2p4sdEm2InEAdgarw97LCPPgH34kf/6C2SrzZhFAPaZzFjobhd7Ok4VFKGVxgkv1LyzIhaRfRshVE5xXszc/n3xmUfQXw3IsJFFy/VQnw=; 25:QLApwsj0gjaVkD89l2uBi5Ux+TSCJRB7+DZEEv1pqZNI22G4JBQVtvVOJkOhnnfKUfZQmDxR+9u1q8D4yrlGJ0A5GKx9JtFt26bGCP37I+AhIBgZz+Ff143mc9D4WqwcJz9MpBo1+L77nVDCgSKqn5RXKqHqN3NErvTh7V9A9WogLDcOIGbAvqsfOlRy7AYMvrt/BYwct7XoIrnnP3B06xHHhy5wKchYUtYRzBCr7JihxuUvXFS/B1miU/DZgtOm8VkO2XlePV0SksgY3XjoMw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR03MB574; X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB574; 20:drVlbTBNrMS1c18cCt0JuOqb7iDOxOy9WUIZ0DmKz4nbABSKdaA19MVxjGfofxmrkW5L6aXdP4pu6LYF8O76dv96h+Z64G2oJiXpEVs7wmphbDTFaP2Y2/Nu+Skz/eRHjdfExMdTXrZ0hPcw8SqXDvFtjzUZzk6UJGM+4AqsioV473UD6kP2EWy9hf+SVgUDO0yruCyU+S/277Bwj0/oYtCBWBbibqnrqNYt+Jktx++MrP4UAlX6W4PasUujxV1LDpm/IRslBHi6K6JnutWvzZ7bH1x1vOVDIykCDljvYX4z1FVaSOgXa9oITJKejGXHVLlzmrLaeAJ3jQZEDohg1GsFvAUkpqp9JZgGCJiAKxA=; 4:EMe+pMnnZFzxC3Y/6OXHOopxQCJvUoVXMiA85aSVFi4jN0OHohVa3sO231RabjlXHgeD/xR5U2q5cP5XHK/yUfmM3Rxf9zAAiKJfESKcly5DPWoxWibO07LQ+J9ZxwVbLq5B/fQ68i2WYMgVMEjN7cH9LfoZrMRVD0uvTJjV50Gr3JpsG86c9cbYn++sAsEFnoGB4CqTWCY0S8e+CSRBqQGIjjCf3BP1+UljZ5NysiPmtclf+YK5XVTjlgjswvHaQT/DrOznJYTxhFcMAyTFg880YQHA1e99AjTW1y3xPGU= 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:DM2PR03MB574; BCL:0; PCL:0; RULEID:; SRVR:DM2PR03MB574; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR03MB574; 23:cBGYXq70mKEmpyNahs97tGy3kSmcA3g5DrREMHvJyI?= =?us-ascii?Q?9fpo2oovHxcUPAslI/WsT0tfMJ5c2aTPIRoR+BKhBYaAIPRyZXA0hT2o8rTX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WOp/cMKL2sb65rsXE2EuERypuZ?= =?us-ascii?Q?RoEc3CSGcILu/7ycH3KRDqjeVfl8xPX8ecl6Zhm2v0roFp8hvN1FyUkoDtyI?= =?us-ascii?Q?x808ZpQ7gXxnM66qOca1kI17Dn4xD/21iya3ySPv2sUpRtMBWYdQGopKqYW2?= =?us-ascii?Q?qVfkbyKig=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR03MB574; 5:5RVmPV0jsJLQMC0aGwTrPjDewMiI8O1b31Jvv/aBgjc9exyclPh8Zg2O+ehoLn/ViX0aepBrVG4wITgz4afbJKhpAmAE9fVIMxgd5Rxuv/lc2at+6oWN2xxqJzM13fJoyG+zDPMzBeCi0nur5Dop4Q==; 24:OivVLfk1OIGSeoN0UMsTq5ocfy1tW/VwY4g+4ykJg6j9vTU1JdIJvIRDAukWCAHqq6Gkfb1aNaAzozdE3OcGfPqnsC3XLJZeyKSdcsKRE38=; 20:dsdMfVeGEbmD6AdZOIb/2YqWOhvUbVI+HKEp/EBfdT65RZQWhB9TWndTjVUguKeYvpGqORGeSv8338/2ihf6Hg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 18:28:51.4680 (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.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR03MB574 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Since fields must be ORed in to operate correctly using any order of operations, changed allocations of the combination of extended descriptor structs + hardware scatterlists to use kzalloc() instead of kmalloc(), so as to ensure that residue data would not be ORed in with the correct data. Signed-off-by: Steve Cornelius Signed-off-by: Victoria Milhoan --- drivers/crypto/caam/caamalg.c | 12 ++++++------ drivers/crypto/caam/caamhash.c | 25 ++++++++++++------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index b09c171..3d1ca08 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -2199,8 +2199,8 @@ static struct aead_edesc *aead_edesc_alloc(struct aead_request *req, sec4_sg_bytes = sec4_sg_len * sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kzalloc(sizeof(struct aead_edesc) + desc_bytes + - sec4_sg_bytes, GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + desc_bytes + sec4_sg_bytes, + GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return ERR_PTR(-ENOMEM); @@ -2503,8 +2503,8 @@ static struct ablkcipher_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(sizeof(struct ablkcipher_edesc) + desc_bytes + - sec4_sg_bytes, GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + desc_bytes + sec4_sg_bytes, + GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return ERR_PTR(-ENOMEM); @@ -2682,8 +2682,8 @@ static struct ablkcipher_edesc *ablkcipher_giv_edesc_alloc( sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(sizeof(*edesc) + desc_bytes + - sec4_sg_bytes, GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + desc_bytes + sec4_sg_bytes, + GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return ERR_PTR(-ENOMEM); diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 9622a81..2361beb 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -807,7 +807,7 @@ static int ahash_update_ctx(struct ahash_request *req) * allocate space for base edesc and hw desc commands, * link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN + + edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, GFP_DMA | flags); if (!edesc) { dev_err(jrdev, @@ -918,8 +918,8 @@ static int ahash_final_ctx(struct ahash_request *req) sec4_sg_bytes = (1 + (buflen ? 1 : 0)) * sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN + - sec4_sg_bytes, GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, + GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return -ENOMEM; @@ -1005,8 +1005,8 @@ static int ahash_finup_ctx(struct ahash_request *req) sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN + - sec4_sg_bytes, GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, + GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return -ENOMEM; @@ -1091,8 +1091,8 @@ static int ahash_digest(struct ahash_request *req) sec4_sg_bytes = src_nents * sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + sec4_sg_bytes + - DESC_JOB_IO_LEN, GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + sec4_sg_bytes + DESC_JOB_IO_LEN, + GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return -ENOMEM; @@ -1165,8 +1165,7 @@ static int ahash_final_no_ctx(struct ahash_request *req) int sh_len; /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN, - GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN, GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return -ENOMEM; @@ -1245,7 +1244,7 @@ static int ahash_update_no_ctx(struct ahash_request *req) * allocate space for base edesc and hw desc commands, * link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN + + edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, GFP_DMA | flags); if (!edesc) { dev_err(jrdev, @@ -1353,8 +1352,8 @@ static int ahash_finup_no_ctx(struct ahash_request *req) sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN + - sec4_sg_bytes, GFP_DMA | flags); + edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, + GFP_DMA | flags); if (!edesc) { dev_err(jrdev, "could not allocate extended descriptor\n"); return -ENOMEM; @@ -1448,7 +1447,7 @@ static int ahash_update_first(struct ahash_request *req) * allocate space for base edesc and hw desc commands, * link tables */ - edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN + + edesc = kzalloc(sizeof(*edesc) + DESC_JOB_IO_LEN + sec4_sg_bytes, GFP_DMA | flags); if (!edesc) { dev_err(jrdev,