From patchwork Wed Mar 23 15:06:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 8650821 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 4F5CE9FB32 for ; Wed, 23 Mar 2016 15:07:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BDFF20211 for ; Wed, 23 Mar 2016 15:07:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52DB120259 for ; Wed, 23 Mar 2016 15:07:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932243AbcCWPGz (ORCPT ); Wed, 23 Mar 2016 11:06:55 -0400 Received: from mail-bn1on0091.outbound.protection.outlook.com ([157.56.110.91]:22240 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932202AbcCWPGu (ORCPT ); Wed, 23 Mar 2016 11:06:50 -0400 Received: from BLUPR0301CA0013.namprd03.prod.outlook.com (10.162.113.151) by BLUPR03MB375.namprd03.prod.outlook.com (10.141.75.149) with Microsoft SMTP Server (TLS) id 15.1.434.16; Wed, 23 Mar 2016 15:06:48 +0000 Received: from BL2FFO11FD019.protection.gbl (2a01:111:f400:7c09::163) by BLUPR0301CA0013.outlook.office365.com (2a01:111:e400:5259::23) with Microsoft SMTP Server (TLS) id 15.1.443.12 via Frontend Transport; Wed, 23 Mar 2016 15:06:48 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) 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.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 BL2FFO11FD019.mail.protection.outlook.com (10.173.161.37) with Microsoft SMTP Server (TLS) id 15.1.443.6 via Frontend Transport; Wed, 23 Mar 2016 15:06:47 +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 u2NF6guo031386; Wed, 23 Mar 2016 08:06:45 -0700 From: Tudor Ambarus To: , CC: , , , Tudor Ambarus Subject: [PATCH v2 1/2] crypto: qat - avoid memory corruption or undefined behaviour Date: Wed, 23 Mar 2016 17:06:39 +0200 Message-ID: <1458745600-1448-2-git-send-email-tudor-dan.ambarus@nxp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1458745600-1448-1-git-send-email-tudor-dan.ambarus@nxp.com> References: <1458745600-1448-1-git-send-email-tudor-dan.ambarus@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131032192077925701; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(19580395003)(36756003)(81166005)(2950100001)(92566002)(50226001)(19580405001)(48376002)(85426001)(229853001)(76176999)(50986999)(5003940100001)(105606002)(189998001)(1220700001)(586003)(33646002)(87936001)(50466002)(47776003)(1096002)(104016004)(11100500001)(6806005)(2906002)(106466001)(5001770100001)(77096005)(86362001)(4326007)(5008740100001)(7059030)(4720700001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB375; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD019; 1:Lu2xmUiWnIJXeTI7vqgsxD/KmdIN9zBwLIkp+5uNWiKAyIwSbNpzo2RFgB5LTZOkZjDzjnimeAwrC84rFXKHTGdj2HZj9Jsl0kam4NTXhwuj7PalQssJ9VK292tlSXkQwDablZKs894vEjhKxhcjAM7VeBM9ceIHUD/QUpXP8o8Vbkjnvg6yjeomQJK446rzOEqN4SWbspEXAtgbCLatCWs0iZLe731bvMnzhglLhNe4F5LuMxVvQkyY7q7jBFqL8c5romA5gz7mkm2ctVEX85LrF3nCXgOjO/qdfpOUMfq68BlTSaNNLcDWWLyQfZY7tNvpm2AOwE8L5SqN3oV279tRKslcI691WtlLPRHxWaR3I4dnrKu6nsi+F7Nm/0G6BXRKbl824pwYoniNonA/c4HC4oOO7smpo37cXSxAAhtl1Czp1zTT2MHc+6WjcUvIWlF0LtKzu7NEanYvYr9ps4Y/RZft0MjtuuFPldPFlDnrXpN5GJpX21A2xQ5jpF5LaQ0CFB9XeLXsg7PWF3Tz+BdwAU6b+dn/xBZrWcvc+4dapceXVkOzjs2eNoskpM3tWkkbOTT/67xXFdcwLJmP1KZ0EUD81nAQB/UfUUC2zazbYQ4M7El0E2hG1qGFq7yR2ujEqQJ7fVe6tP0hJK6f2PO5vz8l42n1qRMgdMfZVFo= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 7c5b70ea-9d5f-4483-abe4-08d3532cc166 X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB375; 2:QnS4l6aSrE/10BKfkRd6Z9RA59oIXQtBOREAs25+WbQ37SmlPvxosplQTCwP1mb2uSzp3Whgwbi9NZ5AOLbo5P9nsCss8QteOWMyjUyVPcA8HmPWJq+m8PXq1j7UTXjjaq+z2yx30e2XbhZ2q5l/QYIfnX/p3/An1Gdq9nXlCyG0fPRixpdh2irbli4n8bNc; 3:SPieyOgIZX0f+O236LUkx+NMDK0lSpebQXQk+VXP7HsFc07Je0Dydhhb/s9riO18c8ugllYgADU56iWtt6zHmgKrED6MtDqFQQ79iNfLY+8V7+8+j3QFNXVyYyw5qXRzNj3bdqeNzjpeSFCrz6cPnQ2KgehPkn6e829Kr3NV1rmvxlNWLmu8CUcsxXFvA4XPPAHyzX5ORu2kJl9IuwL+E0hc9Q+oEr/qCFYrFHKdkHE=; 25:w7UWTLDKk6owe9g0HENM4kseOE8CLoGvhUH7UUkB0Mxa6oCk/3C/dMHIX93YTVOm3ew34pOUG9IG8E8CYU5uTBeUVIamorAwGfGqIVnLeE1JYxwWaEJ7FaMszaUDh09YovfQBlIG1I29KPxL+0xeha8w4f4PU7g7zNLQtiF2qcXW8npLtos83/tS/g8lEvTD3AP/AhbiXxDU7mXipsD+x9oMR0lD0+ol8L9RR1s8m1icJzfYI7Yx2MjERunR4AH2u8Lb9RjmEFmcFpFo78rdn7ZHkwDxOz8M17OHOJEs0gq/Pr7xuToQWMzs45C+4p9Rq+wDqADY0lOg8eKLREShjw6DL3PV29znn5djoqSGHi7UrjpDjhdZd6OPl4SqGCW7LDPY0Ed2KCjBXxpU2h/jlSx1KGDhMf1ceCpMh5D4i+3ZyH+9smayHCejegsMSFwmyb37+bHdCAd7CDcOyYreE+i2Tdsyt/whnfftAt1gEs0k+UPEF3jGiaLu oq+ZfK/kDk0J0mEPX7UyCfUSzbE04A== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB375; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(13018025)(13017025)(13024025)(13023025)(13015025)(8121501046)(3002001)(10201501046); SRVR:BLUPR03MB375; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB375; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB375; 4:NPxcdb9PdkKWJdHVMV4Fbs5ot+1nebFxcOtujJXsav4tzYWcMwjbZMwn/pjKTBmvlC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yd20LHmty00kTY+9S3cBb0ZzleiXxbab?= =?us-ascii?Q?8YZBfo0ivOOnG/eJfHZVVn7ox6o/DbmHqehZkKplnjPVxmIs7dSGNgDFgQFl?= =?us-ascii?Q?2/5aVM+wFHSny8UXg4UFV0Pu7jA+hN1XwVeGIPvYKITy8V7MySNzOWaRC9K2?= =?us-ascii?Q?P34oTJ+fU0wAD9xD62glV0JHxRW3OtPokZtyoHCNZqiLotFhW+ONzZNe91Cn?= =?us-ascii?Q?aQLHQV2frNpLFNY1/H9Vc1mYf2dmxtxyGR5g0eA1udxGlhSRqYvVXT6k/RKy?= =?us-ascii?Q?h2LnNLr/3BC/Vw0BEW7awUofa09KxT2+joInuKaGcqqhGkTNjXtOnXA3NwEP?= =?us-ascii?Q?iQVg6HmWYszhylHja+Pgb22RdYzu/l5cDr+Eqxg2H2qQJ4iHL291w3iMLl/S?= =?us-ascii?Q?4UxCwdyBLlIXKW4KxD2ngloyHARCeIVpNF61XctgANhcXcc91guzB4UYQnsc?= =?us-ascii?Q?BTbazGtaEA8lsIK9sdh/gEVvrnkd1A/2DVAaYUeNYrBoDfIx8oQsIl9MDPvF?= =?us-ascii?Q?Xn6n9dATIlHP3otkMs45f5Zd09eA93m56JMsbkA20IZta82E36NDEaz+J3OW?= =?us-ascii?Q?AAhtWtyT7JiJDDm1tdsTrYe77H?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB375; 5:ksjZZx63H20495IagBLb8T4UYFBghcP8dkKjU2M5UbANID8GULYmEQT5dLT0mm9mbksMaukZe+1+vVmh6VK5NqKpxR5eV/poaaNpKliVFTfi+zMY/bHsplkwObCqs2lmY02znlXloGMG5KFTIyhd/S0om55UqR07hNDEb6J436I=; 24:LDa9GrsB6hlMb8rENhFvZXQfiZFt7eKI5esmnv/5XZAH+QOgKZ8hDBI6YsRr9bhPlekOISS0qi2LNEVTa7LJZikcRZXOpCNqm0oEeF99rE0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2016 15:06:47.5273 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB375 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, T_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);