From patchwork Thu Jul 26 14:37:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Lendacky X-Patchwork-Id: 10545993 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62F551822 for ; Thu, 26 Jul 2018 14:38:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5211F2B0CF for ; Thu, 26 Jul 2018 14:38:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 464FE2B41B; Thu, 26 Jul 2018 14:38:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2E682B0CF for ; Thu, 26 Jul 2018 14:38:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731304AbeGZPzQ (ORCPT ); Thu, 26 Jul 2018 11:55:16 -0400 Received: from mail-eopbgr730073.outbound.protection.outlook.com ([40.107.73.73]:33184 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730030AbeGZPzP (ORCPT ); Thu, 26 Jul 2018 11:55:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f81XLBbOZwRGj6mhr4rDjhQMj3DYWnghpPnN1/5As08=; b=CYr7pfGGoyBFm/wz1oxh4yBSjj6U9GWqjT0ey1FDnZh2sdHuXarqwKIzEMfSP3UFis1bBsPCt1uclcojcJfXP7L/99RjGk4cC0Bg+QqhONrlOxp6wdXpZwk4/xHRen32Ki3gKXWv22cKjJemCQ3iHX9FbgZs3uMhsyCXWLeIstI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from tlendack-t1.amdoffice.net (165.204.77.1) by CY1PR12MB0168.namprd12.prod.outlook.com (2a01:111:e400:50f6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Thu, 26 Jul 2018 14:38:03 +0000 From: Tom Lendacky Subject: [PATCH] crypto: ccp: Check for NULL PSP pointer at module unload To: linux-crypto@vger.kernel.org Cc: Herbert Xu , David Miller Date: Thu, 26 Jul 2018 09:37:59 -0500 Message-ID: <20180726143759.20737.10855.stgit@tlendack-t1.amdoffice.net> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR2201CA0049.namprd22.prod.outlook.com (2603:10b6:301:16::23) To CY1PR12MB0168.namprd12.prod.outlook.com (2a01:111:e400:50f6::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71fda101-61fc-46de-193a-08d5f3056568 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:CY1PR12MB0168; X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0168;3:IFvTWHERB5ndjgG/GoNai9+EbdHN5clyU7W14l6a054je3jbJfgTmVdFL7QIaXbSEqj4xPo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DnQf00lbsuiEMxJYUqytvmUfiy+dfDxxe7v2hyVTmMYaabVY4gdzvZOjHtfAQXNxMm56Z4AstOtRNwMq7xdKsnCTIEEpe13Wk/7U8fTbbFPTerjZu5wvItg+8RE35o0LfHniTBQ6tOIrrOMMeXRA+Xj6KfYhfsjr40rgM5PQ/pHV0FuNXK5k1kzGdk8CMCxlsr6Q+vYRCwAn1mCLAhUncsfd5wzZbj966j42799cXFBuD/m222Rlj43IfwR1TADmTNva5Cs7l4Rf8/CmK1jTIn;4:NF3gC7JW0ZDb7Z4/B3ueRnL16sKqewHvB86XW7qIiY2KM4oCH0y4N5gboJm4gGuPuuOld+OhUMAaToEz8P6o9cpvwMFNIOAkO11QqVwzohMyfoGqPSzBjsuyscuZ4Fo2MANU3lxLvA4K2UcSEV2w5bYzf+enwTshtgU0/f+R7G+pCkQ4VCWtMxD1j1Wtz7wovjUOfDWfUgYUV6/TgXYkJn15uEdZ1eTLOnBbKDZ1q2+yvZZEEGmEehaI6wwnJM2VIlDo6may6fmZwwCZy2L5JsElU5s7TTqjfhKDNRrqwChIiTHbY0sEtl5bNuBIIw7RZdCQvengN5IGHU16mBHh9SQrbLTqW5pfUqeinISgfuSB7j6iylhCxS938YsTmWqM X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(9452136761055)(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:CY1PR12MB0168;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0168; X-Forefront-PRVS: 07459438AA X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39860400002)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(52116002)(386003)(4326008)(6506007)(53936002)(305945005)(68736007)(2351001)(7696005)(230700001)(23676004)(2486003)(97746001)(53416004)(105586002)(478600001)(86362001)(97736004)(6666003)(69596002)(3846002)(6116002)(25786009)(55016002)(486006)(1857600001)(1076002)(9686003)(58126008)(5660300001)(476003)(316002)(14444005)(2906002)(6916009)(8676002)(186003)(16526019)(81156014)(8936002)(81166006)(66066001)(47776003)(106356001)(26005)(103116003)(72206003)(217873002)(54906003)(956004)(50466002)(2361001)(7736002);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR12MB0168;H:tlendack-t1.amdoffice.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BCY1PR12MB0168=3B23=3AudIscNx?= =?utf-8?q?a5eEEARJwGyoB19D10ebKniDMMuxReaOEc2V8qp7us8YulCS5zoslLY/OVGtPY3il?= =?utf-8?q?Bt8g4bJcIHKGdwBEAD9HiWTsK8YfodeHx0dx1BvaGPj1VbOWOZXo7J8bv0KbWM0f1?= =?utf-8?q?ot61ZStcP91Tz/0DLiy58ekHV5BA82D9qk2FLC00d2p/pkCwPib7zmrBmqyOdqo2L?= =?utf-8?q?rO9g6V89rJiOUXWBVuU7MfAOUoj16HGE8i7YkxZN+xK4J477XlndWaRm7ZaCCJi+Z?= =?utf-8?q?RjL9dPNWEwxtTY6iqzuYHA5YMZNjU5xxLtoQ3zkTYUVYJhQBLNN+bI0BkxVmzytUS?= =?utf-8?q?XP9FXDTRNsZhgm9cN1w+GKK5iRtM/5K00vqGpcpmsZaVkSC2HayGFArYlih4plIKP?= =?utf-8?q?/54C6mJBt1g6ecoqbRH6H/9+tAiNPrX4sfL0U1qEyYYDrxUmjaij/Lm9DjHMXzNix?= =?utf-8?q?5tfsLGWCdDPtcNhyFve19evu9wkVQ9+WZiE1m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h7o7+dR2Qv0NXjvuX39AVEqqtXbyMDQougj8WRNHZldN03i2AeePLKeJ/wNU2cglK8GoMFabEpWOtf01qyc9abKu+6GtgNJ1HQyDR7dP04OtQaMvP73hLC7NihN8GALKFz1lgn5HfbqhJcv6i2fxqHKV3EGIWJUw/wVxZ/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0168;20:y9P1RHXRvorhY1rUQwlSfZi64ewkit1MFL9vxk4IFaegaLYRjFttdXELOdq03WnquweJGh1yyg4yHAZxcprKw5B6nVY0HWVK1gpK5vagW16dv9/jzPqCbPwtuwAJ5Eo8Bxd/ld6KaSeAttpwqL0CuJx+2k6ruEnh4P3/avUSGPlJN7IwoAqLoUahIlF7dkKDqzEpaIbKxGCJdat/hBJkn4T4MCx+RMXEVdubzMo9/v5Msfw/98RogestVnz9H8Kl X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2018 14:38:03.9343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71fda101-61fc-46de-193a-08d5f3056568 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0168 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Should the PSP initialization fail, the PSP data structure will be freed and the value contained in the sp_device struct set to NULL. At module unload, psp_dev_destroy() does not check if the pointer value is NULL and will end up dereferencing a NULL pointer. Add a pointer check of the psp_data field in the sp_device struct in psp_dev_destroy() and return immediately if it is NULL. Cc: # 4.16.x- Fixes: 2a6170dfe755 ("crypto: ccp: Add Platform Security Processor (PSP) device support") Signed-off-by: Tom Lendacky Acked-by: Gary R Hook --- drivers/crypto/ccp/psp-dev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index 9b59638..218739b 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -858,6 +858,9 @@ void psp_dev_destroy(struct sp_device *sp) { struct psp_device *psp = sp->psp_data; + if (!psp) + return; + if (psp->sev_misc) kref_put(&misc_dev->refcount, sev_exit);