From patchwork Thu May 25 01:06:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 9747475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2610E60224 for ; Thu, 25 May 2017 01:06:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1600B26E98 for ; Thu, 25 May 2017 01:06:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09456271BC; Thu, 25 May 2017 01:06:52 +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=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 6EB6226E98 for ; Thu, 25 May 2017 01:06:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162240AbdEYBGt (ORCPT ); Wed, 24 May 2017 21:06:49 -0400 Received: from mail-by2nam03on0083.outbound.protection.outlook.com ([104.47.42.83]:43452 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1162417AbdEYBGo (ORCPT ); Wed, 24 May 2017 21:06:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=wftbZ5cOnziwLXlpK6qUELB4MvM9KaC/LtIhF0S7ELE=; b=Rljh2w0Qzg9Us3MUb1WKasacwVULcFWE0hPaB4JkDdIaI0E4u17K57G3i1JvsqS7s1Q2J1rcx/wmwoBdJ/+9sZIhXHPTXiJko/ApuNyFg/HQIKRwUs+MOjPchHRU3kBGhbz0fJVPAmmcWfZ3GJvbWo2XCwi5JCYsyCUy3T/lihM= Received: from DM5PR07CA0046.namprd07.prod.outlook.com (10.168.109.32) by BN1PR07MB422.namprd07.prod.outlook.com (10.141.59.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Thu, 25 May 2017 01:06:42 +0000 Received: from BL2FFO11FD026.protection.gbl (2a01:111:f400:7c09::137) by DM5PR07CA0046.outlook.office365.com (2603:10b6:3:16::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9 via Frontend Transport; Thu, 25 May 2017 01:06:42 +0000 Authentication-Results: spf=none (sender IP is 50.232.66.26) smtp.mailfrom=cavium.com; vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=cavium.com; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BL2FFO11FD026.mail.protection.outlook.com (10.173.161.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1075.5 via Frontend Transport; Thu, 25 May 2017 01:06:42 +0000 Received: from dut1171.mv.qlogic.com (172.29.51.171) by CAEXCH02.caveonetworks.com (10.17.4.29) with Microsoft SMTP Server id 14.2.347.0; Wed, 24 May 2017 18:06:25 -0700 Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id v4P16PO8008949; Wed, 24 May 2017 18:06:25 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id v4P16Pc1008948; Wed, 24 May 2017 18:06:25 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH v2 7/7] qla2xxx: Fix crash due to NULL pointer dereference of ctx. Date: Wed, 24 May 2017 18:06:24 -0700 Message-ID: <20170525010624.8886-8-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170525010624.8886-1-himanshu.madhani@cavium.com> References: <20170525010624.8886-1-himanshu.madhani@cavium.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:50.232.66.26; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39850400002)(39840400002)(39450400003)(39400400002)(39410400002)(2980300002)(428002)(189002)(199003)(9170700003)(76176999)(101416001)(5660300001)(4326008)(50226002)(8936002)(38730400002)(1076002)(50986999)(47776003)(305945005)(8676002)(5003940100001)(189998001)(86362001)(356003)(54906002)(72206003)(33646002)(478600001)(106466001)(105586002)(50466002)(48376002)(42186005)(87636003)(80596001)(2950100002)(81166006)(2906002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR07MB422; H:CAEXCH02.caveonetworks.com; FPR:; SPF:None; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD026; 1:En1B8uSuDJw2vY48nzly0MvjPoEszJrSLgaHvlKoEz2CLYTByRaoeWS2XQfB2Uy9qVwWnasHUUd5dQ5wkjMkntXw7u3hICDe417Xa1A42IUVWVnjrwxvjOBgxMbeqJiLyeHBJDzQjKBWkwJxGXxv2ZzMZELIXCEX87XDcB/J+XuiFpni52UO30xVtlXbE8erLRV3xeFVMYxd6gh5DiU+yMeUjH/0/8c8HYaskuqv8Ipx/jtPrbl34b53kB2FaEKR556UamIC8x7ytINmUj/NgHhlFcxqGQfVSRoRYwX4Bjt/VC/O79NRX+0MGTH0UU7XAOg63l0SoIMhUoKRoMwvp4FSI3l3jAuakP7BrRuEAj7UBFF4Ekc12TCaSD+026cZrV0hkVXUm87/AQLI3WNWJM1dK5RsSx1gCy7OqWeKTcWEqGc8Akwh/3zX63c1g/gRecFep4mtwe6q/+EfXkxETDwSAkBRl5+CaS8k/VVEYuJqwFWjDzVMM25bl/JAxLfe X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PR07MB422: X-MS-Office365-Filtering-Correlation-Id: c005b335-de05-4a0c-a1f8-08d4a30a4e54 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BN1PR07MB422; X-Microsoft-Exchange-Diagnostics: 1; BN1PR07MB422; 3:8NzfB+XSm4DR0BQKtzO9hmydFzXRTmNhEf+ZtO3YCcpLc9KDEvs5t4BzaSGWU2xFfSTZ1Kik8Za6ZVSvNnNAkVMADc8DXLxldE55L4vmtZ+h/ZDJydDQXWxh0oPHYknTWSVmlWcBnzGTDYuPVPLFw59QUioQrOKC7BhDQri9IAr8lijKtZMzfsnNIJDj9TsheTT4kpNJXVI2bLAdKLGh4F09TXbwtuiwa1ULLv7QivGf1QOeQk0DbyvSWq8f1s0zHgSZ/HrxfZqX3tAUkrWlqdzfVSVd72BJ9Uqp6Rd1pYa8igbT8dEcR83ywAPvi/0VhN0D2RjxYhasN9SVuOId772776tvVe7n0VtbH3fsi3mm8ouTB32qRbUZ48DNu0Ry3Cy1mLF/X+MawmnO1o8dy8G54Lmryg0kc+GaifxVsVHbA/M0D0sV5JYW0uF5nUhnMAApYScrMG6oEKNLV0fvHMZKybgc6aNnz3MsU/yRzF+GRgdInLxxcf/am3Kr2ct0 X-Microsoft-Exchange-Diagnostics: 1; BN1PR07MB422; 25:ZJI7VNOKGqAw3wSPwT57acOCx91f/4UJmtmIvwt1X/4ApkRXk7kHaVeKDGX4BUgpnlNFIFjv5umNzIZSS6VIHN4L14YzbirW4ErkVO0Fj1byhqmebGw+4KTu6UEv8CBiA2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f4948oMxb+/EtF8f0o8YkUfEp/IV9Vl2WoFcy7XO8kBeuHJGsQdDbBjNwkduq5Oa1+itH1CTrPp+fqhdhrWm7AUnbnuGutGr2R+yR8J3916o X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(131327999870524); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(5005006)(13016025)(13018025)(8121501046)(93006095)(93001095)(3002001)(10201501046)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148); SRVR:BN1PR07MB422; BCL:0; PCL:0; RULEID:; SRVR:BN1PR07MB422; X-Microsoft-Exchange-Diagnostics: 1; BN1PR07MB422; 4:c2Ic39/+goMW18bOdl3J4xPsGRCKePNoz8hM9YTaihqe1zVVFns1blSb/VPX5uUlmoOGpqikFPJZb42MAl+s9mQh23kBf/Ah2MDw5+rRHJ1C+wcxZH/HOS4+4XFAel0IJBuc7wWqN7p//cCndEgdle/UODNOoA4dUmO/EFNJx+pEzmF8ziOgF7GX22v42QPm5dvRKziQbRli2HQPhSnCfPEcCdCTkvA5tTcW0qaWxkV2IxxF9oDFyOSFbzEMjQ+l6XmqiKmnDO7r/Pd2yqcsE2PWgnWghVKT825pqIZZ6RKx2CaTJ4+yGHdlaPjMv1FlTpgmg3EAisg5I52+w5TocSZHUxRrYNJRf41OJfCGg80/3BMX+jcW8pCOEa5U7II3kaIR2+C+/i//DtofHDGt9d5NeAlRWYMFNGYzux2jmqdrpdWi+h42hkN4kGt37EJ+vQxjDOxScFMeMA49oIhxeIT+MX/BXwsjIv73DWPKlUV8NvC4CXBdp6F0evrwSiBAttpbzRYQ3iCLCBCUSCgV3MP0B7Bjb6J8MgN5VUsCton+Y9Cqw1PHdI8i18J1w5EJA/DU1wcGOQH9i0kYKzuTyw8v3ieNI8YDShJw6wEMfihyfRZl53nNAaYBXasMBDwZdaVoXlt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CSP6aXHxWa0CuDsr8pt129ixv0X7B4xXR7pWxmWbrkTm2a7313JS3PJ?= =?us-ascii?Q?T5yO7H751wDU6JauiYIaC+QQg1PDN8u+cw4BlyA9VhKC2VyRWz178DepBOMe?= =?us-ascii?Q?lU8YSvXxrMtoKHaisMRJPzC1UHNxb29z9XGGqXMvWDEARQCdH8NMOzkAvW3/?= =?us-ascii?Q?h1t7FqzSwAs9+8yV5yv8lsw+/WWGWc5AtRtBceCnY33KG0H1+b0jCA4kze9L?= =?us-ascii?Q?Ra/fOm/wTyZ+CRJcU8SflW7ugAg5VdfGFka359UoowfPJqrrVWiqOnbZW8qj?= =?us-ascii?Q?rsvHkrwW3R0xeI5oouaqqYG183x+OliDvS96lLirhONXnY4O/sSkwD8q8yWZ?= =?us-ascii?Q?sZGshrMws5uS93XnO8zoRutWlxYXQEGXvmR7Ft4aoCuZEAq3i0X7o6wmBCJT?= =?us-ascii?Q?qlOFO0LDrveLx9bPrqMo7AJZFmDdXti1B7aZoTrZcg1/T7dH5Jk9gmonImDQ?= =?us-ascii?Q?8VHanz210OjuT1PyM7eRl5aH17?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR07MB422; 6:gIdSL6sYhHke3t85eLAXhlCE/V2goyprJbrQMhgFcP9h7OATReT+Ja74ElKHfBcg6maPLqkQ0RQgQdzHfLgKtDlGykulJAnHYJJp0s8hHDV7qWQfVsQnRe2+GzJP8lpy970NxghEak6hN9AviOp0b1jfwI4WRF/M06YmU+tj99eeaAh7Swgxp/9cKz5seej3OK7gfXHXchSlynRYC/KrQ1+b4P1R//lyCxn/21u1tWqhdqREHSUR3X4XzbbR/KsevoI8gv/9EEu5S6iThuaMA101xYzgkk9f2r36rdtQ+t3sKBqepevVg6+RrzcZ9byWosy6ri5bXtsUSfwjLLZgaI7zJQjnvgfQnVpNhDvroQdyqcEIpOQnht1qgldn5Iqsy6yNMa6wu5On8ne5xDUahHvHZPF0e3GPx6kaPobuEt882FMJ1/yA0fAiTlQEQTymbjSDoimxZxIAcupFzMBQX6HaYUyvgIluDGvtwJspiqCWmFHGFGXftm6aZVOjcJ/cLSDCA9UhSl/1qhZj5iPjdw==; 5:ZIjs3Xz+tOcm+0wzoGuut+0tqNubn1/mbHsFMO2BaKVHosD64aFKpDgT0czXKRoLwF5Ub1Dv0d1SQUaLCl3sVTKNH3pFMufYgtbJj+llRzYaeiViuDfm7jCUGjqceFIXhii5QOoMNjSvnd2G31NJ2g==; 24:Jy+qftgZbO+zLaAS/ybjMW3WdNZA+KF6yELPdHOISyAMfHpf7NCo5W+dHas1DWx1fDP7olU7A/vn05WCES0z6fX/1CcY69bk2SD79gjyISo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR07MB422; 7:y19UudMB7P43534bFqKTWNUIv9HtZ/jfhfqwqiDBfU805K4aat7lugSZC5c/TvaBHAh879nG5/mkFjWvxCNFxrKoIpnTZ7vUUWtoCYxdD3i96hBeV8sfWC60dawBDGvfSLgvWiv2NGtAaQR/k0GnxmcJ1t2mFtm+yWEN8G04Jcg6nZbPPDcCRJkHb6n4+HBEQe3o1RmN/Yu2PTPiiK1z9mZMfdfI10JC9ZXj2XJwmqj/pAkeljWTOKPoGKmYn1mpfjOhBhrBePJS77FAGik0YTwk5TcP2bPQcthUATyofA6OkMfivvuSByqIRFh2qPuFcmhUAIuqZLsXNl38URPAXg== X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2017 01:06:42.1196 (UTC) X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=711e4ccf-2e9b-4bcf-a551-4094005b6194; Ip=[50.232.66.26]; Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR07MB422 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Joe Carnuccio Fixes following signature in the stack trace: BUG: unable to handle kernel NULL pointer dereference at 0000000000000374 IP: [] qla2x00_sp_free_dma+0xeb/0x2a0 [qla2xxx] Cc: # 4.10 Signed-off-by: Joe Carnuccio Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_inline.h | 26 +++++++------------------- drivers/scsi/qla2xxx/qla_os.c | 30 +++++++++++++++++++----------- drivers/scsi/qla2xxx/qla_target.c | 8 +++++--- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 66df6cec59da..c61a6a871c8e 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -129,28 +129,16 @@ qla2x00_clear_loop_id(fc_port_t *fcport) { } static inline void -qla2x00_clean_dsd_pool(struct qla_hw_data *ha, srb_t *sp, - struct qla_tgt_cmd *tc) +qla2x00_clean_dsd_pool(struct qla_hw_data *ha, struct crc_context *ctx) { - struct dsd_dma *dsd_ptr, *tdsd_ptr; - struct crc_context *ctx; - - if (sp) - ctx = (struct crc_context *)GET_CMD_CTX_SP(sp); - else if (tc) - ctx = (struct crc_context *)tc->ctx; - else { - BUG(); - return; - } + struct dsd_dma *dsd, *tdsd; /* clean up allocated prev pool */ - list_for_each_entry_safe(dsd_ptr, tdsd_ptr, - &ctx->dsd_list, list) { - dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr, - dsd_ptr->dsd_list_dma); - list_del(&dsd_ptr->list); - kfree(dsd_ptr); + list_for_each_entry_safe(dsd, tdsd, &ctx->dsd_list, list) { + dma_pool_free(ha->dl_dma_pool, dsd->dsd_addr, + dsd->dsd_list_dma); + list_del(&dsd->list); + kfree(dsd); } INIT_LIST_HEAD(&ctx->dsd_list); } diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 1c7957903283..c8282a1ab6dc 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -630,29 +630,34 @@ qla2x00_sp_free_dma(void *ptr) sp->flags &= ~SRB_CRC_PROT_DMA_VALID; } + if (!ctx) + goto end; + if (sp->flags & SRB_CRC_CTX_DSD_VALID) { /* List assured to be having elements */ - qla2x00_clean_dsd_pool(ha, sp, NULL); + qla2x00_clean_dsd_pool(ha, ctx); sp->flags &= ~SRB_CRC_CTX_DSD_VALID; } if (sp->flags & SRB_CRC_CTX_DMA_VALID) { - dma_pool_free(ha->dl_dma_pool, ctx, - ((struct crc_context *)ctx)->crc_ctx_dma); + struct crc_context *ctx0 = ctx; + + dma_pool_free(ha->dl_dma_pool, ctx0, ctx0->crc_ctx_dma); sp->flags &= ~SRB_CRC_CTX_DMA_VALID; } if (sp->flags & SRB_FCP_CMND_DMA_VALID) { - struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; + struct ct6_dsd *ctx1 = ctx; dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, - ctx1->fcp_cmnd_dma); + ctx1->fcp_cmnd_dma); list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; ha->gbl_dsd_avail += ctx1->dsd_use_cnt; mempool_free(ctx1, ha->ctx_mempool); } +end: CMD_SP(cmd) = NULL; qla2x00_rel_sp(sp); } @@ -699,21 +704,24 @@ qla2xxx_qpair_sp_free_dma(void *ptr) sp->flags &= ~SRB_CRC_PROT_DMA_VALID; } + if (!ctx) + goto end; + if (sp->flags & SRB_CRC_CTX_DSD_VALID) { /* List assured to be having elements */ - qla2x00_clean_dsd_pool(ha, sp, NULL); + qla2x00_clean_dsd_pool(ha, ctx); sp->flags &= ~SRB_CRC_CTX_DSD_VALID; } if (sp->flags & SRB_CRC_CTX_DMA_VALID) { - dma_pool_free(ha->dl_dma_pool, ctx, - ((struct crc_context *)ctx)->crc_ctx_dma); + struct crc_context *ctx0 = ctx; + + dma_pool_free(ha->dl_dma_pool, ctx, ctx0->crc_ctx_dma); sp->flags &= ~SRB_CRC_CTX_DMA_VALID; } if (sp->flags & SRB_FCP_CMND_DMA_VALID) { - struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; - + struct ct6_dsd *ctx1 = ctx; dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, ctx1->fcp_cmnd_dma); list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); @@ -721,7 +729,7 @@ qla2xxx_qpair_sp_free_dma(void *ptr) ha->gbl_dsd_avail += ctx1->dsd_use_cnt; mempool_free(ctx1, ha->ctx_mempool); } - +end: CMD_SP(cmd) = NULL; qla2xxx_rel_qpair_sp(sp->qpair, sp); } diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 0e03ca2ab3e5..e766d8412384 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -2245,11 +2245,13 @@ static void qlt_unmap_sg(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd) pci_unmap_sg(ha->pdev, cmd->prot_sg, cmd->prot_sg_cnt, cmd->dma_data_direction); + if (!cmd->ctx) + return; + if (cmd->ctx_dsd_alloced) - qla2x00_clean_dsd_pool(ha, NULL, cmd); + qla2x00_clean_dsd_pool(ha, cmd->ctx); - if (cmd->ctx) - dma_pool_free(ha->dl_dma_pool, cmd->ctx, cmd->ctx->crc_ctx_dma); + dma_pool_free(ha->dl_dma_pool, cmd->ctx, cmd->ctx->crc_ctx_dma); } static int qlt_check_reserve_free_req(struct scsi_qla_host *vha,