From patchwork Wed Jul 18 21:29:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhani, Himanshu" X-Patchwork-Id: 10533317 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 5C0D6600F4 for ; Wed, 18 Jul 2018 21:30:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C2AD29A0F for ; Wed, 18 Jul 2018 21:30:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FA9429BD3; Wed, 18 Jul 2018 21:30:08 +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 4859929A0F for ; Wed, 18 Jul 2018 21:30:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730573AbeGRWJt (ORCPT ); Wed, 18 Jul 2018 18:09:49 -0400 Received: from mail-bl2nam02on0089.outbound.protection.outlook.com ([104.47.38.89]:52672 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726680AbeGRWJs (ORCPT ); Wed, 18 Jul 2018 18:09:48 -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:X-MS-Exchange-SenderADCheck; bh=PklGzjAFJwhBn4YR8cAzZSBVVwRk1eal8K3mFEee58U=; b=RFiZ5LbxAp8aHrtvGclHv1NEJ6sxeyoyohLtMr+HjzuJYBA9dhMVGAAcm6udYJcgcmx2eLd7dDpzFlU1KCeTwxBLRZRSq99MWl/ziDuOYfpWCKQGEeMajJN8MhSZQWftBARWlZ1i5alwMJs/uV2IVxbkRz8lBAp2k66Zy4BfcGw= Received: from CO2PR07CA0049.namprd07.prod.outlook.com (2603:10b6:100::17) by DM5PR07MB4072.namprd07.prod.outlook.com (2603:10b6:4:b3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.18; Wed, 18 Jul 2018 21:29:59 +0000 Received: from BY2NAM05FT008.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e52::202) by CO2PR07CA0049.outlook.office365.com (2603:10b6:100::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.973.16 via Frontend Transport; Wed, 18 Jul 2018 21:29:59 +0000 Authentication-Results: spf=pass (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=bestguesspass action=none header.from=cavium.com; Received-SPF: Pass (protection.outlook.com: domain of cavium.com designates 50.232.66.26 as permitted sender) receiver=protection.outlook.com; client-ip=50.232.66.26; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (50.232.66.26) by BY2NAM05FT008.mail.protection.outlook.com (10.152.100.145) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.995.0 via Frontend Transport; Wed, 18 Jul 2018 21:29:58 +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, 18 Jul 2018 14:29:56 -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 w6ILTunY013489; Wed, 18 Jul 2018 14:29:56 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id w6ILTutT013488; Wed, 18 Jul 2018 14:29:56 -0700 From: Himanshu Madhani To: , CC: , Subject: [PATCH 1/5] qla2xxx: Fix unintialized List head crash Date: Wed, 18 Jul 2018 14:29:51 -0700 Message-ID: <20180718212955.13450-2-himanshu.madhani@cavium.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20180718212955.13450-1-himanshu.madhani@cavium.com> References: <20180718212955.13450-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)(136003)(396003)(346002)(39860400002)(376002)(2980300002)(438002)(189003)(199004)(4326008)(87636003)(478600001)(72206003)(54906003)(42186006)(2906002)(2616005)(476003)(126002)(11346002)(16586007)(186003)(6666003)(106002)(44832011)(106466001)(110136005)(486006)(80596001)(316002)(36756003)(47776003)(48376002)(50226002)(5660300001)(50466002)(305945005)(1076002)(336012)(446003)(69596002)(575784001)(76176011)(356003)(14444005)(81156014)(8936002)(81166006)(86362001)(8676002)(26005)(51416003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB4072; H:CAEXCH02.caveonetworks.com; FPR:; SPF:Pass; LANG:en; PTR:50-232-66-26-static.hfc.comcastbusiness.net; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; BY2NAM05FT008; 1:jqoxbKUdEs7dnPkDWORincAu1XTlk2TzptmfqHJbuZDrnly3fhYHKEirA8DLt+L5dRd48gJgZUPs9bcekaOyfr71ChMef1rme6zzfSCT0Ay51pJRJlJB+QW1dLllGA11 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c11a4744-2332-4de0-5c9e-08d5ecf59d1b X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600067)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:DM5PR07MB4072; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB4072; 3:K3TCAxaJNUSstItWLz0cr8g9TTSbY2DW6ACgEYtpE60GcKAlZeSwzQJZjO1bMFnRwm9FZD9pJIj7wnKR+8dR3yCMnxzkP+PBk1Rql/Uc+g3NJa8cavIzT4AvdFTeBdNmD8HKGKGZungb38gdQ3G/oabI353lU+05dauFmlluEc8j4aMyklAU0SZFd1k7kS/972I1+pWSqyUj455oiKNKyf5bThSfboBiZfXO+MeyW6k5udAlv8HrMymD/zoqW0DUsCXE/Lw+5wsejdR55XWqajL+iCOM7y0QpnJD2VRWmliOhNRL+ldDulKhKhhix8llhapg5mQF9kSO4P1DxGwa65uH5s9MQl+xtNHST2cBwr8=; 25:vAZxNWIltPjJOtRcnHw3aWAIhkza1/n6H83iDGAePFOabPL9PTsLVu7OneI6EOly0pUPtqcKaSpeb2TUAC9rjFPiXxlIETU9Xl0PsCMRYPsaARq9hRv3FyTztH92RbNWGF+Sodf6i2/JCY66OOohNsVbYWSEo8K7GXVRlADVBZ/YyPH7OKAsUzxzJwgb5fz120RK8yrwJ1F2cuSoG7cLBntMunVahkn4anQYPPnki8Txf8+Yc3Rj0JJJMbVxNPg2fsorLxAi+Az/4k2B3YyWvcyWAkY3hOTUjq0/FM0yXdU+b1ba3Ud6a8tklJsiYyqwKtxRZGWn0pY59wKgAh4gRg== X-MS-TrafficTypeDiagnostic: DM5PR07MB4072: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB4072; 31:x+SCp0GFqxBsnYU+pcepoJHV5XUS3ujA1F8idA6Kgt1bO5n49qiUT1ir5pWEJPDhEfibheGgZxu2y7UixWqzBq1nopaS3Jmpj8QlKG16KxBjWTqBDSbqvR1zgI3P0qv+9ipvSyjlH8GMcR7pEnexjtQN5Y6jX4J5iS5l8X7Tk914NFvDIBKD/iro2dGMGZi3Wt19Nc4y/3rx/QUpEX4omRS2dvvY3BPrkRri7AlSoJ4=; 20:JcxFs9Jl2bZjgGMsMd+OTcLRelFiqsbqwPYIa0L2j+ICkotEdU0wggEWQWcd9Pql/T+ZVHrP4vfk+DqPpIzW11ydhlXXlVR8uL79hWeC3FiFJDxSbMmoZ5NG6wP3bmqstJ0zPzFH99W8SAbWxmjiUdHdb6WFkimD3ckGuUlBQqY8ItIINU9j9Seg9Wk6lYgSPGV+wol6wPSzRY/xBV1BNFqLRP0+VbdtL627tKPHq8qzGTrmE76AhZ3t7YxlTb3B8UIBXi5SoOCRyZY6hK3Ge24z2ISUo8P1j1Wg13AZCgQRByIKhX0sTSv05YLGiWTUsOcVijRtXiiW/S0lyM0QvzU8TC+9vb3g4qP6Soxs44aj5zC1L/IqI4r+/WphAXC9lgSe3OlJ6o0O308gRFKF+KH2m4PBa0RQ8GqRguoEpFEY2ET44EEBibExMmIlBBIrA+nuzKyj0cho+zq1okZDEVaedqIBnObyn9DJuvJyqi7pTN7dRFEP4iYDZQYV1HBX X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93004095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DM5PR07MB4072; BCL:0; PCL:0; RULEID:; SRVR:DM5PR07MB4072; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB4072; 4:Zim9wPyxX9zz6R3pra9A7H4D749hm4MvwwuFAkIcE4SJDZAcbHxeJSVIfrh24P8Ol8olyLuJaEihzYtKGgBSR9WcB/M9rEV5WuO51X1a7kUm86uMf3VWxndnDXmoH19xi9fxmnKzzupcnV1sUVo32lNardVfg/dRMc5hXiM95rHdHR+t+hs+2tjRuLWQl3AN/xWn38wK7Pax0xsnOkfvmhSzrvnvQE5SXIa07mMrCl8/Ghn6EYUuK3/85jFHNWJsR3WU5vWjEX64Kz6VrFNL9MnL1T1yv2fJ99m4/0C6Y6evnBMiRtao2T1292LwlQgY X-Forefront-PRVS: 0737B96801 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB4072; 23:GZ1HDxumBeOXOqlR1kA69bNKE2hWICpzIKpmT5fh6?= =?us-ascii?Q?aVRXILb70NMreI09/FdpGaOLxmwX0eJWfmj1E+7y1rzfBBp0MRdzM31nD5Bo?= =?us-ascii?Q?wuGBjeYxzdkM1hYnqk/v1x8qXVzkBIhVrMvKooRn379QMGeBf/vJpWdyjsko?= =?us-ascii?Q?MW1D7rP7A0svx541LCPe1SJXY3W4s2PaetiSed0Nn5CLLboxiqoRLzbdwA5C?= =?us-ascii?Q?CfZ5vzi5Mka/Xpe+aDMKlroBGZUxeqM5YJpoKK9Pa+80N690KE5H2zBIGYgC?= =?us-ascii?Q?ZF9NmAe2QRRc5nOBkzoaSKwsOuKQ3TcGGDaYAFhJnjyibqCEdvPpRh1wxdx0?= =?us-ascii?Q?6UQSeKj1p8mYX7TIK1B21rTDa2u9hXb4pKD/enVoY90ZaopdNmYHG97amSId?= =?us-ascii?Q?NwMd+4qjdMfLK6jTF8b//YA2265Lng4m3LbNKCUZLex7wg1+E4Ndn5rQ0x5d?= =?us-ascii?Q?mfqYBbnUN8kE3P3ZmuUyspbD9zWY562Xwq2HdVXjeZVyFZ85PcgK538PWRhH?= =?us-ascii?Q?hyJvO6M18NEiyK0MzigD5cCcd9tJk2lTMm8foeTQrR8xC01gxQTAgJF2Zno8?= =?us-ascii?Q?90fY69JXy9Iw4GnQ7o6x44ZjG3kib1Kx9TQ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AN/p/4WCst+ipam45pFQdebABHo1VRwrt/oZPAtl17JAWC X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2018 21:29:58.7720 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c11a4744-2332-4de0-5c9e-08d5ecf59d1b 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: DM5PR07MB4072 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: Quinn Tran In case of IOCB Queue full or system where memory is low and driver receives large number of RSCN storm, the stale sp pointer can stay on gpnid_list resulting in page_fault. This patch fixes this issue by initializing the sp->elem list head and removing sp->elem before memory is freed. Following stack trace is seen 9 [ffff987b37d1bc60] page_fault at ffffffffad516768 [exception RIP: qla24xx_async_gpnid+496] 10 [ffff987b37d1bd10] qla24xx_async_gpnid at ffffffffc039866d [qla2xxx] 11 [ffff987b37d1bd80] qla2x00_do_work at ffffffffc036169c [qla2xxx] 12 [ffff987b37d1be38] qla2x00_do_dpc_all_vps at ffffffffc03adfed [qla2xxx] 13 [ffff987b37d1be78] qla2x00_do_dpc at ffffffffc036458a [qla2xxx] 14 [ffff987b37d1bec8] kthread at ffffffffacebae31 Fixes: 2d73ac6102d9 ("scsi: qla2xxx: Serialize GPNID for multiple RSCN") Cc: # v4.17+ Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_gs.c | 4 ++++ drivers/scsi/qla2xxx/qla_inline.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index 2c35b0b2baa0..7a3744006419 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -3708,6 +3708,10 @@ int qla24xx_async_gpnid(scsi_qla_host_t *vha, port_id_t *id) return rval; done_free_sp: + spin_lock_irqsave(&vha->hw->vport_slock, flags); + list_del(&sp->elem); + spin_unlock_irqrestore(&vha->hw->vport_slock, flags); + if (sp->u.iocb_cmd.u.ctarg.req) { dma_free_coherent(&vha->hw->pdev->dev, sizeof(struct ct_sns_pkt), diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index bcbdf28bd7b9..735f122607f3 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -220,6 +220,8 @@ qla2xxx_get_qpair_sp(struct qla_qpair *qpair, fc_port_t *fcport, gfp_t flag) sp->fcport = fcport; sp->iocbs = 1; sp->vha = qpair->vha; + INIT_LIST_HEAD(&sp->elem); + done: if (!sp) QLA_QPAIR_MARK_NOT_BUSY(qpair);