From patchwork Tue Feb 12 23:40:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Madhani X-Patchwork-Id: 10808957 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 DFE491390 for ; Tue, 12 Feb 2019 23:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE3792C080 for ; Tue, 12 Feb 2019 23:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C28E72C0AD; Tue, 12 Feb 2019 23:42:21 +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,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 5DA652C080 for ; Tue, 12 Feb 2019 23:42:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729383AbfBLXmU (ORCPT ); Tue, 12 Feb 2019 18:42:20 -0500 Received: from mail-eopbgr710085.outbound.protection.outlook.com ([40.107.71.85]:58112 "EHLO NAM05-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729139AbfBLXmU (ORCPT ); Tue, 12 Feb 2019 18:42:20 -0500 Received: from DM6PR07CA0001.namprd07.prod.outlook.com (2603:10b6:5:94::14) by BY1PR0701MB1925.namprd07.prod.outlook.com (2a01:111:e400:51ab::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1601.19; Tue, 12 Feb 2019 23:42:18 +0000 Received: from CO1NAM05FT009.eop-nam05.prod.protection.outlook.com (2a01:111:f400:7e50::205) by DM6PR07CA0001.outlook.office365.com (2603:10b6:5:94::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1622.16 via Frontend Transport; Tue, 12 Feb 2019 23:42:17 +0000 Authentication-Results: spf=fail (sender IP is 199.233.58.38) smtp.mailfrom=marvell.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=marvell.com; Received-SPF: Fail (protection.outlook.com: domain of marvell.com does not designate 199.233.58.38 as permitted sender) receiver=protection.outlook.com; client-ip=199.233.58.38; helo=CAEXCH02.caveonetworks.com; Received: from CAEXCH02.caveonetworks.com (199.233.58.38) by CO1NAM05FT009.mail.protection.outlook.com (10.152.96.116) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.20.1580.2 via Frontend Transport; Tue, 12 Feb 2019 23:42:17 +0000 Received: from dut1171.mv.qlogic.com (10.112.88.18) by CAEXCH02.caveonetworks.com (10.67.98.110) with Microsoft SMTP Server (TLS) id 14.2.347.0; Tue, 12 Feb 2019 15:41:09 -0800 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 x1CNf9FB029882; Tue, 12 Feb 2019 15:41:09 -0800 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x1CNf9DX029881; Tue, 12 Feb 2019 15:41:09 -0800 From: Himanshu Madhani To: , CC: , Subject: [PATCH 07/12] qla2xxx: Prevent SysFS access when chip is down Date: Tue, 12 Feb 2019 15:40:41 -0800 Message-ID: <20190212234046.29809-8-hmadhani@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190212234046.29809-1-hmadhani@marvell.com> References: <20190212234046.29809-1-hmadhani@marvell.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131944885375876907;(abac79dc-c90b-41ba-8033-08d666125e47);(abac79dc-c90b-41ba-8033-08d666125e47) X-Forefront-Antispam-Report: CIP:199.233.58.38;IPV:CAL;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(376002)(346002)(136003)(396003)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(53936002)(76176011)(105606002)(1076003)(110136005)(16586007)(42186006)(4326008)(106466001)(51416003)(86362001)(126002)(6666004)(87636003)(498600001)(54906003)(2616005)(11346002)(356004)(26826003)(69596002)(80596001)(446003)(476003)(336012)(486006)(97736004)(2906002)(85426001)(68736007)(50466002)(305945005)(48376002)(8936002)(36906005)(316002)(50226002)(26005)(36756003)(81156014)(81166006)(47776003)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1925;H:CAEXCH02.caveonetworks.com;FPR:;SPF:Fail;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;CO1NAM05FT009;1:YrOzEwEh9NCoBd4N1oSTF7rPpqbwaSp2kaAmy3yDCL3syMQD7j0iZAAgJ62gBYw+yVEmvDbsA6GB3T8U5wTjXHizJzi01ZFHY2Dx9wvKfw2Sganz99Cma+GkgOiyVMRaB4meaOrc3XPBV/ipc25CMRvWiT9hK/wb2PTDMx0jrvk= X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20d8805d-ad24-46dc-c9ce-08d69143b938 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(5600110)(711020)(4605077)(2017052603328);SRVR:BY1PR0701MB1925; X-MS-TrafficTypeDiagnostic: BY1PR0701MB1925: X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 0946DC87A1 X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1925;23:Hn9YMibhezHmBSqTcN+7ua0Qo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uOQqKhWqIZJqRauJEGAdPVXwQC3v+XYGB+2Kuw6tSTKzpPnMYSl3URrnG6BwDuPqq8eSkVnDOvad4kw8IE5778OLCcyMs X-Microsoft-Antispam-Message-Info: ZcLk0ozSv/ynX7mhn3scV+tyFvmk1DuDzbBr3tsZX6UwcJWyEyrcB7QSs1bsrc5MAr+A4Z624hW8BOjtkqjk0SI0o6KjtoqYQQAhdKk+Y3zp9ImGwW6iYVJ6xI8TB6GSkT5/4I0P5B6sF3HazHgA9RcmsZ9jPwJw7BgcAARkTlscHjazccMWrcMO7o3l66tGGHbV5nf+cbt2TZJvbPMUaZzSvCPl1PKtnR5WG0b8KkPkv8AroZun6xaxAzPkiAhiqWaQ003QlCvqXQRCNJBdgsdsIwHai0BbZS3qMaVJNEj75wbdxZRGBVE4/IlmBpNmN9bd9a+KYHGwn21L61HWA/3UgSSp98/BmuCv3xGgR3LIYCS547cIE6fScR1AHR5GEhDI3UTcuhygWLHNMen6/huQec0oniIeInhyvdKb014= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Feb 2019 23:42:17.2894 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20d8805d-ad24-46dc-c9ce-08d69143b938 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[199.233.58.38];Helo=[CAEXCH02.caveonetworks.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1925 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 Prevent user from sending commands through SysFS while FW is not running or reset is in progress. Signed-off-by: Quinn Tran Signed-off-by: Himanshu Madhani --- drivers/scsi/qla2xxx/qla_attr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index dcdfcf3bc955..c4a129d049f5 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -543,6 +543,9 @@ qla2x00_sysfs_write_vpd(struct file *filp, struct kobject *kobj, if (unlikely(pci_channel_offline(ha->pdev))) return 0; + if (qla2x00_chip_is_down(vha)) + return 0; + if (!capable(CAP_SYS_ADMIN) || off != 0 || count != ha->vpd_size || !ha->isp_ops->write_nvram) return 0; @@ -993,6 +996,9 @@ qla2x00_sysfs_read_dcbx_tlv(struct file *filp, struct kobject *kobj, return 0; } + if (qla2x00_chip_is_down(vha)) + return 0; + ha->dcbx_tlv = dma_alloc_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, &ha->dcbx_tlv_dma, GFP_KERNEL); if (!ha->dcbx_tlv) {