From patchwork Thu Jul 30 03:58:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6898141 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 26E1CC05AC for ; Thu, 30 Jul 2015 04:14:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CD8520544 for ; Thu, 30 Jul 2015 04:14:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC4052053E for ; Thu, 30 Jul 2015 04:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751120AbbG3EOS (ORCPT ); Thu, 30 Jul 2015 00:14:18 -0400 Received: from mail-bl2on0111.outbound.protection.outlook.com ([65.55.169.111]:9600 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751074AbbG3EOR (ORCPT ); Thu, 30 Jul 2015 00:14:17 -0400 Received: from CH1PR03CA001.namprd03.prod.outlook.com (10.255.156.146) by BL2PR03MB562.namprd03.prod.outlook.com (10.141.91.27) with Microsoft SMTP Server (TLS) id 15.1.225.19; Thu, 30 Jul 2015 03:58:35 +0000 Received: from BL2FFO11OLC009.protection.gbl (10.255.156.132) by CH1PR03CA001.outlook.office365.com (10.255.156.146) with Microsoft SMTP Server (TLS) id 15.1.207.19 via Frontend Transport; Thu, 30 Jul 2015 03:58:35 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; arm.linux.org.uk; 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 BL2FFO11OLC009.mail.protection.outlook.com (10.173.160.145) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Thu, 30 Jul 2015 03:58:35 +0000 Received: from stc-hedley.am.freescale.net (stc-hedley.am.freescale.net [10.67.70.12]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t6U3wUbe025418; Wed, 29 Jul 2015 20:58:34 -0700 From: Victoria Milhoan To: CC: , , , , , Subject: [PATCH 05/12] crypto: caam - Change kmalloc to kzalloc to avoid residual data Date: Wed, 29 Jul 2015 20:58:22 -0700 Message-ID: <1438228709-27650-6-git-send-email-vicki.milhoan@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1438228709-27650-1-git-send-email-vicki.milhoan@freescale.com> References: <1438228709-27650-1-git-send-email-vicki.milhoan@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC009; 1:14A4tF2GaDQCrABMvpaBvdvqWmgfi4WjA9XiCIb8YZS27GltRQSBONvujkAPdXhcYXmTP7Fn8pMtVLi7dZxmhUXd7lhp9l5r2KVZoaQlfsgEyoxwyD0MA0oWKvQfJMB/1SCFk3t5+/8eE+ThC9WQK6ZPuDZWDfhBjCdLXU140kpX8A7zonmPRfmY+l2IbL+8tTRRye/AJEv8SF9B0NrnSk2hqYW9ZVLNj0Q4hf+7mg++mxWPvpHr8/rXVZl46AcCZb16fVRReaYIUf3QdsD97+6hFce9ffvV5kB+IpM82HeUdmakeqxDMwHb+1QAnBs9hfT8GVL8icMI48uOYQZdHw== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(46102003)(106466001)(5001960100002)(110136002)(104016003)(36756003)(77156002)(33646002)(86362001)(50466002)(229853001)(47776003)(77096005)(19580395003)(92566002)(105606002)(189998001)(50226001)(85426001)(48376002)(2351001)(76176999)(50986999)(2950100001)(19580405001)(62966003)(6806004)(87936001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2PR03MB562; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB562; 2:IiZdqMpGPmjOP3PfqPR6vgE5MtNsT+EerqyZXmbvByNGKAmr6yKluJcQ6yrAQ8G+1UT0dfp0Q0SANl4dicO96I6JsWSX6O7aVeAn/WKoM3HNPFzZgd4wWEI1itNIKhBmXMdoOdpCkCXot3LMsdmVUYePJatIkyDQFUG8oBOFXGY=; 3:RXC+zs3NYsZ4Ise1Ey/ZJ++vpe6f/Q/4ThrO0ep4gSkGsNnWAF/xqTIjBekoDqR0tKp3zrCEE5EpD75ivH2ryw0tbm+cSswR4RIpITA53ihA2FdAsJGhny4yVuWnql3fbXcRpYqhzKRyerbiaY5ljDpxrkamPdD2gCS6Kp1EsVf8LcDEnRElgxnLTtjOzC1s3K3oNpYkTX1BAhbLXbFSoUR/Db4+4bLnUqAJtZ1upDg=; 25:RaiSzS+KIrcHBkS7TLKkBTlAnQZ7xub04Kj5X6R3lDp5wyzTdVASG+IwLdWpXhEJJwYKeWKCxROTCKa3H2OutcnCFwfGrTWRgZNyiJGQXRwvlWE3+jkRtiewgHOH103Oo5zH2Wj8tBWsm/DzI9LfqbS9+htgyB7PoPfKEasjom/e92HMoTxpfAOzCOY2iWnZFeB4KHjZPwMC/kgRiyU+6y4tJ9pf2NNtY8lKQzyuYM7W00GaC6nswb1TzuumpRrcWTXv0E/40b+PaGHBKY82Ww== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB562; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB562; 20:hYBfZk5d/rrSxO2liHzd2v4fVFLatrG4niG1+kymA5NH2h3MooFBlAhzhedIEvtjEGP0IHS2sMPLYe5cZYUojtlOnqpR3BTFI+NERemCtmkS/oRqgdRkhryBYWXZXPn+yC9py9H/HUz0OvjW3V1NYT1Bm6cA1Rz2ePYp1yl1m5rDF+jOIydfhXePKgQ8NgAz7HyK8PCJHn4oRObQoHEXcV8PMDJvzpFhNL6MPnn3BPbcdrcrvz76L9rAy4RKKUeqboNauThu6WpqbAdgKwmCvtame7byPRlfGJRolD6XudXnV4Ti0qCdT5ThLhMJX2JVfC7MJnKK5D9CzUUwAqvJFmUEMTTrAszctFGcwNrfqEw=; 4:YH/kgrS6/WpA+UmzZBbw0m7dzhlK2jR3KVR6Zv+QOiAjyth06WpRIplulq0QceqojVUbIoYTaIebwRdqsq1I7lqFE1hrHM2kiS3rG1j8fMS85LKM/Q+BikkfoX59jgJaKRrI75e3wcZ3YSmwUvc0KAAWL0LbxmI26lHtNtlne0nXfcji1yuvVd2Cz54xQxRWvYstJKWIPMUoiDcIaiL2fE1N3cemlsaSMHHLOBpR/KBt1cfdlacFGab4eu1ofro0UuB1733f4k+FQ32G0+F8iMPPyRhtrtoBBVn0qTTM8OY= BL2PR03MB562: 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:BL2PR03MB562; BCL:0; PCL:0; RULEID:; SRVR:BL2PR03MB562; X-Forefront-PRVS: 06530126A4 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB562; 23:Li9o98M2D3SuJbQ56+QeQMUrOSuz9hgd4MdTg/3KMtURxmhBsirBYp4smhSEI47b5FVea0Pbn0wr0kOJVgYzwWy6XHwIxabvTw0yOLN0O4WP4E/Ezr+L3SNQwOdMCIqgJLSkX4/kD0JOkfAsWKJdg3cS5yiApW8MHs8hJqsR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iZCDjawpj36cmbiwYAhfHcPje4Cuj0uB3UCFeNo3hrQMV/ldg== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2015 03:58:35.2037 (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: BL2PR03MB562 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=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 | 20 ++++++++++---------- drivers/crypto/caam/caamhash.c | 25 ++++++++++++------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 3c50a50..33b6861 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -2482,8 +2482,8 @@ static struct aead_edesc *old_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 = kmalloc(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); @@ -2585,8 +2585,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); @@ -2921,8 +2921,8 @@ static struct aead_edesc *aead_giv_edesc_alloc(struct aead_givcrypt_request sec4_sg_bytes = sec4_sg_len * sizeof(struct sec4_sg_entry); /* allocate space for base edesc and hw desc commands, link tables */ - edesc = kmalloc(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); @@ -3094,8 +3094,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); @@ -3273,8 +3273,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,