From patchwork Fri Mar 18 18:32:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 8623181 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 8BC66C0553 for ; Fri, 18 Mar 2016 18:47:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF81420306 for ; Fri, 18 Mar 2016 18:47:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C43E020225 for ; Fri, 18 Mar 2016 18:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755159AbcCRSrS (ORCPT ); Fri, 18 Mar 2016 14:47:18 -0400 Received: from mail-by2on0068.outbound.protection.outlook.com ([207.46.100.68]:46168 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750994AbcCRSrR (ORCPT ); Fri, 18 Mar 2016 14:47:17 -0400 X-Greylist: delayed 895 seconds by postgrey-1.27 at vger.kernel.org; Fri, 18 Mar 2016 14:47:17 EDT Received: from BN3PR0301CA0002.namprd03.prod.outlook.com (10.160.180.140) by SN1PR0301MB1597.namprd03.prod.outlook.com (10.162.130.19) with Microsoft SMTP Server (TLS) id 15.1.443.7; Fri, 18 Mar 2016 18:32:21 +0000 Received: from BN1BFFO11FD023.protection.gbl (2a01:111:f400:7c10::1:145) by BN3PR0301CA0002.outlook.office365.com (2a01:111:e400:4000::12) with Microsoft SMTP Server (TLS) id 15.1.443.12 via Frontend Transport; Fri, 18 Mar 2016 18:32:22 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.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 BN1BFFO11FD023.mail.protection.outlook.com (10.58.144.86) with Microsoft SMTP Server (TLS) id 15.1.443.6 via Frontend Transport; Fri, 18 Mar 2016 18:32:21 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u2IIWAmO015418; Fri, 18 Mar 2016 11:32:19 -0700 From: Tudor Ambarus To: , CC: , , , Tudor Ambarus Subject: [PATCH 05/10] crypto: qat - avoid memory corruption or undefined behaviour Date: Fri, 18 Mar 2016 20:32:02 +0200 Message-ID: <1458325927-14737-5-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1458325927-14737-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1458325927-14737-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131027995415342942; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(4326007)(47776003)(33646002)(87936001)(76176999)(50986999)(2906002)(5001770100001)(50226001)(5008740100001)(6806005)(19580395003)(189998001)(105606002)(106466001)(36756003)(85426001)(92566002)(19580405001)(5003940100001)(104016004)(586003)(77096005)(86362001)(2950100001)(229853001)(48376002)(50466002)(81166005)(1220700001)(1096002)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1597; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD023; 1:lFaA0qJgJOStVWQjLX6YXtbv3iGUMd4nfWlKIgJVVymbmcaKImp9TTCUPVCFQAF3sbnbB+lHeyg9xw1VHQwV64ukdzuYtqcurPATd67fl/f6SPgJ/dO5w7QVQiJ0l0a3ic7tGrW6hsJrx4baFLC+YOFp49i4lKeZjkvsmyDqVmYZYuq8ZpJnejhfj0xcaqIFiLl8C62HuD+vLOTOxCoS/43amBZLDXYozqszSJqSG5z0dCTrFA82X9/S809NaiwhPkguXQJp4UeGcK2DvZphkAwgGRxYiNGxVLBSN+X9AbnsQIMOHn8GhUf0bmBBGArpKdyEAuKGllo4/Lwn4ac37khmS+cUPqDcqboqGe//zaARXqp3Kw0YmyDevDeJeQDoXcWi+ML+Jj5Lm/TYMUDoSqWB3/BrMhHq+pjVb4NaGub2570yABu6xtunAHQ+xWYkxHDFN7dKr0W1aM8M12PYIgXdTYxmxM0rbrpw2ZERD5hez4WxGu/R3TZaZ3W6MnisMGHKSEPyDBr5KmsFow4YcjG1WnRl1jJ+px4iLwJKXxG0xBEH6EcpoWQQUwbqzG+VIAA5YduqWSQ8qEVaST59bcJ7nxFiiJ0JulKnPN/5kt87ucHjbBLN+iaX12kM4rPQhsSN85L1f8qlLpJQqWN7bqDBegJpovg/BB136NJLMj0= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 96bc7b56-459a-4d5f-ef5e-08d34f5ba4d3 X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1597; 2:Sk6kXrwz4riTKLFOhDybN/TSIyzSaOBhNmFF/u9orNuE6D72vqxlpKOsDpFy2jc1vB7xLaRMTvlQPrx1ktUILWwxjaQJAKURqqlVPEAyNprjzKW9nqD8I4ty2OTFBiYWC0G9UrD7Xh9y+LcoTfJf5dHrgwfCLjOtr8m2zz8nzJ5NCuipGwhYmL0K7C7gfNSs; 3:8Qj1hKqgco/RSgqVxOquPKKBvMXaI/QW3I0f0Y0L+74r33UvL69J87pXRYmeJvazF1gtkjlsDwJ/97W3A9Rbw3ndsyun3WLkfFY6l3Sjg6jfak0nEggbz+d1wZ/+jXJz10UpkO2FVvwHyIaqFhjVaT6rmi5N8+ZDGi6WrNg1K/UzCFYSl7Hj9LX+pPPiDhTenaSXkwPfA/BBaqsegB/WtH8UcP9zmXcYkZv9rfPztBw=; 25:Cs7j0i1SQnW+2K5YG62jiVuSo8dDX0IAXZEmnFtCg71/romTJgsmF1EdlEvfjX8O5IFSjADwBd34R1Rigvlm13uk2AunvZuKHoHHNnWZvoL40stmZ8xofsDCaBnXktc2SDhq73bcK0aSzb4aS1OtoVaC/8YVqTLaKlD9tTokOo+P9mMQYRKfOwkZPBnct4npKEMQJ4iy5HrIdKqnr13nBB6U2M3o7V4/OT9CoFZyy1f+xQgJMuVx8tx4rS4b8IDu5GLbgP4OMG+EmcD+YGkJTcKg1XPBMo0gFV0a2x0/4XlpRHZXFTKpHRz6pKwm8Rl5+I2LWzc81Dei9d/yIN1dRPpgg10Emvv6N9QgnQUee5Ph9LjX5c2Zlfq81JUoiE8RgeOXCRRva7G4vd0fkZuGvUDePoGJ1Hx+mNsEh0PS80oi7iBeVvuH8mSVd0a+N+r1VtSYmbGSSMOAuWvw72c34HQ53zHMJjnd937HwMFSv1u74qiN0X6/z OpXDEe1uRi8BiNF9ok2LrB0qjezjLg4Gw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB1597; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13024025)(5005006)(13018025)(13017025)(13023025)(8121501046)(13015025)(3002001)(10201501046); SRVR:SN1PR0301MB1597; BCL:0; PCL:0; RULEID:(400006); SRVR:SN1PR0301MB1597; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1597; 4:SKEdy0+rtTzdPBqJnJySKjeek7+5rFoZQjBwz8WNV09wGCvGi08sIy48cob1tnA/FrMUbcFsIlzhYVOAzH4U4FbVPiqvL2PilQRnW9OVXJ0S9uASM+hquOkJC0BmOZ58CYcNFuh37pGg9B+UAtx8xbMkozH5qFfmPi0QlLun5xh4iPf/f/xGlcXRNajeJnd/btHpanqU/7Of9e4R+MVoC2261uOcy1DDhGmGQpfHVLxfq0vfFsX7MlrHo+Bw92lwm1aBAder/J5zBX9PCC5EeHDAXhejZKOTsUb04tPaid0UM8rw2djMEaVIJJ4D7olz8IcdsDi6xm6LHSOKDhqKhzW/NTZWnPMPoED4dUJhYlhuJyKnS0ui2WkC9sx2aYx/xW7ipUKDxzCuFGR/+HzXD5xcUdpas3Ap725il/4gfsD+feM+HIrDKWugTEIK+N79SkoW0RnWW3ZSYHaOaY5MoA== X-Forefront-PRVS: 088552DE73 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB1597; 23:gVGY73yWOiPTB9sv8HDNJapXIsLiXeuMaTqy3/L?= =?us-ascii?Q?nC3W0xiKw1Flxqmdv8WwebKEwNsRUT7JSp5IACug2YU/QRBypo89/PM8hx47?= =?us-ascii?Q?EU/SrWoquIQYnlI4WfyQIbNYbjk9kH1BfSrlljhGBsT05oPQwi4iaJbhfrfC?= =?us-ascii?Q?Znkka122lAyGmu7Ke5brLFu9kLdxtN1nEbf6d9itYPYRloHPUWNRSDHBkrbW?= =?us-ascii?Q?mnBOpIEeqCR81M2fBrrR3Htm6WMcweGL+A0J7jTljqqr+7QpeNRDr9v42hxj?= =?us-ascii?Q?HbC5BTX1nExH6+yoourqx8H7kio+P9SoewAybMcYVE4sefhvtUsxwvWPFSJv?= =?us-ascii?Q?08OPSKbCZKYOm5LCsAj8NSl4nodMxPqds+OAnEaX41tpfKcJ9gyowkfgDFW5?= =?us-ascii?Q?gZ9Is9FuVXEssApQI+TMF0ZWT6wAc2ppFk+g/X/U9l+TL91P+iNt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wgL+x5lABolR1fJ1HkU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Mar 2016 18:32:21.3002 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB1597 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 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 memcopying to a (null pointer + offset) will result in memory corruption or undefined behaviour. Signed-off-by: Tudor Ambarus --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c index e5c0727..8dbbf084 100644 --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -593,7 +593,7 @@ int qat_rsa_get_d(void *context, size_t hdrlen, unsigned char tag, ret = -ENOMEM; ctx->d = dma_zalloc_coherent(dev, ctx->key_sz, &ctx->dma_d, GFP_KERNEL); - if (!ctx->n) + if (!ctx->d) goto err; memcpy(ctx->d + (ctx->key_sz - vlen), ptr, vlen);