From patchwork Wed May 24 00:33:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9744723 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 83A0D602A7 for ; Wed, 24 May 2017 00:35:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A5928867 for ; Wed, 24 May 2017 00:35:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B8232886B; Wed, 24 May 2017 00:35:30 +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 9E96B28867 for ; Wed, 24 May 2017 00:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1765693AbdEXAf1 (ORCPT ); Tue, 23 May 2017 20:35:27 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:12149 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763364AbdEXAeb (ORCPT ); Tue, 23 May 2017 20:34:31 -0400 X-IronPort-AV: E=Sophos;i="5.38,383,1491235200"; d="scan'208";a="19885332" Received: from mail-by2nam01lp0177.outbound.protection.outlook.com (HELO NAM01-BY2-obe.outbound.protection.outlook.com) ([216.32.181.177]) by ob1.hgst.iphmx.com with ESMTP; 24 May 2017 08:34:29 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=AZp7LUTlbWBJPf37Bgch9IolYXFwgxJMNkvcFgwubGU=; b=D4ENIEgCeTWG0Xy4AQ8QwkxC8brmIu/EfLUBZbPJ8hyTmiytfZnmS3Xt6ket5wB1/w/4QnrbAjigfULIctUFtCMtoYEc0JfAAisujYWcJqMPTbh+aJkDmCKTqUKyIr0d/M0++OFcRC+0mHql+24NWTS7zwUr3SLxgCXgwzhXVYk= Received: from MWHPR04CA0078.namprd04.prod.outlook.com (10.174.173.19) by DM5PR04MB0364.namprd04.prod.outlook.com (10.173.169.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1124.9; Wed, 24 May 2017 00:34:27 +0000 Received: from CO1NAM04FT030.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4d::208) by MWHPR04CA0078.outlook.office365.com (2603:10b6:301:3a::19) 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; Wed, 24 May 2017 00:34:27 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by CO1NAM04FT030.mail.protection.outlook.com (10.152.90.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1075.5 via Frontend Transport; Wed, 24 May 2017 00:34:26 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id C7.43.45291.115D4295; Tue, 23 May 2017 17:34:25 -0700 (PDT) Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Tue, 23 May 2017 17:34:23 -0700 X-AuditID: 0ac94369-166ac9800001b0eb-f8-5924d5112629 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id 81.A3.18148.F05D4295; Tue, 23 May 2017 17:34:23 -0700 (PDT) From: Bart Van Assche To: "Martin K . Petersen" , James Bottomley CC: , , "Bart Van Assche" , Scott Bauer , Christoph Hellwig , Jan Kara , Hannes Reinecke , Subject: [PATCH 10/31] Avoid that scsi_exit_rq() triggers a use-after-free Date: Tue, 23 May 2017 17:33:59 -0700 Message-ID: <20170524003420.5381-11-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170524003420.5381-1-bart.vanassche@sandisk.com> References: <20170524003420.5381-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRmVeSWpSXmKPExsXCddJ5ka7gVZVIgzUdNhYL3uxls1i5+iiT xezpzUwWG/s5LPbe0rbovr6DzWL58X9MFi/nXWG3WLDxEaMDp8e0SafYPBbvecnksftmA5vH x6e3WDzWb7nK4nFmwRF2j8+b5ALYo7hsUlJzMstSi/TtErgyeh/OZi74o12xrGkCawPjDNUu Rg4OCQETiStLhboYuTiEBJYySVw4/4UNwtnGKHHr5kvmLkZOsKKP9xcwQiQ2MkrMPfcNLMEm YCTx7f1MFhBbRKBQ4tK2DrAiZoEeJomu47/AEsICXhKvXz9lBLFZBFQlWnves4PYvAL2EtN+ 9bNAbJCXOLtlJ9hQTqB416sJ7CDnCQnYSSza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jqmr/KbF9MkosxRmJhlrMRcWJAK90Kpzf AQAA MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(39840400002)(39450400003)(39850400002)(39400400002)(39410400002)(2980300002)(438002)(189002)(199003)(9170700003)(189998001)(106466001)(50226002)(48376002)(6666003)(38730400002)(356003)(50466002)(36756003)(2950100002)(33646002)(77096006)(81166006)(8676002)(2906002)(86362001)(575784001)(230783001)(72206003)(5003940100001)(76176999)(50986999)(8936002)(305945005)(1076002)(4326008)(47776003)(5660300001)(53936002)(478600001)(54906002); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR04MB0364; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM04FT030; 1:WJY1atmWSZO6FQ8XBvGTT2lKCTwiyyAAxtHOyfL4IxfbChXqw6KzP9Q30J303ddrvyfNTpEEO+KicHvPDa1ga+FiQYKwmNzlsGJajqp8GNrW1k6fyUbdwgT/K2avOueANJFGK2BfADxnumbGvFLOCv8yZ04KfTp32qOwbv2m8j2WtNfQtVWz3acNjAJ3QHxbpoAiS6gv5VhovaDn4XytOMj+t+bwexqozrPsWFRL93ESDeklE7WdxuZDR//tmRrHOdmWGq+G3duSx2wdrquN5M0Bu9K1DPDjETGkTsyTxpzfMxkZTme1jjdbNrgNDDtZppR0QJv2dzT14ndnf5PIACJivBBdhobnMnS6c/5iXbCTzgU/sXkml77WxdLmmIHAxRuJuzQjU9dv8ftltMYkh5y7kTTezf/SGT34WA0/kRwo1yxH1Jvd2kC6E5vRwzYJkgveNTOTauOfMlZkRnl0qSa0KFefr6X2ARW90Z8PZKVNGyGOje+LQh3qwVjChKlkWuIejZfyn+UQVPXZtzmHvmoMl3tKdRqFw+lZpYj9U8hrCAlb3o6/jQPeBkvZWnldsoS7JTfu8HQkDTRUzCK57A== X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR04MB0364: X-MS-Office365-Filtering-Correlation-Id: 911e5464-9d40-4bb7-b4f0-08d4a23ca276 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR:DM5PR04MB0364; X-Microsoft-Exchange-Diagnostics: 1; DM5PR04MB0364; 3:93mBxzb7lfhnwpTj0YSXXz+/i/Ow56qKPb01hFHdUfyl7dRgbs/hRuWVsKpavu4/xQOzDYvlG4UYqLF7os2pDjCF9sYcrcubVaBQiVLnWJe0n9jat/ithwkxGEv91L7W4GUqrKC6Nv6HdetUoWsZSZLf9C1EjnflcC9Hx80hgB5jZMGy+DFDt42M1nWGbo3S1tiCRnLPkn0qHgzqBDf8e62FQHXWm4KCP4CF2wRgNYhRnBg/35BD4bhjO+rBqUrYTJMqbWfLECjg+BjcyezTaH2rP7peu2c5fTYBs4JtSv8NuwewlaQGtgsNL7oPzLatiNbUvUZ9WjybLXE70ln7cCKjYDV0HgRy3K72txcwq7otpl3azcetSV2Nr8Qt91ylljttCh9GeNquXAkeYzTDW46ygilX7eAbQy+BrQbGJJHWfT4hUrZU9m7UTGLATuIJv5JtVpwsZQW8eyLqqIn6T/AoGqblXFVSjOHY3EXpJpX7dlaooNCXytPXM2OCuvbh X-Microsoft-Exchange-Diagnostics: 1; DM5PR04MB0364; 25:yyM1gyk1do+B2yfw9RfIwZgDk1OS81J5atvFQ6cL5G8g4NoK948UMCHsFvP/0a3odAh+ARttSOmOGauM/GiQRnjRf2T3440mB8rBUvN94JP1rzdrhE4pWovh03UKBnf7jzgrYpWqrPTEQjnapS8uVNnZeuZqDGjbYEKOqHyAOdTI0EFOhT/VvFVzFqRWyIyHuHM3vh7MzNTJ3AXRywPkJOiIKjOKJOUwrJ65dNkS89oqom3cFSO5RtAbZ15sjQL5H7L7wUwz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CSn70M5d X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(42932892334569)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700052)(100105000095)(100000701052)(100105300095)(100000702052)(100105100095)(6040450)(601004)(2401047)(13016025)(5005006)(13018025)(8121501046)(100000703052)(100105400095)(3002001)(10201501046)(93006095)(93004095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123558100)(20161123555025)(6072148)(100000704052)(100105200095)(100000705052)(100105500095); SRVR:DM5PR04MB0364; BCL:0; PCL:0; RULEID:(100000800052)(100110000095)(100000801052)(100110300095)(100000802052)(100110100095)(100000803052)(100110400095)(100000804052)(100110200095); SRVR:DM5PR04MB0364; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR04MB0364; 4:uBipfulkXT1/Fv8y5Hr/lGp9+KQm7YjUgIj5uU9Sgn?= =?us-ascii?Q?bkxwKWK9cH5VxGRTxnsRHHr7wcHL03KnJRFF3JoYTN7PDX6DuwT27gAQMLMA?= =?us-ascii?Q?zQmIbZxziG+5cpBF9bsAsfty5rLq1akCMi1FVVNyHh9M9oHUMfHahzPcjBwz?= =?us-ascii?Q?KGugvufDW9ZglMEq3xA/S/7+//tS1wojfocsAIPTTO6/GO36RjMTPZ3yQoiU?= =?us-ascii?Q?Ok/vNsaPLEeg9ONoN/AwkO1gDwSn3+GfZP1GNITIIvHa84O73ALV+UXPRaBJ?= =?us-ascii?Q?rABIeSt+p0WXIYb3yNL+kcRuogBZh0uotWACcHMTA+n7Ea7cfDQcI+mZWp1O?= =?us-ascii?Q?jxvF7K5LHlQigY9bRReuwZ4XyZHuf+gnsoKvXTt/XwdUPLdkuIiVCgwtV9a8?= =?us-ascii?Q?ikrZVWrfZ9C2aeTGYL0LbY5lm6rbDvuQ9uKdlrMTsCX0Gzv+uVy9gpiOJrPU?= =?us-ascii?Q?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WQVi/Nx0eNFQeVdQ1rA= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2017 00:34:26.8196 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR04MB0364 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 Dereferencing shost from scsi_exit_rq() is not safe because the SCSI host may already have been freed when scsi_exit_rq() is called. Increasing the shost reference count in scsi_init_rq() and dropping that reference in scsi_exit_rq() is nontrivial since scsi_host_dev_release() may sleep and since scsi_exit_rq() may be called from interrupt context. Since scsi_exit_rq() only needs a single bit from shost, copy that bit into struct scsi_cmnd. Reported-by: Scott Bauer Fixes: e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of struct request") Signed-off-by: Bart Van Assche Cc: Scott Bauer Cc: Christoph Hellwig Cc: Jan Kara Cc: Hannes Reinecke Cc: Reviewed-by: Hannes Reinecke --- drivers/scsi/scsi_lib.c | 43 +++++++++++++++++++++++++------------------ include/scsi/scsi_cmnd.h | 1 + 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 30a7900d331c..59400033aba8 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -44,23 +44,23 @@ static struct kmem_cache *scsi_sense_isadma_cache; static DEFINE_MUTEX(scsi_sense_cache_mutex); static inline struct kmem_cache * -scsi_select_sense_cache(struct Scsi_Host *shost) +scsi_select_sense_cache(bool unchecked_isa_dma) { - return shost->unchecked_isa_dma ? - scsi_sense_isadma_cache : scsi_sense_cache; + return unchecked_isa_dma ? scsi_sense_isadma_cache : scsi_sense_cache; } -static void scsi_free_sense_buffer(struct Scsi_Host *shost, - unsigned char *sense_buffer) +static void scsi_free_sense_buffer(bool unchecked_isa_dma, + unsigned char *sense_buffer) { - kmem_cache_free(scsi_select_sense_cache(shost), sense_buffer); + kmem_cache_free(scsi_select_sense_cache(unchecked_isa_dma), + sense_buffer); } -static unsigned char *scsi_alloc_sense_buffer(struct Scsi_Host *shost, +static unsigned char *scsi_alloc_sense_buffer(bool unchecked_isa_dma, gfp_t gfp_mask, int numa_node) { - return kmem_cache_alloc_node(scsi_select_sense_cache(shost), gfp_mask, - numa_node); + return kmem_cache_alloc_node(scsi_select_sense_cache(unchecked_isa_dma), + gfp_mask, numa_node); } int scsi_init_sense_cache(struct Scsi_Host *shost) @@ -68,7 +68,7 @@ int scsi_init_sense_cache(struct Scsi_Host *shost) struct kmem_cache *cache; int ret = 0; - cache = scsi_select_sense_cache(shost); + cache = scsi_select_sense_cache(shost->unchecked_isa_dma); if (cache) return 0; @@ -2003,10 +2003,13 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx, unsigned int numa_node) { struct Scsi_Host *shost = set->driver_data; + const bool unchecked_isa_dma = shost->unchecked_isa_dma; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); - cmd->sense_buffer = - scsi_alloc_sense_buffer(shost, GFP_KERNEL, numa_node); + if (unchecked_isa_dma) + cmd->flags |= SCMD_UNCHECKED_ISA_DMA; + cmd->sense_buffer = scsi_alloc_sense_buffer(unchecked_isa_dma, + GFP_KERNEL, numa_node); if (!cmd->sense_buffer) return -ENOMEM; cmd->req.sense = cmd->sense_buffer; @@ -2016,10 +2019,10 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq, static void scsi_exit_request(struct blk_mq_tag_set *set, struct request *rq, unsigned int hctx_idx) { - struct Scsi_Host *shost = set->driver_data; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); - scsi_free_sense_buffer(shost, cmd->sense_buffer); + scsi_free_sense_buffer(cmd->flags & SCMD_UNCHECKED_ISA_DMA, + cmd->sense_buffer); } static int scsi_map_queues(struct blk_mq_tag_set *set) @@ -2092,11 +2095,15 @@ EXPORT_SYMBOL_GPL(__scsi_init_queue); static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp) { struct Scsi_Host *shost = q->rq_alloc_data; + const bool unchecked_isa_dma = shost->unchecked_isa_dma; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); memset(cmd, 0, sizeof(*cmd)); - cmd->sense_buffer = scsi_alloc_sense_buffer(shost, gfp, NUMA_NO_NODE); + if (unchecked_isa_dma) + cmd->flags |= SCMD_UNCHECKED_ISA_DMA; + cmd->sense_buffer = scsi_alloc_sense_buffer(unchecked_isa_dma, gfp, + NUMA_NO_NODE); if (!cmd->sense_buffer) goto fail; cmd->req.sense = cmd->sense_buffer; @@ -2110,19 +2117,19 @@ static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp) return 0; fail_free_sense: - scsi_free_sense_buffer(shost, cmd->sense_buffer); + scsi_free_sense_buffer(unchecked_isa_dma, cmd->sense_buffer); fail: return -ENOMEM; } static void scsi_exit_rq(struct request_queue *q, struct request *rq) { - struct Scsi_Host *shost = q->rq_alloc_data; struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq); if (cmd->prot_sdb) kmem_cache_free(scsi_sdb_cache, cmd->prot_sdb); - scsi_free_sense_buffer(shost, cmd->sense_buffer); + scsi_free_sense_buffer(cmd->flags & SCMD_UNCHECKED_ISA_DMA, + cmd->sense_buffer); } struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h index b379f93a2c48..16351de31243 100644 --- a/include/scsi/scsi_cmnd.h +++ b/include/scsi/scsi_cmnd.h @@ -56,6 +56,7 @@ struct scsi_pointer { /* for scmd->flags */ #define SCMD_TAGGED (1 << 0) +#define SCMD_UNCHECKED_ISA_DMA (1 << 1) struct scsi_cmnd { struct scsi_request req;