From patchwork Mon Jun 15 23:52:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victoria Milhoan X-Patchwork-Id: 6612491 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 DDC889F1C1 for ; Mon, 15 Jun 2015 23:53:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C694A203B5 for ; Mon, 15 Jun 2015 23:53:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99EDA203C0 for ; Mon, 15 Jun 2015 23:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751392AbbFOXxQ (ORCPT ); Mon, 15 Jun 2015 19:53:16 -0400 Received: from mail-bn1bon0132.outbound.protection.outlook.com ([157.56.111.132]:13568 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751736AbbFOXxN (ORCPT ); Mon, 15 Jun 2015 19:53:13 -0400 Received: from BLUPR0301MB1569.namprd03.prod.outlook.com (10.162.214.15) by BLUPR0301MB1651.namprd03.prod.outlook.com (10.162.214.145) with Microsoft SMTP Server (TLS) id 15.1.190.14; Mon, 15 Jun 2015 23:53:11 +0000 Received: from BLUPR0301CA0028.namprd03.prod.outlook.com (10.162.113.166) by BLUPR0301MB1569.namprd03.prod.outlook.com (10.162.214.15) with Microsoft SMTP Server (TLS) id 15.1.190.14; Mon, 15 Jun 2015 23:53:10 +0000 Received: from BL2FFO11FD015.protection.gbl (2a01:111:f400:7c09::143) by BLUPR0301CA0028.outlook.office365.com (2a01:111:e400:5259::38) with Microsoft SMTP Server (TLS) id 15.1.190.14 via Frontend Transport; Mon, 15 Jun 2015 23:53:10 +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 BL2FFO11FD015.mail.protection.outlook.com (10.173.160.223) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Mon, 15 Jun 2015 23:53:10 +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 t5FNr7p3003741; Mon, 15 Jun 2015 16:53:09 -0700 From: Victoria Milhoan To: CC: , , Subject: [PATCH RFC 08/11] crypto: caam - improve initalization for context state saves Date: Mon, 15 Jun 2015 16:52:56 -0700 Message-ID: <1434412379-11623-9-git-send-email-vicki.milhoan@freescale.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1434412379-11623-1-git-send-email-vicki.milhoan@freescale.com> References: <1434412379-11623-1-git-send-email-vicki.milhoan@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD015; 1:CyKv88qBEEwhjVa/lAgkT4BFjGz4V7kU8hNmrLCpy2MOtty+2QOCt9rYm8AmBvHFASpCmGIgVylKJEeW1HoDF5nsxi0xbe1F6/u0FITpwW7tRQi9a9dvTLx+dmcIzyk/hqMUX2qP/FzCbp0ymt4K+7E+lFYyZ9hRKiLtmccUPeGUqEVP9v1PNllhFRWp1lODznnY9IervmIEZLkgpU1xIzUBIk8zMmW55UsS+EgneZ8ealU+jnY1awmGWilR8bLQ0+kTp+mKgin/U2yKkp15Ns576tgqxGQ0yuTREy3PZV73AcYcSDchDWsDJ+ytXXyMUgumYtZLNeK/kLAQ3Xiycbc4vtgbJ9otwxOXhBgBVJU= X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(76176999)(33646002)(36756003)(77156002)(106466001)(50226001)(50986999)(92566002)(46102003)(6806004)(87936001)(575784001)(62966003)(19580405001)(19580395003)(86362001)(2950100001)(104016003)(5001960100002)(110136002)(107886002)(189998001)(48376002)(50466002)(47776003)(85426001)(229853001)(105606002)(77096005)(2351001)(4001430100001)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0301MB1569; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1569; 2:s8BFM8lqi1tzjvIwK9HpS9KHXYy4dYv3lPjCkBrU8k4cfa5uI5ttOKTZcaJdO4bv; 2:ngXW3J1Am49r8tteyx4bj4sV5eDsFH/SaXDw1aVRbX2Y+Mxc+XV9I9z2k1ZfuQHALAF0Nr3uisiR6H2pptAIQ8aKJKu5Cr691RWQvwxK8XOEp9cHosqcGAzTnrIYSZlXOIj0zSqieYTNzfNbb0A0viWM3mY1g8l2zbNp8NZ1jG1SOO8Zb9Yk271KyVzwN67IIPHgCnzTWVZYxvpvZiNYMMdqgCfG81cXei1E6FdV5t0=; 6:8J8TJTSW9DfGIT3HRwXQJlFRNnQFhP0d4bGM+C6ES8zmoMyejkflZeWazv1iHjsQxblLfEPGcSq02+cIyi/0MMByMRCdUYHkY7yx26vo03wXQ957yfykSA80+Vd1Y6jC7+4Hn/HklkgX4BBkvSstsNYPvGY3qL9W/JbWb5K91IPrPqaJmW326rRIXSUAdn5xlobU2EJJc0DvYwnzrcLws3e/1NU5lwRVBhtYsnqjIPSV6GxiDxpOae9hHALoOrJSAsVnlWB1U/Rv1SujqiEuiw89NveddnYxRg/LPm2LbP2wl10Ql5Tm+164vFI8MS0Tlv4CR2iwgOnGulGKXOeUwA== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1569; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1651; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520003)(3002001); SRVR:BLUPR0301MB1569; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1569; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1569; 3:BDqZYzJexZWZoGxxBmFjGIO+46s3xAuedi3pJ9BeFDE+v8peOMfyo7es5koZWgfCZLBzxf1YO5LXLHJrVptHytswJaJ9k+6VEy6h5hCbtRaNO5dwPcaPy1ec76f6GUsF0jhBWw0EkpTiqA/7ZsjYX/1UdlmseLvQv0nUakam1Dy1y2C//ywVG6BBTquC2YLvzTebmPvqYc0djBOay9vqNnDOgE+ZzhETY7qSzy6feOUdVHq8x8UJPr/fbiioOPfNILZYFEyLwQRGL8I+RDpBvni/eSAtBdCkIKkHR4JQGQ86NHdr63hlRw0RO6XCMVnJ X-Forefront-PRVS: 0608DEDB67 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1569; 9:pOhfj2wIQCOnSMvQIWkSc8Luc3zFeR7CMmn48QQb3DpYLXP3YmQh7s7T+ijX8n9EbD/oxO3eOk/25kIP9bUj0sxRggP0ctlHVsmidWWqosmW6ZgAS7j0tEVwqQrYSTjYCMNN84OGcEIwVJifFkVxclnDsRxqhJvVpMv2W5azDXEaq/jfpmDJ2QLbczfgbmGsgMnqpdf/KNjuXX1L2FYdkY/DthAO6yLTousr66Oq2F09I/CIwZNQfIJxw/rk+LwYTkDkupTjyHEn46dwxpHfF5s2XTk+3LW3Myd9ngzJjZ2i8Ef6dBCL0wpixQ0eqBL2x8OYZNuvmNIaxZ76Iquw85qImCQKYH1rLAHRbdAKqdOq+JS31QDANn89Y4wWxD/jjKN9giVhcLN9JyPq+QU9bnHMdHQ65Qjp/XJz4xysJhVc7q6GgrHvRWrWFiJ4BrBfbmixRfAvV+xvMEdKVJIA+du983azQqywWm8pwzH57FOTACyond1l5KUrN1t30TpRqvr2yVrVBNktvzjVnTNKE9gf0TJAkWsQx3uZeHhPPkqULBu3HpIHJ4R51FE3X1C/bUJk/gt5WOApwjG0VAG+laWrgC7n68tkzKfBpWl5UgpxE269kkGoUvXZP2k+Ekohj9abpEBBH7ceYxK3ulIzCOc4ku/LNhRwmBQTgMt2WLQ8Fw0eA57A1fmB7J7FwHIPTdclmvF1YJVFP1Et09MSdm2/Y9azq2GErRcSfEccVmyUKV+PIhx39FMoGVQXpEbRPFmcshhp6pDnz6IlJhtFFWhfQRVfgUFeZFYn4Fi4Hy97fjJYmsu8seRo2eRd4dpYBppuPU5/VijCjEOoY+tVMpPqLXzIZy3o+R1q1U7mV3bpaIDFvrg4cuic+jBn2yIz6EDvey643oft0YEotFIUcJ/njklPn7FdGRZx1aP1 pLpnQytZeLCN0HJyQi4MycMW X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1569; 3:kwSZ8dgNwBdR29ecHZVmbqAsLlc+w2WwsVP7ywp/HUSAivnJLhIMKg0jftllWk3ITeYi3dDiysLCICBFrgOfaQqhPGqL9Ow48rVujIhT7GDH2XmkqkvPVFvRJLNyPdmMslBQqbUgDWFU1wQWUywXUg==; 10:ymjCit34KbMr5fQpp8xLOQ9Ks6SfVk7c5y4v+olW9rVacdNIiGJDRidSQDuZVsYx7PVjcqUPK2L7MQ2+BTIEixHgO0e2aVP7GqpgxeB2FWU=; 6:35o+XhT89krrtfO8JRe4JnCAw4d5PS2DLu3/nZXYUO779tzk7A3CQh3FAnIGtHZd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2015 23:53:10.6054 (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: BLUPR0301MB1569 X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1651; 2:vviSfIpdTKM6YXAQmly+rjeWtkebya9xukqscn32OpiEXZvjZ8imqigB+zEZz1Pe; 2:fze7qGA74XtXpPLf3j0TjTiBSZum6TjxhdCbHlNVixuPBCsZ7n8FgMA5gPgVsFACK+FF8me5nvNqnSgD8vDDv2OArQjXSvPSu9PmzdCgGP4kqJBN//Zi+J2njkNKkID27Q8CoUPtOf1UWyUU1ozJhbV8IkZ36a7ILCdM+FatDP3FtLdRQNf18Vmw2Jyxa94REKhryJsRKOH0+WmPJHBkkV1aMXIY+qbndzMQphKAYlY=; 9:ADb91Au4WUarBstAEpyqVks65LoeSzXRmJ0bktQAgw98LcShM8XtHqWAPM7NY+yG5W0wnwmrd61V9wRwssfO4sGo78EZawAkrZ4yqVJcmxbiRi/B20MNeJQ2Yv77axKedb2ZxzcS3usYzAfuwlzepg== X-OriginatorOrg: freescale.com 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.4 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 From: Steve Cornelius Multiple function in asynchronous hashing use a saved-state block, a.k.a. struct caam_hash_state, which holds a stash of information between requests (init/update/final). Certain values in this state block are loaded for processing using an inline-if, and when this is done, the potential for uninitialized data can pose conflicts. Therefore, this patch improves initialization of state data to prevent false assignments using uninitialized data in the state block. This patch addresses the following traceback, originating in ahash_final_ctx(), although a problem like this could certainly exhibit other symptoms: kernel BUG at arch/arm/mm/dma-mapping.c:465! Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = 80004000 [00000000] *pgd=00000000 Internal error: Oops: 805 [#1] PREEMPT SMP Modules linked in: CPU: 0 Not tainted (3.0.15-01752-gdd441b9-dirty #40) PC is at __bug+0x1c/0x28 LR is at __bug+0x18/0x28 pc : [<80043240>] lr : [<8004323c>] psr: 60000013 sp : e423fd98 ip : 60000013 fp : 0000001c r10: e4191b84 r9 : 00000020 r8 : 00000009 r7 : 88005038 r6 : 00000001 r5 : 2d676572 r4 : e4191a60 r3 : 00000000 r2 : 00000001 r1 : 60000093 r0 : 00000033 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c53c7d Table: 1000404a DAC: 00000015 Process cryptomgr_test (pid: 1306, stack limit = 0xe423e2f0) Stack: (0xe423fd98 to 0xe4240000) fd80: 11807fd1 80048544 fda0: 88005000 e4191a00 e5178040 8039dda0 00000000 00000014 2d676572 e4191008 fdc0: 88005018 e4191a60 00100100 e4191a00 00000000 8039ce0c e423fea8 00000007 fde0: e4191a00 e4227000 e5178000 8039ce18 e419183c 80203808 80a94a44 00000006 fe00: 00000000 80207180 00000000 00000006 e423ff08 00000000 00000007 e5178000 fe20: e41918a4 80a949b4 8c4844e2 00000000 00000049 74227000 8c4844e2 00000e90 fe40: 0000000e 74227e90 ffff8c58 80ac29e0 e423fed4 8006a350 8c81625c e423ff5c fe60: 00008576 e4002500 00000003 00030010 e4002500 00000003 e5180000 e4002500 fe80: e5178000 800e6d24 007fffff 00000000 00000010 e4001280 e4002500 60000013 fea0: 000000d0 804df078 00000000 00000000 00000000 00000000 00000000 00000000 fec0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 fee0: 00000000 00000000 e4227000 e4226000 e4753000 e4752000 e40a5000 e40a4000 ff00: e41e7000 e41e6000 00000000 00000000 00000000 e423ff14 e423ff14 00000000 ff20: 00000400 804f9080 e5178000 e4db0b40 00000000 e4db0b80 0000047c 00000400 ff40: 00000000 8020758c 00000400 ffffffff 0000008a 00000000 e4db0b40 80206e00 ff60: e4049dbc 00000000 00000000 00000003 e423ffa4 80062978 e41a8bfc 00000000 ff80: 00000000 e4049db4 00000013 e4049db0 00000013 00000000 00000000 00000000 ffa0: e4db0b40 e4db0b40 80204cbc 00000013 00000000 00000000 00000000 80204cfc ffc0: e4049da0 80089544 80040a40 00000000 e4db0b40 00000000 00000000 00000000 ffe0: e423ffe0 e423ffe0 e4049da0 800894c4 80040a40 80040a40 00000000 00000000 [<80043240>] (__bug+0x1c/0x28) from [<80048544>] (___dma_single_dev_to_cpu+0x84) [<80048544>] (___dma_single_dev_to_cpu+0x84/0x94) from [<8039dda0>] (ahash_fina) [<8039dda0>] (ahash_final_ctx+0x180/0x428) from [<8039ce18>] (ahash_final+0xc/0) [<8039ce18>] (ahash_final+0xc/0x10) from [<80203808>] (crypto_ahash_op+0x28/0xc) [<80203808>] (crypto_ahash_op+0x28/0xc0) from [<80207180>] (test_hash+0x214/0x5) [<80207180>] (test_hash+0x214/0x5b8) from [<8020758c>] (alg_test_hash+0x68/0x8c) [<8020758c>] (alg_test_hash+0x68/0x8c) from [<80206e00>] (alg_test+0x7c/0x1b8) [<80206e00>] (alg_test+0x7c/0x1b8) from [<80204cfc>] (cryptomgr_test+0x40/0x48) [<80204cfc>] (cryptomgr_test+0x40/0x48) from [<80089544>] (kthread+0x80/0x88) [<80089544>] (kthread+0x80/0x88) from [<80040a40>] (kernel_thread_exit+0x0/0x8) Code: e59f0010 e1a01003 eb126a8d e3a03000 (e5833000) ---[ end trace d52a403a1d1eaa86 ]--- Signed-off-by: Steve Cornelius Signed-off-by: Victoria Milhoan --- drivers/crypto/caam/caamhash.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index 1662c65..f2f1e87 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c @@ -1552,6 +1552,8 @@ static int ahash_init(struct ahash_request *req) state->current_buf = 0; state->buf_dma = 0; + state->buflen_0 = 0; + state->buflen_1 = 0; return 0; }